Code Monkey home page Code Monkey logo

acts_as_commentable_with_threading's Introduction

acts_as_commentable_with_threading's People

Contributors

arjun810 avatar austinpray avatar casen avatar chrisb avatar christianpeters avatar coreypnorris avatar dfischer avatar dinuz avatar jcode avatar jrunning avatar kamarcum avatar leereilly avatar malev avatar namiwang avatar petergoldstein avatar tcocca avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

acts_as_commentable_with_threading's Issues

Can't dup Nil class

Hi
I'm getting error, like in title, always on second request (first is ok) when trying to get user model from comment, for example 'article.root_comments.first.user'. Running the same from console works always fine.
I found a solution here
http://strd6.com/2009/04/cant-dup-nilclass-maybe-try-unloadable/
From all mentioned ones only adding uloadable to user model solved it.
Another question, maybe I should move user model from vendor/plugins to my app/models ?

Rails 4.0 activesupport dependency

Hi!
I trying to update my project from rails 3.2 to 4.0 but get this error on bundle install

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    acts_as_commentable_with_threading (>= 0) ruby depends on
      activesupport (~> 3.0) ruby

    rails (= 4.0.0.beta1) ruby depends on
      activesupport (4.0.0.beta1)

Is there any plans on updating gem to work with 4's rails?

Rails 4.1.4 "ArgumentError: Unknown key: :order"

ArgumentError: Unknown key: :order is happening on Comment.all and the commentable model's .comment_threads and .root_comments methods in Rails 4.1.4.

[1] pry(main)> Comment.all
ArgumentError: Unknown key: :order. Valid keys are: :class_name, :class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table
from /Users/erik/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.4/lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys'
[2] pry(main)> Post.last.comment_threads
  Post Load (0.1ms)  SELECT  "posts".* FROM "posts"   ORDER BY "posts"."id" DESC LIMIT 1
