Monday 15 February 2010

Rails form select with NULL (no choice) support -


How do I add a tap option to select my form? I have a table:

  categories id category_id name   

If I am creating a new category, then I NO_CATEGORY Option (zero value and id).

My view code:

  & lt;% = f.collection_select: supercategory_id, category all,: id,: name% & gt;   

Besides, is this a good idea? Is not it better for some predefined root category in the database? Thank you.

Try:

    

It's okay to be zero. Just know its model logic that it should create a new category and choose it instead of assigning it to the mass rather than assign it. There may be something that happens in the pre_translation method

No comments:

Post a Comment