小编Bre*_*ses的帖子

设计自定义after_update_path_for未被调用(Rails 4)

我正在使用设计,并希望在基于条件语句更新用户后指定不同的重定向.我确实遵循了这个https://github.com/plataformatec/devise/wiki/How-To:-Customize-the-redirect-after-a-user-edits-their-profile,它没有调用我的自定义after_update_path_for方法.

routes.rb

devise_for :users, :skip => [:registrations], :controllers => { :registrations => :registrations }

as :user do
  get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'    
  put 'users/:id' => 'devise/registrations#update', :as => 'user_registration'            
end
Run Code Online (Sandbox Code Playgroud)

我有跳过注册的原因是因为我不希望有新的并为用户创建路由.我不确定问题是否与路线或其他问题有关.

这里是 registrations_controller.rb

class RegistrationsController < Devise::RegistrationsController
  protected
    def after_update_path_for(resource)
      binding.pry
      if current_user.position == "owner" && current_user.sign_in_count == 1
        hub_landing_path
      end
    end
end
Run Code Online (Sandbox Code Playgroud)

任何帮助是极大的赞赏.这真的让我感到难过,所以如果有人有任何想法,我很乐意尝试一下.

ruby ruby-on-rails devise ruby-on-rails-4

4
推荐指数
1
解决办法
1416
查看次数

隐藏ActiveRecord MySQL结果到对象数组

当我运行这一行时,@users = ActiveRecord::Base.connection.execute(raw)我得到了一个mysql结果,我觉得它不像实际用户对象那样干净或易于使用.有没有办法将此结果转换为类User对象数组?谢谢您的帮助.

ruby ruby-on-rails ruby-2.0 ruby-on-rails-4

3
推荐指数
1
解决办法
382
查看次数

为什么我得到''parse':( <unknown>):Ruby中的YAML文件中不允许在此上下文中使用映射值

尝试在Ruby中打开我的Yaml文件时出现上述错误.我已在此验证器中检查过YAML,它已通过http://yamllint.com/.我不确定我的YAML会阻止它打开是什么问题.有任何想法吗?这是YAML文件.我正在尝试打开该文件yml = YAML::load(File.open('servers.yml'))

---
servers:
  - ps-overture-d01
    location: ps-overture-d01
    tomcat_location: /home/tomcat/tomcat/webapps/report/
    user: tomcat
    menus:
      - Accounts Receivable
        reports:
          - Accounts Receivable Aging Report
            name: AccountsReceivableAgingReport
            location: /public/Common/Reports/Accounts_Receivable_Reports
      - Inventory
        reports:
          - Inventory Master List Report
            name: InventoryMasterListReport
            location: /public/Common/Reports/Inventory_Reports
          - Inventory Totals Report
            name: InventoryTotalsReport
            location: /public/Common/Reports/Inventory_Reports
          - Dealer Purchasing Report
            name: DealerPurchasingReport
            location: /public/Common/Reports/Inventory_Reports
          - DOA Report
            name: DOAReport
            location: /public/Common/Reports/Inventory_Reports
          - Stock Transfers Report
            name: StockTransfersReport
            location: /public/Common/Reports/Inventory_Reports
          - Removed Inventory Report
            name: RemovedInventoryReport
            location: …
Run Code Online (Sandbox Code Playgroud)

ruby yaml ruby-2.0

3
推荐指数
1
解决办法
6508
查看次数

标签 统计

ruby ×3

ruby-2.0 ×2

ruby-on-rails ×2

ruby-on-rails-4 ×2

devise ×1

yaml ×1