ArgumentError: Unknown key: :order. Valid keys are: :class_name, :class, :foreign_key, :validate, :autosave, :table_name, :before_add, :after_add, :before_remove, :after_remove, :extend, :primary_key, :dependent, :as, :through, :source, :source_type, :inverse_of, :counter_cache, :join_table
from /Users/erik/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/activesupport-4.1.4/lib/active_support/core_ext/hash/keys.rb:71:in `block in assert_valid_keys'

Edit: I'd really like to add this into Prelang as soon as possible.

Why is Comment#build_from only a class method?

Wouldn't it make sense to be able to build a comment from an existing Comment instance as a response?

some_comment.build_from( @article, user.id, "Comment body" )
# New comment is a reply to some_comment

Documentation editing error (acts_as_votable)

README says:

If you plan to use the acts_as_votable plugin with your comment system be sure to uncomment two things:

In lib/comment.rb uncomment the line acts_as_votable.

WHAT'S THE SECOND THING??!!!!!11

Active Support

Saw the previous activesupport issue. When running bundle install I get:

Bundler could not find compatible versions for gem "activesupport":
In Gemfile:

acts_as_commentable_with_threading (>= 0) ruby depends on
    activesupport (~> 3.0) ruby

actionpack (~> 4.0.0.beta1) ruby depends on
  activesupport (4.0.0.beta1)

My gem file has
gem 'acts_as_commentable_with_threading', :git => "git://github.com/elight/acts_as_commentable_with_threading.git", :branch => "rails4"

I'm not sure why it's not picking up the correct activesupport branch

Problem handlind inheritence

I have 2 models: Item and Book, where Book inherits from Item.
Then if I do this:

71.9.3p194 :001 > i = Item.first
1.9.3p194 :002 > i.comment_threads
Comment Load (1.8ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = 17 AND "comments"."commentable_type" = 'Item'
=> [#<Comment id: 44, commentable_id: 17, commentable_type: "Item", title: "", body: "primer", subject: "", user_id: 2, parent_id: nil, lft: 7, rgt: 8, created_at: "2012-05-13 15:31:38", updated_at: "2012-05-13 15:31:38">, #<Comment id: 45, commentable_id: 17, commentable_type: "Item", title: "", body: "segundo", subject: "", user_id: 2, parent_id: nil, lft: 9, rgt: 10, created_at: "2012-05-13 15:31:42", updated_at: "2012-05-13 15:31:42">, #<Comment id: 46, commentable_id: 17, commentable_type: "Item", title: "", body: "tercero", subject: "", user_id: 2, parent_id: nil, lft: 11, rgt: 12, created_at: "2012-05-13 15:31:46", updated_at: "2012-05-13 15:31:46">]
1.9.3p194 :003 > i.comments_ordered_by_submitted
Comment Load (1.3ms) SELECT "comments".* FROM "comments" WHERE "comments"."commentable_id" = 17 AND "comments"."commentable_type" = 'Book' ORDER BY created_at DESC
=> []
1.9.3p194 :004 >

As you can see, the first query use "Item" as commentable_type and the second uses "Book". The should both use the same or not?

User cant be blank

I use gem 'acts_as_commentable_with_threading', But when I want create new comment, Rails gives this error: # Not implemented: check to see whether the user has permission to create a comment on this object

@comment = Comment.build_from(@obj, current_user, @comment_hash[:body])
if @comment.save!
  render :partial => "comments/comment", :locals => { :comment => @comment }, :layout => false, :status => :created
else
  redirect_to root_path

in controller 
class CommentsController < ApplicationController
  def create
    @comment_hash = params[:comment]
    @obj = @comment_hash[:commentable_type].constantize.find(@comment_hash[:commentable_id])
    # Not implemented: check to see whether the user has permission to create a comment on this object
    @comment = Comment.build_from(@obj, current_user, @comment_hash[:body])
    if @comment.save!
      render :partial => "comments/comment", :locals => { :comment => @comment }, :layout => false, :status => :created
    else
      redirect_to root_path
    end
  end
end

Why gem dont use current_user on Rails 4.0.0.0?

ArgumentError: comparison of Fixnum with nil failed

Hi,
The following is the create action of my comments controller.

def create
        @commentable = find_commentable
        @comment_body, @parent_id = params[:comment][:body], params[:comment][:parent_id].to_i
        @comment = Comment.build_from(@commentable, current_user.id, @comment_body)
        if @comment.save
            if @parent_id > 0
                @parent_comment = Comment.find(@parent_id)
                @comment.move_to_child_of(@parent_comment)
            end
            flash[:notice] = "Your comment is created successfully."
            respond_to do |format|
                format.html { redirect_to @commentable }
                format.js
            end            
        else
            respond_to do |format|
                format.html { render :action => 'new' }
                format.js
            end
        end
    end

The comment gets save but when it tries to move the newly created comment to be child of existing comment, the following error is thrown in development log

ActiveRecord::ActiveRecordError (Impossible move, target node cannot be inside moved tree.):
  app/controllers/comments_controller.rb:31:in `create'

And this is the error when I tried this same thing on console

