Aliased render

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs