mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
35 lines
729 B
Ruby
35 lines
729 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: options
|
|
#
|
|
# id :integer not null, primary key
|
|
# option :string(255)
|
|
# votes :integer default(0), not null
|
|
# created_at :datetime
|
|
# updated_at :datetime
|
|
# poll_id :integer
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_options_on_poll_id (poll_id)
|
|
#
|
|
|
|
class Option < ActiveRecord::Base
|
|
include Extra
|
|
|
|
#attr_protected :id, :updated_at, :created_at, :votes
|
|
|
|
validates_length_of :option, :in => 1..30
|
|
|
|
has_many :real_votes, :class_name => "Vote", :as => :votable
|
|
belongs_to :poll, :optional => true
|
|
|
|
def to_s
|
|
self.option
|
|
end
|
|
|
|
def self.params(params, cuser)
|
|
# FIXME: check this
|
|
params.require(:option).permit(:option, :votes, :poll_id)
|
|
end
|
|
end
|