similar to: "Owning" a polymorphic

Displaying 20 results from an estimated 5000 matches similar to: ""Owning" a polymorphic"

2008 Oct 29
5
Polymorphic Associations with inheritance
I have two models, Article and Post, that has many Comments. However, both Article and Post are inherited from a BaseContent class like so: class Article < BaseContent has_many :comments, :as => :commentable end class Post < BaseContent has_many :comments, :as => :commentable end and here''s my Comment model: class Comment < ActiveRecord::Base belongs_to
2006 May 15
33
acts_as_commentable release
I now have the acts_as_commentable plugin up on RubyForge. This plugin will allow you to add comments to any active_record object in your Rails application. So far the directions are simple, and there are only a few features: To install: ruby script/plugin install svn://rubyforge.org//var/svn/commentable/acts_as_commentable In the readme there is a sample migration you will need to use, with
2013 Feb 28
2
Create polymorphic resources
Hi I have created a polymorphic association for comments since I need commenting functionality on several models. The issue is that when I create the comment in my Commets#create action, I really don''t know what type the parent is of. So, let''s say I have Foo, Bar and Comment. Comment have this: belongs_to :commentable, polymorphic: true And Foo and Bar both have:
2006 Jun 20
2
Converting from acts_as_tree to acts_as_nested_set
I''m currently using acts_as_tree to display threaded Comments on my forums-like site. It''s waaay too slow to display a page with 1,000 comments, as it''s issuing a TON of selects. I''m pretty sure I want to convert to the nested set model, using acts_as_nested_set or acts_as_threaded. This should give me the performance I''m looking for. The problem,
2009 Jan 02
5
Very odd NoMethodError/stack overflow....
I''m getting this very weird error and I can''t figure out what the problem is. I''m using acts_as_commentable. Basically, I have a partial with this code in it: <div id="<%= ''#{comment.commentable_type}_comment_# {comment.commentable_id}'' %>" class="comment"> <dl> <dt><%= link_to comment.user.login,
2009 Jul 20
0
Polymorphic Comment notification to Users?
Hi, my webapp has registered users and it has articles, blog posts, gossips too. For all these resources I''ve a polymorphic Comment model which is listed below. <pre> id content commentable_id commentable_type user_id created_at updated_at 1 Frist comment 2 Article 1 .... 2 Second comment 3 Post 2 .....
2009 Mar 11
12
Eager loading comments associated with user submissions.
Hey everyone, I am working on an application that allows users to submit articles, and also comment on those articles. Pretty much exactly like Digg. Everything works fine except that when there are a lot of comments there are a lot of database queries to both fetch the comments and the users who posted those comments. I have used eager loading in other parts of my application to reduce the
2009 Apr 20
3
xxx.valid? still true after xxx.errors.add(...)?
Hi all I have the following code in my controller: if @comment.valid? captcha_url = "http://captchator.com/captcha/check_answer/#{captcha_code}/#{@comment.captcha}" result = open(captcha_url) unless result.read == "1" @comment.errors.add(:captcha, "Captcha wurde nicht korrekt eingegeben") raise "#{@comment.valid?}"
2010 Sep 11
10
Having difficulty with threaded comments, using acts_as_tree
I''ve been having problems making threaded comments for the last few days. Mainly with creating children and displaying the children. Currently, I have comments shown at the bottom of my articles show view. The top level comments work, but I do not really know how to implement a way for users to "reply" to the top level comments and take them to a form (the comment
2009 Jul 22
2
How to build scope for count() & has many polymorphic?
Hello, i have the following models in my application: class Message < ActiveRecord::Base has_many :comments, :as => :commentable, :dependent => :destroy, :order => ''created_at ASC'' end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end I need "commented" named scope, which do the follownig thing:
2009 Apr 29
0
Polymorphic comments table needs associated model
Howdy, I''ve been banging my head on this problem for a bit. I''m using the acts_as_commentable plugin which works great. The scenario, I''m on the user''s dashboard and want to display comments with commentable_type = Venue. No problem. But, if I want to display the name of that Venue with the comment... big nasty. The polymorphic key is a composite key and
2006 May 14
2
object class with STI and Polymorphic Assoc''s.
Hi, lets say I have a a table, "Linkings" that I am using for polymorphic associations. One of the associations is to the "person" table, and there are several other associations. "Person" has 2 types, "slacker" and "suckup". It is modelled as such: class Linking < ActiveRecord::Base belongs_to :person belongs_to :linkable, :polymorphic
2006 Mar 24
7
Polymorphic associations?
I''ve read the stuff about polymorphic associations here: http://wiki.rubyonrails.org/rails/pages/UnderstandingPolymorphicAssociations But I''m not sure what exactly they are and what their advantage is. Are they the same as HABTM, but they''re "two-way"? Joe -- Posted via http://www.ruby-forum.com/.
2006 Jul 10
2
Polymorphic associations in reverse?
My app has an association that''s got me scratching my head. I have Users, and Images. A User has many Images. (Yes, another picture sharing app, but it''s for a small niche, and it doesn''t end in -r!) I would like to express a "Favorite" relationship between both Users to Users, and Users to Images. This seems like the opposite of the standard
2006 Mar 19
2
Multiple polymorphic belongs_to declarations
I have the following models: class Card < ActiveRecord::Base belongs_to :deck belongs_to :front, :polymorphic => true belongs_to :back, :polymorphic => true end class TextContent < ActiveRecord::Base has_one :card, :as => :front has_one :card, :as => :back end The conflicting has_one declarations don''t work. What I need is
2006 Feb 10
3
[Req] polymorphic associations howto
Hi people, I''m looking into polymorphic associations as a way to cleanup some messy parts of my code. I think they will allow me to do exectly what I need, but since there''s little to none written on this subject, I''d be delighted if someone could shed some light on this. Especially what the different options and needed table structures need to be. Thanks, -
2006 Jun 26
5
How can I dynamiclly generate models?
I am trying to write a plugin, ''acts_as_commentable'', for my models - Image, Book, Music and so on, I do not want to use polymorphic association, so very model should have its own comment class. Here is my code acts_as_commentable.rb module Commentable def self.included(base) base.extend(ClassMethods) end module ClassMethods def
2009 Nov 01
1
please help - complicated polymorphic association
I am trying to build a shared-appointment system, where users can subscribe to appointments and be updated whenever changes are made to them. I have three objects in this system, appointments, users, and subscribers. Subscribers are a polymorphic object like so: class Subscriber < ActiveRecord::Base belongs_to :user belongs_to :subscribable, :polymorphic => true end The tricky part is
2006 Aug 16
0
Creating a comments system for multiple types of
It sounds like you want a polymorphic association - class Party < ActiveRecord::Base has_many :comments, :as => :commentable end class BlogEntry < ActiveRecord::Base has_many :comments, :as => :commentable end class Comment < ActiveRecord::Base belongs_to :commentable, :polymorphic => true end then include columns ''commentable_id'' and
2006 Feb 15
2
Polymorphic joins work one way, but not the other
I''ve been using polymorphic joins from edge rails based on about 5 lines of advice Rick Olson gave me over IRC. There''s some sparse documentation popping up but it seems to cover a somewhat different case. Anyway - I pretty much got it to work - save for one detail. Here''s what I have: class Event < ActiveRecord::Base belongs_to :attachable, :polymorphic =>