[Rails] Multiple Select example?

brez! !! jbresnik at gmail.com
Wed Apr 26 18:23:26 GMT 2006


I've been trying to sort out a multiple select dropdown but haven't
found any good examples - anyone know of any or perhaps could make a
suggestion [see below]

Model:
1. Task AR has_many users
2. User AR belongs_to task
   login/password attributes

Controller:


View:
<%= collection_select("task", "users" , @users, "id", "login", {},
{:multiple => true}) %>

 def new
   @task = Task.new
   @users = User.find_all
 end

 def create
   @task = Task.new(params[:task])

   if @task.save
     flash[:notice] = 'Task was successfully created.'
     redirect_to :action => 'list'
   else
     render :action => 'new'
   end
 end

Error:

"User expected, got String"


Seems pretty straight forward but isn't working - any sugggestions?

Thanks.

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


More information about the Rails mailing list