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? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
On 7/21/07, Scott Pn <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> 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 Fernandez http://jroller.com/obie/ Pre-order my book The Rails Way today! http://www.amazon.com/dp/0321445619 --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
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. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld 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): -------------------------------------------------------------------- <h1>Please Login</h1> <%= render(:partial => "login") %> -------------------------------------------------------------------- Here is my other page which is in my layout folder (layout/main.rhtml): -------------------------------------------------------------------- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> <title><%= controller.action_name %></title> <%= stylesheet_link_tag ''scaffold'' %> </head> <body> <div align="center"> <div class="sidebarLeft"> <% if session[:user_id].nil? %> <%= render(:partial => "login/login") %> <% else %> <p> Hello, <%= session[:username] %><br /> <%= link_to "Logout", :controller => ''login'', :action => ''logout'' %> </p> <% end %> </div> <div class="contentWrapper"> <p style="color: green"><%= flash[:notice] %></p> <%= yield :layout %> </div> </div> </body> </html> --------------------------------------------------------------------- And here is what my partial looks like (login/_login.rhtml): --------------------------------------------------------------------- <% form_tag do %> <label>Username:</label> <%= text_field_tag :username, params[:username] %> <br /> <label>Password:</label> <%= password_field_tag :password, params[:password] %> <br /> <%= submit_tag "Login" %> <% end %> --------------------------------------------------------------------- -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
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 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Shai Rosenfeld 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): > -------------------------------------------------------------------- > > <h1>Please Login</h1> > <%= render(:partial => "login") %> > -------------------------------------------------------------------- > > Here is my other page which is in my layout folder (layout/main.rhtml): > -------------------------------------------------------------------- > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <head> > <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> > <title><%= controller.action_name %></title> > <%= stylesheet_link_tag ''scaffold'' %> > </head> > <body> > <div align="center"> > <div class="sidebarLeft"> > <% if session[:user_id].nil? %> > <%= render(:partial => "login/login") %> > <% else %> > <p> > Hello, <%= session[:username] %><br /> > <%= link_to "Logout", :controller => ''login'', :action => ''logout'' %> > </p> > <% end %> > </div> > > <div class="contentWrapper"> > <p style="color: green"><%= flash[:notice] %></p> > <%= yield :layout %> > </div> > </div> > </body> > </html> > --------------------------------------------------------------------- > And here is what my partial looks like (login/_login.rhtml): > --------------------------------------------------------------------- > <% form_tag do %> > <label>Username:</label> > <%= text_field_tag :username, params[:username] %> > <br /> > <label>Password:</label> > <%= password_field_tag :password, params[:password] %> > <br /> > <%= submit_tag "Login" %> > <% end %> > --------------------------------------------------------------------- > -- > Posted via http://www.ruby-forum.com/. > > > >-- Obie Fernandez http://jroller.com/obie/ Pre-order my book The Rails Way today! http://www.amazon.com/dp/0321445619 --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
> <% if session[:user_id].nil? %> > <%= render(:partial => "login/login") %> > <% else %> > <p>stupid question, but possible session[:user_id] is not nil? seems it should work. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld wrote:>> <% if session[:user_id].nil? %> >> <%= render(:partial => "login/login") %> >> <% else %> >> <p> > > 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. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Obie Fernandez 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 <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: >> >> <title><%= controller.action_name %></title> >> <%= link_to "Logout", :controller => ''login'', :action => ''logout'' %> >> </html> >> <%= submit_tag "Login" %> >> <% end %> >> --------------------------------------------------------------------- >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > > -- > Obie Fernandez > http://jroller.com/obie/ > > Pre-order my book The Rails Way today! > http://www.amazon.com/dp/0321445619Yeah 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. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---