ruby-on-railsrubyruby-on-rails-5wicked-gem

Is there a better way to create a dynamic rails path?


Is there a better way to do this in Rails using the wicked gem?

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

Solution

  • This can be done by using url_for method

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