Reputation: 318
I have a radio button in my Rails application:
.<% @votes.each do |vote| %>
.<%= radio_button_tag "escolha", "#{vote.id}" %>
.<% end %>
I want to make a java-script code that validates this when no option is chosen.
Upvotes: 2
Views: 1350
Reputation: 8710
In your votes class do something similar to this:
class Myvotes < ActiveRecord::Base
validates :votes, :presence => true
end
Please refer to the 8.2 Validations section of the Rails release notes, this tutorial, and the Rails API documentation.
Upvotes: 4