Is activeresource broken in rails 3.2.4?

22 views
Skip to first unread message

cyber c.

unread,
Jun 18, 2012, 5:45:45 PM6/18/12
to rubyonra...@googlegroups.com
Hi,

I see that
Person.find(:all) and Person.find(:all, :params => {id => '2'}) returns
all records irrespective of conditions. Is activeresource broken?
PS: Im using rails 3.2.4

--
Posted via http://www.ruby-forum.com/.

Craig White

unread,
Jun 18, 2012, 5:52:21 PM6/18/12
to rubyonra...@googlegroups.com

On Jun 18, 2012, at 2:45 PM, cyber c. wrote:

> Hi,
>
> I see that
> Person.find(:all) and Person.find(:all, :params => {id => '2'}) returns
> all records irrespective of conditions. Is activeresource broken?
> PS: Im using rails 3.2.4
----
do you actually have a column in the db named 'params' ? That would seem to be wrong so I'm gathering that what you are actually wanting is...

Person.find(:all, {:id => '2'}) # but coming from older versions of rails, I don't feel all that comfortable with the syntax of that and would tend to do

Person.find(:all, :conditions => ["id = ?", '2'])

Craig

cyber c.

unread,
Jun 18, 2012, 6:50:03 PM6/18/12
to rubyonra...@googlegroups.com
I dont have a column with "params".

Person.find(:all, :conditions => [ "id = ?","9"]) generates a request
Started GET "/persons.json" for 127.0.0.1 => hence returns all the
records

Where as
Person.find(:all, {:id => '2'}) generates a request
Started GET "/persons.json?id=2" for 127.0.0.1
But *returns all the records*

cyber c.

unread,
Jun 18, 2012, 9:29:37 PM6/18/12
to rubyonra...@googlegroups.com
Seems like this has been a problem/bug from earlier versions.

http://www.rornoob.com/a/active-resource-find-with-conditions-problem/

Is there a work around for this?

cyber c.

unread,
Jun 19, 2012, 1:12:40 PM6/19/12
to rubyonra...@googlegroups.com
Hi Ryan,

Where is not an activeresource method. Here are the list of
activeresource methods
http://api.rubyonrails.org/classes/ActiveResource/Base.html
Also i will be using find to look for records that match multiple
conditions like if name = XYZ, build = ABC etc

Matt Jones

unread,
Jun 20, 2012, 7:46:43 AM6/20/12
to rubyonra...@googlegroups.com


On Monday, 18 June 2012 17:45:45 UTC-4, Ruby-Forum.com User wrote:
Hi,

I see that
Person.find(:all) and Person.find(:all, :params => {id => '2'}) returns
all records irrespective of conditions. Is activeresource broken?
PS: Im using rails 3.2.4


Better question: is the service on the other end paying any attention to the parameters? Not going to have much success if it isn't...

--Matt Jones 

cyber c.

unread,
Jun 20, 2012, 1:30:06 PM6/20/12
to rubyonra...@googlegroups.com
Found a solution to the problem , the default index methods of the
controller should be modified to return records according to the params
Reply all
Reply to author
Forward
0 new messages