I am very new to Ruby on Rails and I’m trying to access the scores from a specific Organization. I was wondering if someone could point me in the right direct of being able to accomplish this. I currently have the following Models:
Here is the User Model
class User < ActiveRecord::Base
attr_accessible :fname, :lname, :email, :password, :password_confirmation
has_secure_password
belongs_to :organization
Here is the Organization Model
class Organization < ActiveRecord::Base
attr_accessible :name, :employee_number, :country, :postal_code, :sic_code, :primary_url
has_many :users
has_many :social_entities
has_many :social_scores, :through => :social_entity
has_many :social_channels, :through => :social_entity
Here is the Entity Model
class SocialEntity < ActiveRecord::Base
attr_accessible :name, :org_id
has_many :social_channels
has_many :social_scores
belongs_to :organization
Here is the Channel Model
class SocialChannel < ActiveRecord::Base
attr_accessible :authorized, :channel_identifier, :channel_type, :name, :social_entity_id
belongs_to :social_entity # edited from original post, :socialentity
Here is the Score Model
class SocialScore < ActiveRecord::Base
attr_accessible :engagement_score, :popularity_score, :presence_score, :reputation_score, :score_period_end, :score_period_start, :score_period_type, :score_timestamp, :social_entity
belongs_to :social_entity
Here is a description of what I am trying to do. A User logs into the system, the user is tied to a organization, each organization has a social entity which has social channels and scores. I want to be able to display the scores for the organization in the view.
If you have an instance of Organization, the
has_manydeclaration creates an attribute (a method, really) that gets a collection of SocialScores, referenced bysocial_scores, e.g.Is that what you were seeking?