Permalink
Browse files

associate articles with collection

  • Loading branch information...
1 parent f3ad79b commit 719ce81af799f03745d098f0c30245d30e754c6a Jia Brown committed Apr 7, 2012
View
@@ -1,6 +1,7 @@
class Article < ActiveRecord::Base
has_many :comments, :as => :commentable
belongs_to :volume
+ belongs_to :collection
validates_presence_of :issue_number
View
@@ -1,2 +1,3 @@
class Collection < ActiveRecord::Base
+ has_many :articles
end
@@ -10,6 +10,9 @@
%p
= f.label :volume_id
= f.collection_select :volume_id, Volume.order("number desc"), :id, :number
+%p
+ = f.label :collection_id
+ = f.collection_select :collection_id, Collection.all, :id, :name
%p
= f.label :issue_number
%br
@@ -0,0 +1,7 @@
+class AddCollectionIdToArticles < ActiveRecord::Migration
+ def change
+ change_table :articles do |t|
+ t.belongs_to :collection
+ end
+ end
+end
View
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120407204814) do
+ActiveRecord::Schema.define(:version => 20120407205455) do
create_table "announcements", :force => true do |t|
t.text "title"
@@ -41,6 +41,7 @@
t.datetime "updated_at"
t.text "issue_number"
t.integer "volume_id"
+ t.integer "collection_id"
end
create_table "authorization_links", :force => true do |t|

0 comments on commit 719ce81

Please sign in to comment.