From d142c516be567093a819455c8018b1e87e57ccc9 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Mon, 26 Sep 2011 03:14:59 +0400 Subject: [PATCH] Structuring models directory --- app/models/{ => beathaven}/favorite.rb | 0 app/models/{ => beathaven}/playlist.rb | 0 app/models/{ => beathaven}/playlist_item.rb | 0 app/models/{ => beathaven}/session.rb | 0 app/models/{ => beathaven}/user.rb | 0 app/models/local_brainz/cached_release.rb | 4 ++++ app/models/local_brainz/cached_track.rb | 3 +++ app/models/{ => local_brainz}/local_brainz.rb | 0 app/models/local_brainz/release.rb | 4 ---- app/models/local_brainz/track.rb | 3 --- app/models/{ => music}/album.rb | 0 app/models/{ => music}/album_format.rb | 0 app/models/{ => music}/album_genre.rb | 0 app/models/{ => music}/album_style.rb | 0 app/models/{ => music}/artist.rb | 0 app/models/{ => music}/artist_alias.rb | 0 app/models/{ => music}/artist_link.rb | 0 app/models/{ => music}/genre.rb | 0 app/models/{ => music}/release_format.rb | 0 app/models/{ => music}/style.rb | 0 app/models/{ => music}/track.rb | 0 app/models/{ => music}/track_artist.rb | 0 config/application.rb | 2 +- .../20110925231256_rename_local_brainz_tables.rb | 10 ++++++++++ 24 files changed, 18 insertions(+), 8 deletions(-) rename app/models/{ => beathaven}/favorite.rb (100%) rename app/models/{ => beathaven}/playlist.rb (100%) rename app/models/{ => beathaven}/playlist_item.rb (100%) rename app/models/{ => beathaven}/session.rb (100%) rename app/models/{ => beathaven}/user.rb (100%) create mode 100644 app/models/local_brainz/cached_release.rb create mode 100644 app/models/local_brainz/cached_track.rb rename app/models/{ => local_brainz}/local_brainz.rb (100%) delete mode 100644 app/models/local_brainz/release.rb delete mode 100644 app/models/local_brainz/track.rb rename app/models/{ => music}/album.rb (100%) rename app/models/{ => music}/album_format.rb (100%) rename app/models/{ => music}/album_genre.rb (100%) rename app/models/{ => music}/album_style.rb (100%) rename app/models/{ => music}/artist.rb (100%) rename app/models/{ => music}/artist_alias.rb (100%) rename app/models/{ => music}/artist_link.rb (100%) rename app/models/{ => music}/genre.rb (100%) rename app/models/{ => music}/release_format.rb (100%) rename app/models/{ => music}/style.rb (100%) rename app/models/{ => music}/track.rb (100%) rename app/models/{ => music}/track_artist.rb (100%) create mode 100644 db/migrate/20110925231256_rename_local_brainz_tables.rb diff --git a/app/models/favorite.rb b/app/models/beathaven/favorite.rb similarity index 100% rename from app/models/favorite.rb rename to app/models/beathaven/favorite.rb diff --git a/app/models/playlist.rb b/app/models/beathaven/playlist.rb similarity index 100% rename from app/models/playlist.rb rename to app/models/beathaven/playlist.rb diff --git a/app/models/playlist_item.rb b/app/models/beathaven/playlist_item.rb similarity index 100% rename from app/models/playlist_item.rb rename to app/models/beathaven/playlist_item.rb diff --git a/app/models/session.rb b/app/models/beathaven/session.rb similarity index 100% rename from app/models/session.rb rename to app/models/beathaven/session.rb diff --git a/app/models/user.rb b/app/models/beathaven/user.rb similarity index 100% rename from app/models/user.rb rename to app/models/beathaven/user.rb diff --git a/app/models/local_brainz/cached_release.rb b/app/models/local_brainz/cached_release.rb new file mode 100644 index 0000000..0103a9a --- /dev/null +++ b/app/models/local_brainz/cached_release.rb @@ -0,0 +1,4 @@ +class LocalBrainz::CachedRelease < ActiveRecord::Base + belongs_to :album, :class_name => 'Album' + has_many :local_brainz_cached_tracks, :class_name => 'LocalBrainz::CachedTrack', :dependent => :destroy +end diff --git a/app/models/local_brainz/cached_track.rb b/app/models/local_brainz/cached_track.rb new file mode 100644 index 0000000..61da40d --- /dev/null +++ b/app/models/local_brainz/cached_track.rb @@ -0,0 +1,3 @@ +class LocalBrainz::CachedTrack < ActiveRecord::Base + belongs_to :local_brainz_cached_release, :class_name => 'LocalBrainz::CachedRelease' +end diff --git a/app/models/local_brainz.rb b/app/models/local_brainz/local_brainz.rb similarity index 100% rename from app/models/local_brainz.rb rename to app/models/local_brainz/local_brainz.rb diff --git a/app/models/local_brainz/release.rb b/app/models/local_brainz/release.rb deleted file mode 100644 index b7aa0be..0000000 --- a/app/models/local_brainz/release.rb +++ /dev/null @@ -1,4 +0,0 @@ -class LocalBrainz::Release < ActiveRecord::Base - belongs_to :album, :class_name => 'Album' - has_many :local_brainz_tracks, :class_name => 'LocalBrainz::Track', :dependent => :destroy -end diff --git a/app/models/local_brainz/track.rb b/app/models/local_brainz/track.rb deleted file mode 100644 index b835673..0000000 --- a/app/models/local_brainz/track.rb +++ /dev/null @@ -1,3 +0,0 @@ -class LocalBrainz::Track < ActiveRecord::Base - belongs_to :local_brainz_release, :class_name => 'LocalBrainz::Release' -end diff --git a/app/models/album.rb b/app/models/music/album.rb similarity index 100% rename from app/models/album.rb rename to app/models/music/album.rb diff --git a/app/models/album_format.rb b/app/models/music/album_format.rb similarity index 100% rename from app/models/album_format.rb rename to app/models/music/album_format.rb diff --git a/app/models/album_genre.rb b/app/models/music/album_genre.rb similarity index 100% rename from app/models/album_genre.rb rename to app/models/music/album_genre.rb diff --git a/app/models/album_style.rb b/app/models/music/album_style.rb similarity index 100% rename from app/models/album_style.rb rename to app/models/music/album_style.rb diff --git a/app/models/artist.rb b/app/models/music/artist.rb similarity index 100% rename from app/models/artist.rb rename to app/models/music/artist.rb diff --git a/app/models/artist_alias.rb b/app/models/music/artist_alias.rb similarity index 100% rename from app/models/artist_alias.rb rename to app/models/music/artist_alias.rb diff --git a/app/models/artist_link.rb b/app/models/music/artist_link.rb similarity index 100% rename from app/models/artist_link.rb rename to app/models/music/artist_link.rb diff --git a/app/models/genre.rb b/app/models/music/genre.rb similarity index 100% rename from app/models/genre.rb rename to app/models/music/genre.rb diff --git a/app/models/release_format.rb b/app/models/music/release_format.rb similarity index 100% rename from app/models/release_format.rb rename to app/models/music/release_format.rb diff --git a/app/models/style.rb b/app/models/music/style.rb similarity index 100% rename from app/models/style.rb rename to app/models/music/style.rb diff --git a/app/models/track.rb b/app/models/music/track.rb similarity index 100% rename from app/models/track.rb rename to app/models/music/track.rb diff --git a/app/models/track_artist.rb b/app/models/music/track_artist.rb similarity index 100% rename from app/models/track_artist.rb rename to app/models/music/track_artist.rb diff --git a/config/application.rb b/config/application.rb index f8948f9..ed2c684 100644 --- a/config/application.rb +++ b/config/application.rb @@ -16,7 +16,7 @@ module Beathaven # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. - # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths += Dir[Rails.root.join('app', 'models', '{**}')] # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. diff --git a/db/migrate/20110925231256_rename_local_brainz_tables.rb b/db/migrate/20110925231256_rename_local_brainz_tables.rb new file mode 100644 index 0000000..905bbfb --- /dev/null +++ b/db/migrate/20110925231256_rename_local_brainz_tables.rb @@ -0,0 +1,10 @@ +class RenameLocalBrainzTables < ActiveRecord::Migration + def self.up + rename_table :local_brainz_tracks, :local_brainz_cached_tracks + rename_table :local_brainz_releases, :local_brainz_cached_releases + end + def self.down + rename_table :local_brainz_cached_tracks, :local_brainz_tracks + rename_table :local_brainz_cached_releases, :local_brainz_releases + end +end