photomix/app/models/tag.rb

19 lines
426 B
Ruby
Raw Normal View History

2009-05-22 22:38:52 +02:00
class Tag < ActiveRecord::Base
has_many :photo_tags
has_many :photos, :through => :photo_tags
2009-05-25 21:39:43 +02:00
validates_uniqueness_of :title
2009-06-02 00:08:57 +02:00
def self.tag_list
return self.find(:all).map { |tag| tag.title }.join('\',\'')
end
2009-05-25 21:39:43 +02:00
def to_param
#{ }"#{id}-#{name.gsub(/[^a-z0-9]+/i, '-')}"
#id.to_s+'-'+name.downcase.gsub(/[^a-z0-9]+/i, '-')
#id.to_s+'-'+name.downcase.gsub(' ', '-')
self.title
end
2009-05-22 22:38:52 +02:00
end