Sha256: ff1cd400e27e4da04ca3aa913d7334175947827f15b5369c6bbaa8029a55b0d9

Contents?: true

Size: 530 Bytes

Versions: 1

Compression:

Stored size: 530 Bytes

Contents

class Music::Artist < ActiveRecord::Base  
  set_table_name 'music_artists'
  
  validates :name, :presence => true
  validates_uniqueness_of :name, :case_sensitive => false
  
  attr_accessible :name, :tag_list, :author_id
  
  # TODO: Move to Import::NoRelation
  def self.find_existing_entries(criteria, values)
    class_eval <<-EOV
find_by_sql(
  [
    "SELECT music_artists.id AS id, music_artists.name AS name FROM music_artists WHERE #{criteria}",
    "#{values.join('", "')}"
  ]
).map{|a| [a.id, a.name]}
EOV
  end  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
import-0.0.2 spec/dummy/app/models/music/artist.rb