Partial problem

I created a partial for my login form and I have it in my my login view
folder (‘login/_login.rhtml’), When I call the partial for my login page
login.rhtml it works fine. I have it on a layout for all pages that
aren’t the login page, and I call it by the command:

render(:partial => ‘login/login’)

But when I click the submit button it does nothing.
Any ideas on what the problem is?

Scott Pn wrote:

I created a partial for my login form and I have it in my my login view
folder (‘login/_login.rhtml’), When I call the partial for my login page
login.rhtml it works fine. I have it on a layout for all pages that
aren’t the login page, and I call it by the command:

render(:partial => ‘login/login’)

But when I click the submit button it does nothing.
Any ideas on what the problem is?

… it looks good at a first start. maybe 'tis worth posting your code,
as it doesn’t seem there’s any problem with what you’ve posted.

Shai R. wrote:

… it looks good at a first start. maybe 'tis worth posting your code,
as it doesn’t seem there’s any problem with what you’ve posted.

Here is what I have for my login page, which uses the _login partial,
this works fine (login/login.rhtml):

Please Login


<%= render(:partial => “login”) %>

Here is my other page which is in my layout folder (layout/main.rhtml):

<%= controller.action_name %> <%= stylesheet_link_tag 'scaffold' %>
<% if session[:user_id].nil? %> <%= render(:partial => "login/login") %> <% else %>

Hello, <%= session[:username] %>
<%= link_to "Logout", :controller => 'login', :action => 'logout' %>

<% end %>

<%= flash[:notice] %>

<%= yield :layout %>
--------------------------------------------------------------------- And here is what my partial looks like (login/_login.rhtml): --------------------------------------------------------------------- <% form_tag do %> Username: <%= text_field_tag :username, params[:username] %>
Password: <%= password_field_tag :password, params[:password] %>
<%= submit_tag "Login" %> <% end %> ---------------------------------------------------------------------
 <% if session[:user_id].nil? %>

<%= render(:partial => “login/login”) %>
<% else %>

stupid question, but possible session[:user_id] is not nil? seems it
should work.

On 7/21/07, Scott Pn [email protected] wrote:

I created a partial for my login form and I have it in my my login view
folder (‘login/_login.rhtml’), When I call the partial for my login page
login.rhtml it works fine. I have it on a layout for all pages that
aren’t the login page, and I call it by the command:

render(:partial => ‘login/login’)

But when I click the submit button it does nothing.
Any ideas on what the problem is?

I don’t think you have posted enough code to diagnose the problem. I’m
guessing that is has something to do with the way you have setup the
url params for your form, so that they’re in the right context when
you’re executing actions in the login_controller scope, but otherwise
not.

Cheers,
Obie


Obie F.

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619

Shai R. wrote:

 <% if session[:user_id].nil? %>

<%= render(:partial => “login/login”) %>
<% else %>

stupid question, but possible session[:user_id] is not nil? seems it
should work.

Already tested it, I thought the same thing, but If I login using
localhost:3000/login/login where the partial is on the login page it
works fine and when I go back to any other page with the partial on it
the message is displayed.
If the user is nil the partial form is displayed, but when I click
submit nothing works, idk if I pointed that out or not, or if it makes
any difference in differentiating the problem.

You have not provided any explicity action to form_tag in your
partial. That means it will post back to its current URL. When you’re
on the login page, I’m guessing that it works fine, since it will POST
to the /login/login action. However, anywhere else on your site it
will not work.

Provide an action to that form_tag and it will work. [i.e. form_tag ‘/login/login’]

On 7/22/07, Scott Pn [email protected] wrote:

<%= controller.action_name %> <%= link_to "Logout", :controller => 'login', :action => 'logout' %> <%= submit_tag "Login" %> <% end %> --------------------------------------------------------------------- -- Posted via http://www.ruby-forum.com/.


Obie F.

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619

Obie F. wrote:

You have not provided any explicity action to form_tag in your
partial. That means it will post back to its current URL. When you’re
on the login page, I’m guessing that it works fine, since it will POST
to the /login/login action. However, anywhere else on your site it
will not work.

Provide an action to that form_tag and it will work. [i.e. form_tag ‘/login/login’]

On 7/22/07, Scott Pn [email protected] wrote:

<%= controller.action_name %> <%= link_to "Logout", :controller => 'login', :action => 'logout' %> <%= submit_tag "Login" %> <% end %> --------------------------------------------------------------------- -- Posted via http://www.ruby-forum.com/.


Obie F.
Best Online Casino in Australia | Top Licensed Casinos for Gamblers

Pre-order my book The Rails Way today!
http://www.amazon.com/dp/0321445619

Yeah I actually figured that out yesterday, I realized that it wasn’t
specifying any controller so it assumed whatever controller it was on.
However I did encounter another problem where the controller
specification didn’t work, even though it should (probably just a bug on
my machine or something), but a way around it is to build your own html
form.

Thanks for the help.