Displaying 14 results from an estimated 14 matches for "commentable_type".
2008 Oct 29
5
Polymorphic Associations with inheritance
...gt; :commentable
end
class Post < BaseContent
has_many :comments, :as => :commentable
end
and here''s my Comment model:
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
Now when I try to associate a comment with an Article or Post, the
commentable_type field gets set as "BaseContent" instead of "Article"
or "Post." Is there a way to specify what the commentable_type field
is?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on...
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 rails doesn''t have a way to recognize
this. I really want to keep with Active Record so I tried
has_many_polymorphs, which makes finding the v...
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 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?}"
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
2006 Mar 31
2
"Owning" a polymorphic
...ny :comments, :as => :commentable
end
#comment class
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
#comment table includes the following fields:
id
content <--- the actual comment text
user_id <--- the user who made the comment
commentable_id
commentable_type
I''ve thought this over for 2 days and I still can''t seem to figure out a
way to describe what I want to describe... Does anyone have any ideas or
suggestions on how to do this?
--
Posted via http://www.ruby-forum.com/.
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 .....
</pre>
So for each commentable resource, I''ve a comment form at the bottom of
the commentable resource for users to comment.
I wa...
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
2013 Feb 28
2
Create polymorphic resources
...e)
end
end
nil
end
and
@commentable = find_commentable
Which loops over all params for something that ends with _id and then get
the class name from that etc... But that feels a bit "hackish" to me :S
Another solution would be to add the "commentable_id" and
"commentable_type" as hidden fields in my Comment form.
How do you handle this issue? Are there better ways than the way above?
Cheers
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails...
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, profile_path(User.find
(comment.user_id).profile) %></dt>
<dd><%= comment.comment %></dd>
</dl>
</div>
and h...
2006 Aug 16
0
Creating a comments system for multiple types of
...s_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
''commentable_type'' in the comments table, and
ActiveRecord will do lookups based on both the foreign
key and type.
Cheers,
B Gates
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
2010 Sep 11
10
Having difficulty with threaded comments, using acts_as_tree
...find_commentable
@comment = @commentable.comments.find(params[:id])
# @comments = @commentable.comments.paginate(:page => params[:page])
end
def new
@commentable = find_commentable
@comment = Comment.new
end
def create
@commentable = find_commentable
if @comment.commentable_type == "Comment"
@comment = @commentable.children.create(param[:comment])
else
@comment = @commentable.comments.build(params[:comment])
end
@comment.user_id = current_user.id
if @comment.save
flash[:success] = "Comment saved."
redirect_to @com...
2006 Dec 20
4
undefined method `fullname' for #<User:0x357e380>, BUT works on first view?
...N
tags.id = taggings.tag_id WHERE ((taggings.taggable_type = ''News'') AND
(taggings.taggable_id = 13))
Tag Columns (0.000187) SHOW FIELDS FROM tags
Rendered /news/_item (0.00561)
Comment Load (0.000301) SELECT * FROM comments WHERE
(comments.commentable_id = 13 AND comments.commentable_type = ''News'')
Comment Columns (0.000248) SHOW FIELDS FROM comments
User Columns (0.000345) SHOW FIELDS FROM users
User Load (0.000359) SELECT * FROM users WHERE (users.id = 1)
Rendered /comments/_comment (0.01381)
Rendered /comments/_form (0.00201)
Completed in 0.04776 (20...
2010 Oct 11
5
Object lost in memory/trashed?
...t bookmark.user it works and
displays "#".
As you can see, I''ve got two debug calls in my view.
When the partial is called for a Comment, debug displays the following:
--- !ruby/object:Comment
attributes:
comment: pouet
created_at: 2010-10-11 00:44:02
title: ""
commentable_type: Diagram
commentable_id: "29"
updated_at: 2010-10-11 00:44:02
id: "41"
user_id: "2"
attributes_cache:
created_at: 2010-10-11 00:44:02 Z
--- !ruby/object:User
attributes:
created_at: 2010-05-23 18:31:02
activated_at: 2010-06-08 22:23:19
send_news: "...