Using master(single) template for all view pages

Hi all
i want to use a master template for all my view files to use the rails
DRY feature.So How can i achieve that. I already googled it but
unfortunately didn’t get much help.
any help would be appreciated

venkata reddy wrote in post #977331:

Hi all
i want to use a master template for all my view files to use the rails
DRY feature.

What do you mean by the rails DRY feature? DRY is coding practice not a
framework feature.

So How can i achieve that. I already googled it but
unfortunately didn’t get much help.
any help would be appreciated

You use layouts for this. You put the common layout ERb (or HAML) in
./app/views/layouts then put the page specific ERb in
./app/views/ and use <%= yield %> and/or <%= yield
:some_content %> inside the layout templates to mark where the page
specific code should be rendered.

Rails will, by convention, look for ./app/layouts/application.html.erb
if no other layout is specified.

./app/layouts/application.html.erb

Demo <%= stylesheet_link_tag :all %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %>

<%= yield %>


If you haven’t done so already I’d recommend starting right here:

http://guides.rubyonrails.org/getting_started.html

For information more focused on layouts and views go here:

http://guides.rubyonrails.org/layouts_and_rendering.html

venkata reddy wrote in post #977331:

Hi all
i want to use a master template for all my view files to use the rails
DRY feature.So How can i achieve that. I already googled it but
unfortunately didn’t get much help.
any help would be appreciated

Are you looking for the use of layouts?
http://guides.rubyonrails.org/layouts_and_rendering.html

Best,

Marnen Laibow-Koser
http://www.marnen.org
[email protected]

thank u…very good tutorials…

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs