Hi
In my routes.rb I have
map.login ''/login'',:controller => :user_sessions, :action
=> :new
Now I have controller action as
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
redirect_to some_url
else
render :action => :new,:layout => ''my_layout''
end
end
The problem in the else case when render action new again what I
get in browser is
http://localhost:3000/user_session
But what I need is http://localhost:3000/login Or in the worst case
http://localhost:3000/user_sessions/new
How can I do this? Please help
Thanks
Tom
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
I got a solution from another old thread in a different forum like
map.login ''/login'', :controller =>
''admin/user_session'', :action =>
''new'',
:conditions => { :method => :get }
# This line does the trick:
map.connect ''/login'', :controller =>
''admin/user_session'', :action =>
''create'',
:conditions => { :method => :post }
Then in new.html.erb
<% form_for @user_session, :url => login_path do |f| %>
This is perfectly right. But if I have a route like
map.root :controller => "users",:action => "new"
And if my form is like
<% form_for @user do |f| %>
Please guide how I can apply this here.
Thanks
Tom
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.