Activerecord question

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)

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)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Binh Ly wrote:

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