i want to add the “available time” when the user establish a vote . how to implement?
For example i set up a vote ,and it is available to vote by 2012.1.1.In addition ,the vote’s “available time” range from one day to one year.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
add a date column like “expires_at” and then you run a custom validation like:
Solution A*
if you have one single table called
votings:expires_atis a Date columnNow your model looks like (voting.rb):
Now in your controller:
Solution B
If you have a 2-Table approach like:
Table Votings:
Table Votes:
You need two models:
voting.rb
votes.rb
Your Controller:
Creating a new Voting: