Ruby on Rails externalising Views -
i'm lamp developer making switch ruby development. in php, can split page segments (to maximise code re-use) using separate php files each section. example of being wordpress, have separate header / sidebar / content file etc.
is possible using ruby on rails? equivalent of embedding controller / view view? far i'm bit stumped on way embedded because seems there controller has route view, i'm unsure bit try include.
what looking called partials
. can create partial, such sidebar or footer, render template.
the official rails guide contains information using partials.
essentially, create file name prefixed underscore such posts/_form.html.erb
, render view
<%= render partial: "form" %>
you can specify absolute path views
folder
<%= render partial: "/posts/form" %>
the same naming conventions of template (e.g. format suffixes) apply.
Comments
Post a Comment