>> @comment.save
=> true
>> @comment.move_to_child_of(@parent_comment)
ArgumentError: comparison of Fixnum with nil failed
    from /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/whiny_nil.rb:55:in `<='
    from /home/millisami/rails_apps/wnn_finale/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:410:in `move_possible?'
    from /home/millisami/rails_apps/wnn_finale/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:497:in `move_to'
    from /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
    from /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:182:in `transaction'
    from /opt/ruby-enterprise-1.8.6-20090610/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/transactions.rb:188:in `transaction'
    from /home/millisami/rails_apps/wnn_finale/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:488:in `move_to'
    from /home/millisami/rails_apps/wnn_finale/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:397:in `move_to_child_of'
    from (irb):7

What might be the culprit??

ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) when gem is included

I am getting this error bellow when ever I try to run the generator or try to create a migration when i have the gem installed...

Any idea?

/Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_pool.rb:318:in retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished) from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:97:inretrieve_connection'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.0/lib/active_record/connection_adapters/abstract/connection_specification.rb:89:in connection' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/moretea-awesome_nested_set-1.4.3.1/lib/awesome_nested_set/base.rb:258:inquoted_left_column_name'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/moretea-awesome_nested_set-1.4.3.1/lib/awesome_nested_set/base.rb:72:in acts_as_nested_set' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/comment.rb:5:inclass:Comment'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/comment.rb:4:in <top (required)>' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:inrequire'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in block in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:inblock in load_dependency'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:591:in new_constants_in' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:225:inload_dependency'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/bundler/gems/acts_as_commentable_with_threading-31983bd/lib/acts_as_commentable_with_threading.rb:7:in<top (required)>'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:64:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:64:inblock (2 levels) in require'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:62:in each' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:62:inblock in require'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:51:in each' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler/runtime.rb:51:inrequire'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/bundler-1.0.0.rc.6/lib/bundler.rb:112:in require' from /Users/Pete/Sites/work/pollenizer/PitchBay/config/application.rb:7:in<top (required)>'
from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:15:in require' from /Users/Pete/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.0/lib/rails/commands.rb:15:in<top (required)>'
from script/rails:6:in require' from script/rails:6:in

'

comment_threads and root_comments do not work with model inheritance

If my commentable model has inherited models, using comment_threads or root_comments does not work as expected.

Steps to reproduce:

% rails new aacwt
[ cd aacwt, edit Gemfile, run bundle ]
% rails generate acts_as_commentable_with_threading_migration
% rails g model Post
% rails g model Article --parent=Post
% rails g model User
% rake db:migrate
> a = Article.create
> u = User.create
> c = Comment.build_from( a, u, "hello, world" )
> c.save
>  a.root_comments
 => [] # What!?
sqlite> select * from comments ;
1|1|Article||hello, world||1||1|2|2010-11-17 12:27:40.157701|2010-11-17 12:27:40.157701

Here, we have an Article as commentable_type.

% tail -1 log/development.log 
  Comment Load (0.2ms)  SELECT "comments".* FROM "comments" WHERE ("comments".commentable_id = 1 AND "comments".commentable_type = 'Post') AND ("comments"."parent_id" IS NULL) ORDER BY created_at ASC

But it looks for a Post commentable_type.

already initialized constant error..

..when using 'bundle install' on a locally sourced version of the current master branch.

warning: already initialized constant ACTS_AS_COMMENTABLE_WITH_THREADING

Migration Failed: column 'body' can't have a default value

Running my first migration after installing acts_as_commentable_with_threading, I get this error:

==  ActsAsCommentableWithThreadingMigration: migrating ========================
-- create_table(:comments, {:force=>true})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql2::Error: BLOB/TEXT column 'body' can't have a default value: CREATE TABLE
`comments` (`id` int(11) DEFAULT NULL auto_increment PRIMARY KEY, `commentable_i
d` int(11) DEFAULT 0, `commentable_type` varchar(255) DEFAULT '', `title` varcha
r(255) DEFAULT '', `body` text DEFAULT '', `subject` varchar(255) DEFAULT '', `u
ser_id` int(11) DEFAULT 0 NOT NULL, `parent_id` int(11), `lft` int(11), `rgt` in
t(11), `created_at` datetime NOT NULL, `updated_at` datetime NOT NULL) ENGINE=In
noDB

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Any idea what's going on? I haven't touched the migration file, but at the moment body does have a default value:

t.text :body, :default => ""

comments won't save

This is my view
<%= form_for (:comment), :url => "#{item.id}/comment" do |f|%>
<%= f.label :body, "Write"%>
<%= f.text_field :body%>
<%= f.submit "Comment" %>
<% end %>

The method in my items controller is access, but the comment does not save.
Here's my items controller.

def comment
@comment = Comment.build_from( @item, @current_user.id, params[:body])

    if @comment.save
        redirect_to @item

this is only here to confirm that the comment did not save

    else
        redirect_to items_path, notice: "Did not work"          
            end

end

Why won't the comment save? I can get it to save in the rails console.

Deprecation warnings, rails4

Ruby 2, Rails 4.

DEPRECATION WARNING: #connection is deprecated in favour of accessing it via the class.

DEPRECATION WARNING: Model.scoped is deprecated. Please use Model.all instead.

DEPRECATION WARNING: The following options in your User.has_and_belongs_to_many :read_comments declaration are deprecated: :uniq.

has_many :spam_comments, conditions: { spam: true }, class_name: 'Comment'
should be rewritten as the following:

has_many :spam_comments, -> { where spam: true }, class_name: 'Comment'

DEPRECATION WARNING: The following options in your Comment.has_many :children declaration are deprecated: :order. Please use a scope block instead.

Error installing with bundle

I added
My Gemfile:

gem 'rails'
gem 'acts_as_commentable_with_threading'

$ bundle install
Updating https://github.com/elight/acts_as_commentable_with_threading.git
Fetching source index for http://rubygems.org/
Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
acts_as_commentable_with_threading depends on
activerecord (~> 3.0)

rails depends on
  activerecord (3.0.0.rc)

I've search and google and i can't figure out why this would happen. Ideas?

Thanks

db migrate with error in Mysql2 Adapter

the console prompt messages look like

Mysql2::Error: BLOB/TEXT column 'body' can't have a default value

so i have no choose but to delete body default value in comment migration file and save , migrate again , it is work .

it is so strange,maybe there is an additional check for mysql, is it really? thanks.

Bundler could not find compatible versions for gem "activerecord"

In snapshot (Gemfile.lock):
activerecord (3.1.0)

In Gemfile:
acts_as_commentable_with_threading depends on
activerecord (~> 3.0.0)

Running bundle update will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.


Needs support for Rails 3.1 apparently / new gems.

Adding a category to each comment

Hi, I would like to add a category field and each comment must belong to one category.
Can anyone tell me how to implement it? thanks.

:force => true

For some reason my migration didn't like the force => true line. It could be because I did not already have the table, so it could not drop the table before creating it. Otherwise, I have no idea. Very minor problem, the fix was just to remove the statement.

dont work with Rails 4 Ruby 2.0.0 Win7

Bundler could not find compatible version for gem "activesupport":
In Gemfile:
acts_as_commentable_with_threading <> = 0> x86-mingw32 depends on activesupport <~> 3.0> x86-mingw32

         rails <= 4.0.0> x86-mingw32  depends on 
            activesupport < 4.0.0>

Illustrative tutorial on implementing the gem

Hi,

I have had a look around and cannot find a decent tutorial showing you how you can go about implementing this gem for a fully commendable model with threaded replies. If anyone knows of one I would be in your debt.

Damien

stacktrace on validations

Rails 2-3-stable, plugin bombs when trying to save a record from controller.

NoMethodError in Community/groupsController#create_shout

You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.include?

/path/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:142:in `create_time_zone_conversion_attribute?'
/path/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:75:in `define_attribute_methods'
/path/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `each'
/path/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
/path/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:355:in `respond_to?'
/path/vendor/rails/activesupport/lib/active_support/core_ext/object/blank.rb:13:in `blank?'
/path/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `send'
/path/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:181:in `add_on_blank'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:179:in `each'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:179:in `add_on_blank'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:587:in `validates_presence_of'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `call'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:182:in `evaluate_method'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:166:in `call'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `each'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `send'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:90:in `run'
/path/vendor/rails/activesupport/lib/active_support/callbacks.rb:276:in `run_callbacks'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:1098:in `valid_without_callbacks?'
/path/vendor/rails/activerecord/lib/active_record/callbacks.rb:315:in `valid?'
/path/vendor/rails/activerecord/lib/active_record/validations.rb:1077:in `save_without_dirty'
/path/vendor/rails/activerecord/lib/active_record/dirty.rb:79:in `save_without_transactions'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:229:in `send'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:229:in `with_transaction_returning_status'
/path/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:228:in `with_transaction_returning_status'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:196:in `save'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
/path/vendor/rails/activerecord/lib/active_record/transactions.rb:196:in `save'
/path/app/controllers/community/groups_controller.rb:99:in `create_shout'

