Skip to content
Snippets Groups Projects
Commit 3d5ce50e authored by Matheus Agio Nerone's avatar Matheus Agio Nerone
Browse files

creating associations


Signed-off-by: default avatarman13 <man13@inf.ufpr.br>
parent 682a836a
No related branches found
No related tags found
No related merge requests found
class MimeType < ActiveRecord::Base class MimeType < ActiveRecord::Base
has_and_belongs_to_many :object_types
end end
class ObjectType < ActiveRecord::Base class ObjectType < ActiveRecord::Base
has_many :learning_objects has_many :learning_objects
has_and_belongs_to_many :mime_types
validates :name, presence: true validates :name, presence: true
end end
class RemoveMimeTypesFromObjectTypes < ActiveRecord::Migration
def change
remove_column :object_types, :mime_type, :string
end
end
class AddAssociationsToObjectTypesAndMimeTypes < ActiveRecord::Migration
def change
create_table :mime_types_object_types do |t|
t.belongs_to :object_type, index: true
t.belongs_to :mime_type, index: true
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment