ruby on rails - Why is it normal for render to be called in both the controller and in the view? -
the rails guide layouts , rendering in rails gives examples of render being used in both controller , view.
the section rendering default ... mentions rendering called default. section using render gives example of render
being called within controller:
def update @book = book.find(params[:id]) if @book.update(book_params) redirect_to(@book) else render "edit" end end
the section using partials gives example of render being used within view, example use partials.
<%= render "menu" %>
neither cases of render being used in controller, nor case of render being used in view, strike me illogical. what's confusing me thought 1 of major concepts of rails model view controller separation, means giving separate responsibilities model, view, , controller.
why normal render called in both controller , in view?
i'd if used properly, when render used in view, should organization/structural tool in order make code view more understandable , readable.
when used in controller, it's defining entry point view , primary association between action in controller , view.
the difference subtle.
Comments
Post a Comment