2010-11-25 251 views
0

我正在使用Ruby On Rails 2.3.5與haml版本2.2.21(在我的environment.rb文件中)並且在視圖中生成的所有鏈接(使用haml)都會自動添加鏈接最後。Ruby On Rails Application.html.haml

例:

%li 
    =link_to 'sign up', {:controller=> 'users' , :action=> 'signup'} 

顯示 註冊(用戶/註冊)

任何人都知道這是爲什麼?

回答

0

你應該能夠做到:

=link_to 'Sign Up', user_registration_path 

對於未來的參考,你可以在命令

rake routes 

爲了讓應用程序中的所有命名路由的列表:

$ rake routes 
     new_user_session GET /users/sign_in(.:format)         {:action=>"new", :controller=>"devise/sessions"} 
      user_session POST /users/sign_in(.:format)         {:action=>"create", :controller=>"devise/sessions"} 
    destroy_user_session GET /users/sign_out(.:format)        {:action=>"destroy", :controller=>"devise/sessions"} 
     user_password POST /users/password(.:format)        {:action=>"create", :controller=>"devise/passwords"} 
    new_user_password GET /users/password/new(.:format)       {:action=>"new", :controller=>"devise/passwords"} 
    edit_user_password GET /users/password/edit(.:format)       {:action=>"edit", :controller=>"devise/passwords"} 
     user_password PUT /users/password(.:format)        {:action=>"update", :controller=>"devise/passwords"} 
    user_registration POST /users(.:format)           {:action=>"create", :controller=>"devise/registrations"} 
new_user_registration GET /users/sign_up(.:format)         {:action=>"new", :controller=>"devise/registrations"} 
edit_user_registration GET /users/edit(.:format)         {:action=>"edit", :controller=>"devise/registrations"} 
    user_registration PUT /users(.:format)           {:action=>"update", :controller=>"devise/registrations"} 
    user_registration DELETE /users(.:format)           {:action=>"destroy", :controller=>"devise/registrations"} 

路由名稱列在最左邊的列中。然後,您可以將'_path'附加到其中任何一個來訪問該路徑。

+0

感謝您的回覆。但我正在按照你所說的去做,而且結果如我所描述的那樣。它總是顯示註冊(用戶/註冊) – 2010-11-25 23:49:23