How to get commendable tests to run on it's own in Gem?

If you checkout the gem, how do you get the second test file to pass? From my output it seems that it's not connecting to the database. Upon investigation it looks like the spec_helper.rb should be setting up a connection.

Anyone have an idea of what's wrong? Anything I'm missing?

rake spec
rake/gempackagetask is deprecated.  Use rubygems/package_task instead
............FFFFFF

1)
ActiveRecord::UnknownAttributeError in 'A class that is commentable special class finders#find_comments_for should return the comments for the passed commentable'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:17:in `block (4 levels) in <top (required)>'

2)
ActiveRecord::UnknownAttributeError in 'A class that is commentable special class finders#find_comments_for should not return the comments for other commentables'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:17:in `block (4 levels) in <top (required)>'

3)
ActiveRecord::UnknownAttributeError in 'A class that is commentable special class finders#find_comments_by_user should return comments by the passed user'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:37:in `block (4 levels) in <top (required)>'

4)
ActiveRecord::UnknownAttributeError in 'A class that is commentable special class finders#find_comments_by_user should not return comments by other users'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:37:in `block (4 levels) in <top (required)>'

5)
ActiveRecord::UnknownAttributeError in 'A class that is commentable instance methods#comments_ordered_by_submitted should return its own comments, ordered with the newest first'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:61:in `block (4 levels) in <top (required)>'

6)
ActiveRecord::UnknownAttributeError in 'A class that is commentable instance methods#comments_ordered_by_submitted should not include comments for other commentables'
unknown attribute: commentable
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1753:in `block in assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `each'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1747:in `assign_attributes'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/base.rb:1567:in `initialize'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `new'
/Users/Armageddon/.rvm/gems/ruby-1.9.2-p180-patched@acts_as_commentable_with_threading/gems/activerecord-3.1.1/lib/active_record/validations.rb:39:in `create!'
spec/commentable_spec.rb:61:in `block (4 levels) in <top (required)>'

Help: Should the comment.rb reside under plugins or in my app/models/comments folder?

The reason I ask is, the belongs_to :user association does not seem to work when I do this

comments_controller:
@comment = Comment.build_from(@post, @user.id, comment_body)
@comment.save
-the comment record is created properly in DB

In my view _comment.html.erb, the following chokes
<%= comment.user.name %>
Throws exception
undefined method `name' for "#<User:0xb590f7e4>":User

