Posted By

smoothdzion on 11/24/09


Tagged

select html rails ruby ror


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

smoothdzion
octoberborn


RoR - Select Box Using Existing Model


 / Published in: Rails
 

The code to find all objects from a model and use them as select options.

  1. # Replace |model| with whatever you want to use. ie. |whatever|
  2. <%= select(:object, :name, Model.all.collect {|model| [model.name, model.id]}) %>

Report this snippet  

You need to login to post a comment.