select helper and issues with :selected

I have this code:

<%= select 'stuff', 'id', Stuff.find_by_sql( "SELECT stuffs.value, stuffs.id from stuffs WHERE account_id = " + @account.id.to_s + " ORDER BY stuffs.value ASC" ).collect{ |a| [a.value, a.id] }, {:include_blank => true, :selected => @user.stuff_profile.to_s } %>

I'm not sure what stuff_profile is, but the fact that you're converting it, whatever it is, to a string means that it's guaranteed not to be equal to any of those ids.

Fred

Frederick Cheung wrote:

I'm not sure what stuff_profile is, but the fact that you're converting it, whatever it is, to a string means that it's guaranteed not to be equal to any of those ids.

Fred

I added that as a last ditch effort to try and make it work but with no luck. even without it it still doesn't work.

Frederick Cheung wrote:

I'm not sure what stuff_profile is, but the fact that you're converting it, whatever it is, to a string means that it's guaranteed not to be equal to any of those ids.

Fred

I added that as a last ditch effort to try and make it work but with
no luck. even without it it still doesn't work.

what is stuff_profile ? what ever you pass to :selected should be an
integer that will be == to the id of one of the instances of Stuff you
are returning

Fred

I changed the find and still nada. Here is what I got now:

<%= select( 'stuff', 'id', Stuff.find( :all, :conditions => ['account_id = ?', @account.id.to_s], :order => 'value ASC').collect{ |a| [a.value, a.id] }, { :include_blank => true, :selected => @user.stuff_profile }) %>

@user.stuff_profile is an id

Is it definitely an integer ? (ie "1" is != 1)

Fred and when I look at the html there is an