Hello,
I seem to be having a very hard time creating a login form that would
sit in the sidebar or header of a website which can be used to login
from ANY page.
The problem is that the login form needs to be somehow ‘included’ in the
application ‘global’ layout, but all the reference material places the
“login” method as a separate view.
How would I include the login as part of the layout?
Steve,
You reference a partial in your master layout file, application.rhtml
which resides in views/layouts. You will need to include the path to
the partial though.
For example, if you have a login form in apps/views/sessions/
_form.rhtml
then you could reference that in your application.rhtml file as:
<%= render :partial => ‘sessions/_form.html’ %>
Cheers,
Nicholas
On Nov 16, 11:24 pm, Steve O. [email protected]
On Nov 16, 2007, at 10:24 PM, Steve O. wrote:
I seem to be having a very hard time creating a login form that would
sit in the sidebar or header of a website which can be used to login
from ANY page.
The problem is that the login form needs to be somehow ‘included’ in
the
application ‘global’ layout, but all the reference material places the
“login” method as a separate view.
How would I include the login as part of the layout?
Here’s how I do it:
In my views directory I created a directory called shared, where I put
any partials that are used in more than one place.
In there I have a partial named _quick_login_form.rhtml that creates
the form fields.
Then in my layout I have this:
<% form_tag :action => 'login', :controller => :login do %>
<%= render :partial => '/shared/quick_login_form' %>
<%= submit_tag "Member Login" %>
<%= link_to "Forgot your Login?", :action
=> :forgotten_login, :controller => :login %>
<% end %>
You could put the whole form in the partial, of course.