Rails models

This commit is contained in:
magnolia-fan
2011-04-03 22:32:27 +04:00
parent ca9ef65439
commit 1ba26ffd9c
8 changed files with 571 additions and 14 deletions
+6 -1
View File
@@ -1,5 +1,10 @@
class ArtistController < ApplicationController
def view
@artist = Artists.getByName(params[:name])
@artist = Artist.getByName(params[:name])
@albums = ReleaseGroup.getArtistAlbums(@artist.id)
ids = []
@albums.each do |a|
ids << a.id
end
end
end
+6
View File
@@ -0,0 +1,6 @@
class Artist < ActiveRecord::Base
set_table_name 'musicbrainz.bh_artist'
def self.getByName(name)
Artist.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
end
end
-6
View File
@@ -1,6 +0,0 @@
class Artists < ActiveRecord::Base
set_table_name 'musicbrainz.bh_artist'
def self.getByName(name)
Artists.first(:conditions => ['name = ? AND id=credit_id', name], :order => 'rating DESC')
end
end
View File
+6
View File
@@ -0,0 +1,6 @@
class ReleaseGroup < ActiveRecord::Base
set_table_name 'musicbrainz.bh_release_group'
def self.getArtistAlbums(artist_id)
ReleaseGroup.all(:conditions => ['artist_id = ? AND release_type=1', artist_id], :order => 'year ASC, id ASC')
end
end
-6
View File
@@ -1,6 +0,0 @@
class ReleaseGroups < ActiveRecord::Base
set_table_name 'musicbrainz.bh_release_group'
def self.getArtistAlbums(artist_id)
ReleaseGroups.all(:conditions => ['artist_id = ? AND type=1', artist_id], :order => 'year ASC, id ASC')
end
end