Hello all,
I have a need in my app to allow users to bookmark a post. They should only be able to create one bookmark per post. I've set up my polymorphic association like so:
class Post < ActiveRecord::Base
has_many :bookmarks, :as => :bookmarkable
end
class Bookmark < ActiveRecord::Base
belongs_to :bookmarkable, :polymorphic =...
I have a metric table that I expect to be very large. It has a polymorphic association so that it can belongs_to other models that want to record some metric. I typically index association columns like this to speed up association loading. I've heard people talking about joint-indexing this association. This looks like:
add_index :c...
Below I have outlined the structure of a polymorphic association.
In VacationsController I put some comments inline describing my current issue. However, I wanted to post this to see if my whole approach here is a little off. You can see in business_vacations_controller and staff_vacations_controller that I've had to make 'getters' for ...
I have a simple polymorphic association
#comment.rb
belongs_to :commentable, :polymorphic => true
has_many :comments, :as => :commentable
#post.rb
has_many :comments, :as => :commentable
accepts_nested_attributes_for :comments, :allow_destroy => true
So in IRB I can do, Post.comments, or Commen...
I have posts that can be voted on by a polymorphic association. Now I am making comments votable as well. Can I share the same models and logic for this for my comments? Or do I have to make a new model relationship ?
#post.rb
has_many :votes, :as => :votable
has_many :...