目前,设计网址为/users/sign_in
,但我想将其更改为/signin
。
在routes.rb
文件中,我试过这个:
devise_for :users do
get "/signin" => "devise/sessions#new"
match '/signin', :to => 'devise/sessions#new'
get "/signout" => "devise/sessions#destroy"
match '/signout', :to => 'devise/sessions#destroy'
end
但没有任何效果。我收到一个错误说:
app/controllers/posts_controller.rb:19:in `show'
在show
部分,我有
def show
@post = Post.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @post }
end
end
控制器中的show
与设计有什么关系?
答案 0 :(得分:0)
试试这个:
devise_scope :user do
get "/signin" => "devise/sessions#new"
match '/signin' => 'devise/sessions#new'
get "/signout" => "devise/sessions#destroy"
match '/signout' => 'devise/sessions#destroy'
end
来源:https://github.com/plataformatec/devise/wiki/How-To:-Change-the-default-sign_in-and-sign_out-routes