Hi I''m new to RoR and for my webpage I want to nest a page that has my login fields in a seperate file. The idea is to create a login area on the left side of the screen that will be always visible until they login while the center section will be the main area. I can do this using the application layout file, but I would like to not put the RHTML for the login into the layout directly. Instead I''d like to leave it in the view/login>index.rhtml file. Is there a way that from my application layout I could have that file rendered into the application layout from the login file? I''ve tried using ''<%= render :partial => ''login'' %>'' already and about 100 different things I found on google. The one way I found that almost worked was this "<%= render_component :controller => "login", :action => "index" %>" but it creates some kind of loop so I end up with 20 user and password field on the screen when I hit stop. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
franco.fallica-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2006-Aug-22 09:37 UTC
[Rails] Re: Putting a page within a page
You had it. <%= render :partial=>"login" %> is the way to go. Keep in mind when rendering partials you file needs to be caled _login.rhtml not login.rhml. an other way would be using frames, but the kind a hacky solution - and I don''t recomend it. I''ve done the same thing as you want by using partials. the following is from wiki.rubyonrails.com: Sharing partial templates between controllers A partial template is normally placed in the same view directory as the template it''s called from. To use the partial in a template in a different directory, use the full path to that directory (from the views directory). For example, consider a template called _author_summary.rhtml which exists in the directory, views/author. Now, you may also want to show an author summary from, say, a blog page. In the blog template (which is saved in /views/blog), use this: <%= render :partial => ''author/author_summary'' %> Notice that you don''t put the initial underscore that actually exists on the name of the template. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
D. K. wrote:> Hi I''m new to RoR and for my webpage I want to nest a page that has my > login fields in a seperate file. The idea is to create a login area on > the left side of the screen that will be always visible until they login > while the center section will be the main area. I can do this using the > application layout file, but I would like to not put the RHTML for the > login into the layout directly. Instead I''d like to leave it in the > view/login>index.rhtml file.You would probably want to separate login form into a separate file "app/views/login/_form.rhtml". Then from your login/index action say render :partial => ''form'' and from your layout file: render :partial => ''login/form'' Components are evil (and slow). Zsombor -- Company - http://primalgrasp.com Thoughts - http://deezsombor.blogspot.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---