Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not Rendering the Default Application Layout in Rails 3

I am an entry developer in Rails and I am doing system study of an Application developed in Ruby 1.8.7 and Rails 3.0.3. In my App, I have application_controller with an application.html.erb layout and a home_controller with a home_html.erb layout along with CRUD views. Then in my routes.rb, the default route is set as given below along with resourceful routing for home.

root :to => 'home#index'

resources :home

In application.html.rb, we have default layout to be rendered inside which the other views need to be inserted using <%= yield %>. But I have another layout called home.html.erb whose contents are the same as that of the application.html.erb. When I run the app, the default layout is loaded from home.html.erb instead of application.html.erb. What could be the reason?

like image 412
Rajesh Omanakuttan Avatar asked Nov 19 '25 01:11

Rajesh Omanakuttan


1 Answers

In your controller write

   class TetsController < ApplicationController
      layout "layout_name"
      #...
    end
like image 95
Sachin R Avatar answered Nov 21 '25 16:11

Sachin R



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!