【问题标题】:Is there a better way to create a dynamic rails path?有没有更好的方法来创建动态导轨路径?
【发布时间】:2019-08-29 11:58:36
【问题描述】:

有没有更好的方法在 Rails 中使用 wicked gem 来做到这一点?

def finish_wizard_path
  public_send("#{controller_name}_path", current_user.try(controller_name.intern).id)
end

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-5 wicked-gem


    【解决方案1】:

    这可以通过使用url_for方法来完成

    url_for(controller: controller_name, action: :new, id: current_user.id)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-08-02
      • 1970-01-01
      • 1970-01-01
      • 2010-09-09
      • 2014-07-06
      • 2012-08-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多