hello all, if you have a collection_select from which you, using DOM, add its values to an UL or some HTML structure, upon reload of the page the collection_select will repopulate with all the values from the DB, including the ones you''ve selected previously. is there a quick/easy way to tell activerecord to select all values not in a given set? something like find(:all, EXCEPT_STUFF_WITH_THESE_CERTAIN_IDS) -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
maybe something like: models = find( :all, :conditions => ''id_field_from_table NOT IN ('' + banned_id_array.join( '', '' ) + '')'' ) Binh Ly wrote:> hello all, > > if you have a collection_select from which you, using DOM, add its > values to an UL or some HTML structure, upon reload of the page the > collection_select will repopulate with all the values from the DB, > including the ones you''ve selected previously. is there a quick/easy > way to tell activerecord to select all values not in a given set? > > something like > > find(:all, EXCEPT_STUFF_WITH_THESE_CERTAIN_IDS)-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Binh Ly wrote:> hello all, > > if you have a collection_select from which you, using DOM, add its > values to an UL or some HTML structure, upon reload of the page the > collection_select will repopulate with all the values from the DB, > including the ones you''ve selected previously. is there a quick/easy > way to tell activerecord to select all values not in a given set? > > something like > > find(:all, EXCEPT_STUFF_WITH_THESE_CERTAIN_IDS) >You can use ActiveRecord::Extensions[*] and do the following... find( :all, :conditions=>{ :id_not_in => array_of_ids } ) Zach [1] http://rubyforge.org/projects/arext [2] http://www.continuousthinking.com/are -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFgLGpMyx0fW1d8G0RAswBAJ93Kg/ri3RYanpnlQnNo+8UGuGzLACfcZNi LSLgb+KEIhsr84KLHlA44mo=XwZb -----END PGP SIGNATURE----- --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---