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/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Craig White at Jun 18, 2012 at 9:52 pm

    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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Cyber c. at Jun 18, 2012 at 10:50 pm
    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*

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Cyber c. at Jun 19, 2012 at 1:29 am
    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?

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Ryan Buckley at Jun 19, 2012 at 4:24 pm
    If you're using Rails 3, why not just do Person.where(:id => 2) ?
    On Monday, June 18, 2012 11:45:45 AM UTC-10, 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

    --
    Posted via http://www.ruby-forum.com/.
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/XsDxi9ORjiYJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Cyber c. at Jun 19, 2012 at 5:12 pm
    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

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Matt Jones at Jun 20, 2012 at 11:46 am

    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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HulCR5paFrUJ.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Cyber c. at Jun 20, 2012 at 5:30 pm
    Found a solution to the problem , the default index methods of the
    controller should be modified to return records according to the params

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

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJun 18, '12 at 9:45p
activeJun 20, '12 at 5:30p
posts8
users4
websiterubyonrails.org
irc#RubyOnRails

People

Translate

site design / logo © 2021 Grokbase