Problem with Active Query condition

20 views
Skip to first unread message

Ben Edwards

unread,
Nov 20, 2017, 7:46:09 PM11/20/17
to Ruby on Rails: Talk
I have the following code for an active record condition in a controller

  @thus_section = Section.all( :conditions => [ "url_section = ?", params[:ssection] ] )

And when I try to goto to the webpage asociated with it I get the following error:

  ArgumentError in UpcomingEventsController#index


  wrong number of arguments (given 1, expected 0)


I was using  http://guides.rubyonrails.org/active_record_querying.html to work out how to do it.


What am I doing wrong?





Hassan Schroeder

unread,
Nov 20, 2017, 9:04:27 PM11/20/17
to rubyonrails-talk
On Mon, Nov 20, 2017 at 4:46 PM, Ben Edwards <lo...@funkytwig.com> wrote:

> What am I doing wrong?

In order:

1. not having a test for the method in the first place
2. not showing us the complete code for that method
3. not showing us the full log entry and stack trace

😀
--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Pratik

unread,
Nov 21, 2017, 1:14:21 PM11/21/17
to Ruby on Rails: Talk
You can do it like below

Section.find(:all, :conditions => { :url_section => params[:ssection] } )

Ben Edwards

unread,
Nov 26, 2017, 3:28:30 PM11/26/17
to Ruby on Rails: Talk
Actualy you missed the main thisg, not saying whitch version of rails I was using.  I was using old syntax for 9I think 2.3) and was using rails 5.
Reply all
Reply to author
Forward
0 new messages