2014-03-26 11:09:39 +00:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: options
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# option :string(255)
|
2020-03-31 17:27:34 +00:00
|
|
|
# votes :integer default(0), not null
|
2014-03-26 11:09:39 +00:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2020-03-18 03:38:17 +00:00
|
|
|
# poll_id :integer
|
|
|
|
#
|
|
|
|
# Indexes
|
|
|
|
#
|
|
|
|
# index_options_on_poll_id (poll_id)
|
2014-03-26 11:09:39 +00:00
|
|
|
#
|
|
|
|
|
2014-03-23 00:22:25 +00:00
|
|
|
class Option < ActiveRecord::Base
|
|
|
|
include Extra
|
|
|
|
|
2020-03-16 23:57:47 +00:00
|
|
|
#attr_protected :id, :updated_at, :created_at, :votes
|
2014-03-23 00:22:25 +00:00
|
|
|
|
|
|
|
validates_length_of :option, :in => 1..30
|
|
|
|
|
|
|
|
has_many :real_votes, :class_name => "Vote", :as => :votable
|
2020-03-26 02:26:30 +00:00
|
|
|
belongs_to :poll, :optional => true
|
2014-03-23 00:22:25 +00:00
|
|
|
|
|
|
|
def to_s
|
|
|
|
self.option
|
|
|
|
end
|
2020-03-18 03:38:17 +00:00
|
|
|
|
|
|
|
def self.params(params, cuser)
|
|
|
|
# FIXME: check this
|
|
|
|
params.require(:option).permit(:option, :votes, :poll_id)
|
|
|
|
end
|
2014-03-23 00:22:25 +00:00
|
|
|
end
|