Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 无法获取rails ActiveRecord:条件正在工作,';参数数目错误(给定1,应为0)';_Ruby On Rails_Ruby_Activerecord - Fatal编程技术网

Ruby on rails 无法获取rails ActiveRecord:条件正在工作,';参数数目错误(给定1,应为0)';

Ruby on rails 无法获取rails ActiveRecord:条件正在工作,';参数数目错误(给定1,应为0)';,ruby-on-rails,ruby,activerecord,Ruby On Rails,Ruby,Activerecord,我有以下代码用于控制器中的活动记录条件 @this_section = Section.all( :conditions => [ "url_section = ?", params[:ssection] ] ) 当我试图转到与其关联的网页时,浏览器中出现以下错误: ArgumentError in UpcomingEventsController#index wrong number of arguments (given 1, expected 0) 在美洲狮日志中,我得到:

我有以下代码用于控制器中的活动记录条件

 @this_section = Section.all( :conditions => [ "url_section = ?", params[:ssection] ] )
当我试图转到与其关联的网页时,浏览器中出现以下错误:

ArgumentError in UpcomingEventsController#index

wrong number of arguments (given 1, expected 0)
在美洲狮日志中,我得到:

 Started GET "/" for 127.0.0.1 at 2017-11-21 11:06:22 +0000
 Processing by UpcomingEventsController#index as HTML
 Completed 500 Internal Server Error in 3ms (ActiveRecord: 0.0ms)

 ArgumentError (wrong number of arguments (given 1, expected 0)):

 app/controllers/upcoming_events_controller.rb:11:in `index'
11是这篇文章顶部的代码行

我过去一直在想怎么做

此页面的路径是

   get 'upcoming_events/:ssection/:cost', to: 'upcoming_events#index'

我试图做的是将@this_section设置为数据库的sections表中的记录,其中url_section=params[:ssection]。我使用的是rails 5。

您试图将2.3查询语法应用于ActiveRecord 5.x。正确的方法是:

@this_section = Section.where(url_section: params[:section])
或者更准确地说(因为在这种情况下,您似乎只需要一个实例):


您正在尝试将2.3查询语法应用于ActiveRecord 5.x。正确的方法是:

@this_section = Section.where(url_section: params[:section])
或者更准确地说(因为在这种情况下,您似乎只需要一个实例):