My project has a select box where one can choose each user's project, but user.project_id is set according to be project's hash_id, not its actual id. So, the browser only knows the user and the project's hash_id.
Here's the code I'm using (project is already defined):
The above code doesn't work - it ignores the value and sets everything to the first option, regardless of what the DB value is. I'd like it so it shows the correct value.
My project has a select box where one can choose each user's project, but
user.project_id
is set according to be project'shash_id
, not its actualid
. So, the browser only knows the user and the project's hash_id.Here's the code I'm using (
project
is already defined):<%= best_in_place user, :project_id, as: :select, collection: @projects.collect{|d| [d.id, d.name]}, value: project.hash_id %>
The above code doesn't work - it ignores the value and sets everything to the first option, regardless of what the DB value is. I'd like it so it shows the correct value.