# Aliased render

**URL:** <https://www.ruby-forum.com/t/aliased-render/184496>\
**Category:** Rails\
**Created:** [March 3, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/aliased-render/184496 "2010-03-03T13:10:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 3, 2010, 1:10pm UTC](https://www.ruby-forum.com/t/aliased-render/184496/1 "2010-03-03T13:10:26Z")

</div>

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](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](http://localhost:3000/user_sessions/new)

```
 How can I do this? Please help

```

Thanks  
Tom

---

<div class="post-metadata">

**Author:** ![tom-mac](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/bc8723/32.png) [@tom-mac](https://www.ruby-forum.com/u/tom-mac)\
**Post date:** [March 3, 2010, 1:53pm UTC](https://www.ruby-forum.com/t/aliased-render/184496/2 "2010-03-03T13:53:39Z")

</div>

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
