【问题标题】:change routes in devise在设计中更改路线
【发布时间】:2012-01-27 16:05:05
【问题描述】:

我正在使用 ruby​​ 1.9.2、rails 3.1.3、devise 1.5.3,我需要更改设计路线,我已经更改了默认路线,喜欢登录和注销,但我需要更改其他路由,例如:

http://localhost:3000/password/new

我需要,当用户单击链接时,您是否忘记了密码?前往:

http://localhost:3000/recovery_password

在我尝试过的路线中:

get "recovery_password", :to => "devise/passwords#new"                                    
get 'recovery_password' => 'devise_passwords#new', :as => :new_user_password

但不起作用,请帮忙。

提前致谢。

【问题讨论】:

    标签: ruby-on-rails-3 devise custom-routes


    【解决方案1】:

    试试这个。它应该有效。 ;)

    # change :devise_model to :users, or :admins or any name of your devise model 
    devise_for :devise_model do
        get 'recovery_password' => "devise/passwords#new"
    end
    

    你可以像这样在视图中使用它。

    link_to 'Forgot you password?', recovery_password_url
    

    附言。如果您有自定义设计控制器。您应该先告诉路由器,并将设计控制器更改为您自定义的控制器名称。

    【讨论】:

    • 现在设计更新到 2.0.0 版本,点击查看 github 页面this link
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-10
    • 2020-06-10
    相关资源
    最近更新 更多