fix has_many relationships in map & mapping models for rails 4
This commit is contained in:
parent
d67d098b2a
commit
a8cef723a2
2 changed files with 5 additions and 5 deletions
|
@ -2,11 +2,8 @@ class Map < ActiveRecord::Base
|
|||
|
||||
belongs_to :user
|
||||
|
||||
has_many :topicmappings, :class_name => 'Mapping', :conditions => {:category => 'Topic'}
|
||||
has_many :synapsemappings, :class_name => 'Mapping', :conditions => {:category => 'Synapse'}
|
||||
|
||||
has_many :topics, :through => :topicmappings
|
||||
has_many :synapses, :through => :synapsemappings
|
||||
has_many :topics, -> { Mapping.topicmapping }, :through => :topicmappings
|
||||
has_many :synapses, -> { Mapping.synapsemapping }, :through => :synapsemappings
|
||||
|
||||
# This method associates the attribute ":image" with a file attachment
|
||||
has_attached_file :screenshot, :styles => {
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
class Mapping < ActiveRecord::Base
|
||||
|
||||
scope :topicmapping, -> { where (category: :Topic) }
|
||||
scope :synapsemapping, -> { where (category: :Synapse) }
|
||||
|
||||
belongs_to :topic, :class_name => "Topic", :foreign_key => "topic_id"
|
||||
belongs_to :synapse, :class_name => "Synapse", :foreign_key => "synapse_id"
|
||||
belongs_to :map, :class_name => "Map", :foreign_key => "map_id"
|
||||
|
|
Loading…
Reference in a new issue