-name is a method I defined in user.rb

Any ideas greatly appreciated.

Readme lacks example code for integrating with forms

An example form would be immensely helpful. It would be a trivial matter for experts, but incredibly helpful and time-saving for newcomers. And for a good % of the time, a deciding factor for newcomers to use this gem instead of seeking other sources.

The current code for controllers, do they all go in the "Articles" controller? Which scope or file do they go into? This kind of information of often overlooked by experts, professors, and people who have been doing things for a long time because it' intimate knowledge to them, and often becomes a blind-spot in terms of teaching.

Some examples of ambiguity and confusion:

  1. The following wording makes it seem like you need to write this code in the model. Easily un-confused by labeling the file name that this code should go in, (i.e. articles_controller.rb or should it be comments_controller.rb I still can't tell.)?
Add a comment to a model instance, for example an Article:

@article = Article.find(params[:id])
@user_who_commented = @current_user
@comment = Comment.build_from( @article, @user_who_commented.id, "Hey guys this is my comment!" )
  1. where does this goo?
To make a newly created comment into a child/reply of another comment:

@comment.move_to_child_of(the_desired_parent_comment)

Other issues:

How to you properly use the "lft" and "rgt" integer columns?

The generator command doesn't produce a comments controller. Do we need a comments controller though? If not, how do you create comments? This is where an example form would help. Especially using it with ajax, which is most likely what everyone wants to do with it.

The model is under app/models/ for rails, not lib/

In lib/comment.rb uncomment the line acts_as_votable.

Acts as Voteable?

Looks like this gem supports a "voteable" plugin - however it doesn't specify which specific one. It seems that "acts_as_voteable" goes all the way back to 2006 in terms of code.

Which repo is the one this gem was built with compatibility in mind for?

order in acts_as_commentable

hi, its rather something what may be mentioned in comments. If someone needs to take all comment threads and display them one after another (and than style it with padding for example) it may be usefull to add :order => 'lft ASC, created_at ASC' in CommentableWithThreading::ClassMethods.acts_as_commentable has_many

README inconsistencies and typos

Hi, I just read all the documentation. Noticed few issues which are basically typos in my opinion.

First, there is mentioned about votable gem.

"If you plan to use the acts_as_votable plugin with your comment system be sure to uncomment two things:"

In lib/comment.rb uncomment the line acts_as_votable.

When I run rails generate to install your gem, it creates comment.rb file under app folder. Doesn't it make sense to mention in README, that I have to change app/comment.rb to uncomment that acts_as_votable rather than in /lib/comment.rb

Another thing is inside comment.rb, commented out #acts_as_votable is with typo and doesn't work by default.

It is now:   acts_as_voteable
It should be:   acts_as_votable

Hope this helps for the future users :)

