Displaying 14 results from an estimated 14 matches for "commentable_id".
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,
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
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 Mar 31
2
"Owning" a polymorphic
...to :user
has_many :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 user...
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
...1.classify.constantize.find(value)
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 th...
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 here''s the code that calls...
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 Aug 16
0
Creating a comments system for multiple types of
...lass 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
''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
ht...
2007 Dec 16
0
pass the model type to the action via a hidden field?
..., :url => comments_path ) do |f | -%>
<%= f.text_field :title %>
<%= f.text_field :comment %>
<%= f.hidden_field ''commentable'', ''commentable'', :value => @user %>
<%= f.hidden_field ''commentable'', ''commentable_id'', :value =>
@user.id %>
<%= submit_tag ''Create'' %>
<% end -%>
I know this is not correct, but I am very confused as to what the
@model.type and @model.id should each be. If anyone can give me a
lead as to the right direction it will be much apprecia...
2009 Apr 29
0
Polymorphic comments table needs associated model
...user.comments.find :all, :conditions => "`comments`.commentable_type
= ''Venue''", :include => :venues
#--> WORKS but it''s ugly
Comment.find_by_sql "SELECT `comments`. * , `venues`. name FROM
`comments` INNER JOIN `venues` ON venues.id = comments.commentable_id
WHERE (user_id =#{self.id} AND commentable_type = ''Venue'') ORDER BY
created_at DESC LIMIT 0 , 30"
Does anyone have any ideas on how I can avoid using find_by_sql for
this operation?
Best,
Jackson
2006 Dec 20
4
undefined method `fullname' for #<User:0x357e380>, BUT works on first view?
...* FROM tags INNER JOIN taggings ON
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...
2010 Oct 11
5
Object lost in memory/trashed?
...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: "1"
remember_token_...