我如何将设计路由到某些路线并使钩子工作

时间:2015-01-23 12:42:00

标签: ruby-on-rails ruby paypal devise

我有followin routes文件,我基本上想将/ users / id链接到views / registrations / show中的文件。现在我收到了错误

  

找不到UsersController

的动作'show'
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

另外,我认为同样的问题发生在钩子上,当从paypal处理的付款重定向但是没有更新我的数据库中的任何内容时应该更新用户属性

  

hook_path POST /hook(.:format)注册#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

1 个答案:

答案 0 :(得分:0)

您可以通过以下方式将新路线添加到用户资源。 只需将内容保存在devise_for中即可:

devise_for :users do
    post "/hook" =>  "devise/registrations#hook"
end