diff --git a/Gemfile b/Gemfile index 2c27471..dfb0386 100644 --- a/Gemfile +++ b/Gemfile @@ -3,11 +3,6 @@ source 'http://rubygems.org' gem 'rails', '3.0.9' gem 'json' -gem 'sass' -gem 'coffee-script' - -gem 'therubyracer', :require => false -gem 'barista' gem 'awesome_print', :require => 'ap' gem 'delayed_job' @@ -16,6 +11,12 @@ gem 'musicbrainz-ruby', :git => 'git://github.com/magnolia-fan/musicbrainz-ruby. group :development do gem 'sqlite3' + + gem 'sass' + gem 'coffee-script' + + gem 'therubyracer', :require => false + gem 'barista' end group :production do diff --git a/app/controllers/import_controller.rb b/app/controllers/import_controller.rb index 785c121..11783e5 100644 --- a/app/controllers/import_controller.rb +++ b/app/controllers/import_controller.rb @@ -121,6 +121,7 @@ class ImportController < ApplicationController album.mbid = mb_album['id'] album.album_type = mb_album['type'] album.pic_url = album_image + album.has_pic = (album_image != '' and not album_image.nil?) album.save unless dry_run ap album if dry_run diff --git a/app/models/artist.rb b/app/models/artist.rb index 59ffbc9..8211a70 100644 --- a/app/models/artist.rb +++ b/app/models/artist.rb @@ -1,3 +1,3 @@ class Artist < ActiveRecord::Base - has_many :albums, :order => '(pic_url!="" AND pic_url IS NOT NULL) DESC, year ASC, id ASC', :dependent => :destroy + has_many :albums, :order => 'has_pic DESC, year ASC, id ASC', :dependent => :destroy end diff --git a/db/migrate/20110630052149_add_has_pic_to_album.rb b/db/migrate/20110630052149_add_has_pic_to_album.rb new file mode 100644 index 0000000..43db61b --- /dev/null +++ b/db/migrate/20110630052149_add_has_pic_to_album.rb @@ -0,0 +1,9 @@ +class AddHasPicToAlbum < ActiveRecord::Migration + def self.up + add_column :albums, :has_pic, :integer + end + + def self.down + remove_column :albums, :has_pic + end +end diff --git a/db/schema.rb b/db/schema.rb index d51a67c..3331fb8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20110630035132) do +ActiveRecord::Schema.define(:version => 20110630052149) do create_table "albums", :force => true do |t| t.string "name" @@ -21,6 +21,7 @@ ActiveRecord::Schema.define(:version => 20110630035132) do t.datetime "updated_at" t.string "album_type" t.string "mbid" + t.integer "has_pic" end create_table "artists", :force => true do |t|