Support for anonymous comments

We would like to support anonymous comments for our application.

In order to make it work with acts_as_commentable_with_threading, we had to add a dummy user to the database, which is quite hacky. (We also added the column "username" to the comment model, which is used if the comment.user_id = 1 (dummy user).)

Wouldn't it be a nice feature to optionally allow anonymous users?

location of comment.rb

Yesterday I ran acts_as_commentable_upgrade_migration and got this error:

saasbook@saasbook:~/Documents/dxrails$ rails generate acts_as_commentable_upgrade_migration
      create  db/migrate/20140425153710_acts_as_commentable_upgrade_migration.rb
Could not find "comment.rb" in any of your source paths. Your current source paths are: 
/home/saasbook/.rvm/gems/ruby-1.9.3-p448/gems/acts_as_commentable_with_threading-1.2.0/lib/generators/acts_as_commentable_upgrade_migration/templates

Could it be that comment.rb is in the wrong directory? Instead of being in templates, it is one level higher.

Another thought: Could the fact that I already had an existing app/models/comment.rb have caused such an error?

Acts as votable should be config variable, not source code edit

Hey, great gem! I was thinking that you shouldn't ask users to edit your gem source for configuration, in case they want to update in which case the app will break. If elight is cool with this but doesn't have time, I would be happy to submit a pull request. Just want to make sure it will get accepted first.
PS: the docs say to change two lines and then only list one line.

ActiveRecord joins method "Association 'comments' was not found"

Hi,
When I try to perform a join method on the model that "acts_as_commentable", e.g:

Article.joins(:comments)

I get the error:
ActiveRecord::ConfigurationError: Association named 'comments' was not found; perhaps you misspelled it?

I guess that it's caused because the ActiveRecord joins method uses the relations explicitly recorded with has_one, belons_to, etc.
Due this gem uses the act_as_commentable method instead of the above ones, maybe that raises the error.

I could avoid this issue writting the SQL query by and, instead of using the ActiveRecord methods, but It'd be great if we could use this methods.

Bundler could not find compatible versions for gem "activerecord":

When I add gem 'acts_as_commentable_with_threading' to my Gemfile, and try bundle install i get this:

Bundler could not find compatible versions for gem "activerecord":
In Gemfile:
acts_as_commentable_with_threading depends on
activerecord (~> 3.0.0)

authlogic depends on
  activerecord (3.1.0)

I'm using rails 3.1.0,
how can I solve this conflict?

commentable_type character case issue

I finally got this gem to work....
I had to not call the "load_commentable" method before the "def create" in order for new comments to load.
However I wasn't able to read the new comments in my ariticle.show page. I noticed that the

def new
@comment = Comment.new
end

method inserts a "Lap" for the commentable type. I have to manually change them to lowecase "lap" in the db or them to load. I cannot locate where I would change the case during creation so that the data is in lowercase when inserted in the comments table.

Any ideas?
thanks
steve

Pagination?

Hi, first of all thank you for your amazing work on this!
Is there any way to retrieve comments using pagination so I can load a paginated conversation?

Has conflicting dependencies with Pundit

I tried adding this to an app with pundit already present and couldn't bundle:

Bundler could not find compatible versions for gem "activesupport":
  In Gemfile:
    acts_as_commentable_with_threading (>= 0) ruby depends on
      activesupport (~> 3.0) ruby

    pundit (>= 0) ruby depends on
      activesupport (4.0.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.