15

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?

Chris Alley
  • 3,015
  • 2
  • 21
  • 31
  • I'm actually running into this after a recent 4.2 upgrade, but am not using turbolinks. – maxhs Sep 20 '15 at 00:19

1 Answers1

49

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'

Chris Alley
  • 3,015
  • 2
  • 21
  • 31
  • 4
    Wow. This one was really hard to find, I spent about 2 hours not knowing what to do with this error. Many thanks for that answer. – jmarceli Mar 18 '15 at 13:36
  • 4
    I encountered this when I upgraded to 4.2 and all my tests that has assert_redirected_to suddenly fails. I've been at this for roughly 3 hours too, so thanks OP for answering your own question. – Rystraum May 07 '15 at 16:37
  • Fortunately, I found this within minutes. – Smek Mar 01 '19 at 10:31