I'm pretty new to Rails, and i'm trying to do a polymorphic HABTM relationship. The problem is that I have three models that I want to relate.
The first one is the Event model and then are two kind of attendees: Users and Contacts.
What I want to do…
I got some Manager and SoccerTeam model. A manager "owns" many soccer teams; also a manager can comment on soccer teams and can comment on other managers too:
manager.rb
# Soccer teams the manager owns
has_many :soccer_teams, :dependent =>…
I have the following models. Users have UserActions, and one possible UserAction can be a ContactAction (UserAction is a polymorphism). There are other actions like LoginAction etc. So
class User < AR::Base
has_many :contact_requests,…
This one's really getting me down! :(
I'm trying to make a nested model form for my User model with a checkbox list in it where multiple Stores can be checked or unchecked to administer the Stores through model Staffing.
class Staffing <…
After reading the Ruby on Rails guides and a few of the stackoverflow responses to questions about polymorphic association I understand its use and implementation but I have a question about a specific use scenario. I have tags that can be…
I'm using has_many_polymorphs to create a "Favorites" feature on a site where multiple users can post stories and make comments. I want users to be able to "favorite" stories and comments.
class User < ActiveRecord::Base
has_many :stories
has_many…
I'm trying to make a self-referential user class with three basic user types - parent, student, and tutor. A student belongs to a parent and can also belong to a tutor. Of course, the way I have it written, rails only recognizes the parent having…
I have a has_many_polymorphs relationship between a Candidate and many events of various type. In particular, a Candidate creates a Created event when it is created.
class Candidate < ActiveRecord::Base
has_many_polymorphs :events, :through =>…
I have the following model structure
class Asset < ActiveRecord::Base
attr_writer :session_user_id
...
end
class Item < ActiveRecord::Base
has_many :assets, :as => :assetable, :dependent => :destroy
...
end
and want to put the user_id in…
I have a model called Organization that has many teams and has many collaborations. A Collaboration also has many teams. So the team model has a polymorphic association with Organization and Collaboration.
What I would like to do is…
I have the models "Payment", "Estimate" and "Quote", a payment has a polymorphic relationship where it can belong either to a quote or to an estimate, simultaneously a quote can have many estimates, so an estimate is always going to belong to a…
I don't know if this is possible, but here goes:
FruitBasket
has_many :apples
has_many :bananas
######## What to put here to access Worm through its pest_holder relationship?
Apple
has_many :worms, :as => :pest_holder
belongs_to…
i moved from php to rails3, and i still think it was a good decision! Anyway I have some models:
users
questions
answers
question_id
votes
user_id
answer_id
model for users:
has_many :questions
has_many :votes
model for questions:
belongs_to…
I have a problem joining two models in a n..n association.
I have the following associations in the context:
Proposal n..n Product
Proposal n..n Project
Proposal n..n NewProject
And similarly with this, I have:
Order n..n Product
Order n..n…