Default values for model fields in a Ruby on Rails form
- by Callum Rogers
I have a Model which has fields username, data, tags, date, votes. I have form using form_for that creates a new item and puts it into the database. However, as you can guess I want the votes field to equal 0 and the date field to equal the current date when it is placed into the database. How and where would I set/apply these values to the item?
I can get it to work with hidden fields in the form but this comes with obvious issues (someone could set the votes field to a massive number.