ruby on rails - select_tag multiple and partials -


i'm having problem pesky select_tags, can them show data fine on new when comes edit, don't show up, here code have @ moment. think need use include? don't know put it.

this have @ moment new

<% @data = code.find(:all, :conditions => "section = 'location'") %> <%= select_tag "candidate[code_ids][]", options_for_select(@data.map{|d| ["#{d.value}",d.id]}), :multiple => true %>  

and edit

<% @data = code.find(:all, :conditions => "section = 'location'") %> <%= select_tag "candidate[code_ids][]", options_for_select(@data.map{|d| ["#{d.value}",d.id]},@found), :multiple => true %>          

in controller have grabs of codes related candidate.

@results = candidate.all :joins =>      "left join candidates_codes on candidates.id = candidates_codes.candidate_id",     :conditions => ["candidates.id = ?", params[:id]],     :select => "candidates_codes.code_id" #create array of candidates selected codes @found = [] c in @results  @found.push(c.code_id.to_i) end 

how can make have 1 select rather having 1 new , 1 edit?

long after asked... how have been able make form multi-select drop-down reload each time. admittedly, using params , not data...

<%= type_list = eventconstants::eventtype::to_array      select_tag(:event_types, options_for_select(type_list, params[:event_types]),                 :multiple => true, :size => 5) %> 

since using mongo_mapper, can chain plucky queries so:

qry_where = qry_where.where(:event_type.in => params[:event_types]) if params[:event_types] && !params[:event_types].include?("all") 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -