我怎样才能将设计路由到某些路由并使挂钩工作
how can i route devise to certain routes and make hook work
我有以下路由文件,我基本上想 link /users/id 到 views/registrations/show 中的文件。现在我收到错误
The action 'show' could not be found for UsersController
Omr::Application.routes.draw do
devise_for :admins
resources :pins
devise_for :users ,:controllers => { :registrations => "registrations" }
root 'pins#index'
get 'user_root' => 'pins#index', as: :user_root
get 'about' => 'pages#about'
get 'users_list' => 'pages#users_list'
match 'users/:id' => 'users#destroy', :via => :delete, :as => :admin_destroy_user
resources :users
resources :registrations
post "/hook" => "registrations#hook"
post "/registrations/:id" => "registrations#show"
resources :courses
此外,我认为挂钩也会出现同样的问题,该挂钩应该在从贝宝处理的付款重定向回来时更新用户属性,但不会更新我的数据库中的任何内容
hook_path POST /hook(.:format) registrations#hook
registrations_controller.rb def hook 看起来像这样
protect_from_forgery except: [:hook]
def hook
params.permit! # Permit all Paypal input params
status = params[:payment_status]
if status == "Completed"
@User = User.find params[:invoice]
@User.update_attributes notification_params: params, status: status, transaction_id: params[:txn_id], purchased_at: Time.now
end
render nothing: true
end
您可以通过以下方式将新路由添加到用户资源。
把东西放在 devise_for 里就行了:
devise_for :users do
post "/hook" => "devise/registrations#hook"
end
我有以下路由文件,我基本上想 link /users/id 到 views/registrations/show 中的文件。现在我收到错误
The action 'show' could not be found for UsersController
Omr::Application.routes.draw do
devise_for :admins
resources :pins
devise_for :users ,:controllers => { :registrations => "registrations" }
root 'pins#index'
get 'user_root' => 'pins#index', as: :user_root
get 'about' => 'pages#about'
get 'users_list' => 'pages#users_list'
match 'users/:id' => 'users#destroy', :via => :delete, :as => :admin_destroy_user
resources :users
resources :registrations
post "/hook" => "registrations#hook"
post "/registrations/:id" => "registrations#show"
resources :courses
此外,我认为挂钩也会出现同样的问题,该挂钩应该在从贝宝处理的付款重定向回来时更新用户属性,但不会更新我的数据库中的任何内容
hook_path POST /hook(.:format) registrations#hook
registrations_controller.rb def hook 看起来像这样
protect_from_forgery except: [:hook]
def hook
params.permit! # Permit all Paypal input params
status = params[:payment_status]
if status == "Completed"
@User = User.find params[:invoice]
@User.update_attributes notification_params: params, status: status, transaction_id: params[:txn_id], purchased_at: Time.now
end
render nothing: true
end
您可以通过以下方式将新路由添加到用户资源。 把东西放在 devise_for 里就行了:
devise_for :users do
post "/hook" => "devise/registrations#hook"
end