Forum: Ruby on Rails How to handle no category on select element?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Affab6de94b467912e3230395e8175b6?d=identicon&s=25 Marko Žabčić (evensoul)
on 2007-05-08 23:48
I have situation like this:

<p><label for="task_category_id">Assign:</label>
 <select name="category[category_id]" id="category_category_id">
 <option value="0">Choose</option>
 <option value="1">category 1</option>
 <option value="2">category 2</option>
</select>
</p>

So when I choose option 'Choose' with value 0 and I don't have a
category with that id i get error....

Making a new category in table with title = 'No category' doesn't feel
right


How can I handle that kind of problem?
This topic is locked and can not be replied to.