Hey, I couldn''t find answer for this question for quite long, I hope some one will explain to me why layout specified in application.rb is not displayed properly on all views? I mean some divs are displayed wrong or without layout at all... let''s say login.rhtml has layout on its own and now it works ( exactly this same as project.rhtml which is layout for the whole project... ) but when I have this layout "project" in login_controller it does not work ( it is from app.rb ) So why is it so? That some views are not displaying layout correctly at all or just partialy ? Thanks a million Lukasz -- Posted via http://www.ruby-forum.com/.
Hi Lukasz, Lukasz wrote:> I mean some divs are displayed wrong > or without layout at all... let''s say login.rhtml has layout on its own > and now it works ( exactly this same as project.rhtml which is layout > for the whole project... ) but when I have this layout "project" in > login_controller it does not work ( it is from app.rb ) So why is it so? > That some views are not displaying layout correctly at all or just > partialy ?I''m not sure this will help since I don''t know much about the details of your app and am not sure I understand your problem statement 100%, but the basic rules for the view-layout hierarchy is that the view file that''s rendered will be 1) one in the app/views/ directory that''s named after the controller action, 2) the one that''s specified by the controller action (ie, through a render :something), or 3) application.rhtml. hth, Bill
Hey Bill, Thanks for response but thats not what I mean - acctualy You are right I was not very clear. Here I will try to explain my problem in more details. I have login controler with login method (so I have app/views/login.rhtm) and I have manage_users controler with delete add and edit methods on it ... (done by scaffolding) and therefor I need them all to share this same layout... I specified layout in application.rb but it seems that only manage_users has it... login.rhtml seems to have only some of it (even if it uses this same divs! ) I created a new one called login.rhtml inside /app/view/layout and it looks fine now but that annoys me cos it will require me to create a new layout file for each view which is not what I want :) I need them to share one layout... How it is now ? Thanks again. Cheers, Lukasz Bill Walton wrote:> Hi Lukasz, > > Lukasz wrote: > >> I mean some divs are displayed wrong >> or without layout at all... let''s say login.rhtml has layout on its own >> and now it works ( exactly this same as project.rhtml which is layout >> for the whole project... ) but when I have this layout "project" in >> login_controller it does not work ( it is from app.rb ) So why is it so? >> That some views are not displaying layout correctly at all or just >> partialy ? > > I''m not sure this will help since I don''t know much about the details of > your app and am not sure I understand your problem statement 100%, but > the > basic rules for the view-layout hierarchy is that the view file that''s > rendered will be 1) one in the app/views/ directory that''s named after > the > controller action, 2) the one that''s specified by the controller action > (ie, > through a render :something), or 3) application.rhtml. > > hth, > Bill-- Posted via http://www.ruby-forum.com/.
Lukasz, by default all controllers in your app will render app/views/layouts/application.rhtml. You don''t need to specify that in the application.rb. In your application.rhtml file you should have the following command in the body: <%= yield %> (previously this was <%= @content_for_layout %> which should also work. this will insert into that spot any content in the specific rhtml for that controller/method (ie, app/views/login/login.rhtml) if you have a controller named login with a method named login. Lukasz wrote:> I have login controler with login method (so I have > app/views/login.rhtm) and I have manage_users controler with delete add > and edit methods on it ... (done by scaffolding) and therefor I need > them all to share this same layout... I specified layout in > application.rb but it seems that only manage_users has it... > login.rhtml seems to have only some of it (even if it uses this same > divs! ) I created a new one called login.rhtml inside /app/view/layout > and it looks fine now but that annoys me cos it will require me to > create a new layout file for each view which is not what I want :) I > need them to share one layout...-- Posted via http://www.ruby-forum.com/.