2014-02-17 18:05:39 +01:00
|
|
|
# == Schema Information
|
|
|
|
#
|
|
|
|
# Table name: api_keys
|
|
|
|
#
|
|
|
|
# id :integer not null, primary key
|
|
|
|
# api_key :string(16)
|
|
|
|
# channel_id :integer
|
|
|
|
# user_id :integer
|
|
|
|
# write_flag :boolean default(FALSE)
|
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
|
|
|
# note :string(255)
|
|
|
|
#
|
|
|
|
|
2011-03-27 22:56:15 +02:00
|
|
|
class ApiKey < ActiveRecord::Base
|
2012-02-10 00:42:16 +01:00
|
|
|
belongs_to :channel
|
|
|
|
belongs_to :user
|
2011-03-27 22:56:15 +02:00
|
|
|
|
2012-02-10 00:42:16 +01:00
|
|
|
validates_uniqueness_of :api_key
|
|
|
|
|
2014-02-17 18:05:39 +01:00
|
|
|
scope :write_keys, lambda { where("write_flag = true") }
|
|
|
|
scope :read_keys, lambda { where("write_flag = false") }
|
2012-02-10 00:42:16 +01:00
|
|
|
|
|
|
|
attr_readonly :created_at
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
api_key
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_param
|
|
|
|
api_key
|
|
|
|
end
|
2011-03-27 22:56:15 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|