为什么在 Rails 4.2 中使用 redirect_to 时会出现错误数量的参数错误? [英] Why is there a wrong number of arguments error when using redirect_to in Rails 4.2?

查看:27
本文介绍了为什么在 Rails 4.2 中使用 redirect_to 时会出现错误数量的参数错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在应用程序的 Rails 4.1.1 版本中,我在articles_controller 中有以下创建方法:

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

但是,更新到 Rails 4.2 后,尝试重定向时会出现以下错误:

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

错误数量的参数(2 for 1)

为什么会出现这个错误,如何解决?

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

推荐答案

该问题是由包含过时版本的 Turbolinks (2.2.2) 的 Gemfile 引起的.我通过将 Turbolinks 升级到 2.5.3 版解决了这个问题.

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.

在 Gemfile 中:

In Gemfile:

gem 'turbolinks', '~>2.5.3'

这篇关于为什么在 Rails 4.2 中使用 redirect_to 时会出现错误数量的参数错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