Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

自作多情 提交于 2019-11-29 17:37:21

问题


In the Rails 4.1.1 version of an app, I have the following create method in articles_controller:

def create
  @article = Article.new(article_params)
  authorize @article
  if @article.save
    flash[:notice] = "Successfully created article."
    redirect_to edit_article_path(@article)
  else
    render :new
  end
end

However, after updating to Rails 4.2 the following error occurs when the redirect is attempted:

wrong number of arguments (2 for 1)

Why does this error occur and how can it be resolved?


回答1:


The issue was caused by the Gemfile containing an outdated version of Turbolinks (2.2.2). I resolved the issue by upgrading Turbolinks to version 2.5.3.

In Gemfile:

gem 'turbolinks', '~> 2.5.3'



来源:https://stackoverflow.com/questions/27956998/why-is-there-a-wrong-number-of-arguments-error-when-using-redirect-to-in-rails-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!