Git Product home page Git Product logo

acts-as-messageable's Introduction

Hi there ๐Ÿ‘‹

acts-as-messageable's People

Contributors

aagrawal2001 avatar adamdilek avatar akosipc avatar bitdeli-chef avatar dependabot-preview[bot] avatar dependabot[bot] avatar dhiemstra avatar keichan34 avatar lte avatar luvtechno avatar masa-iwasaki avatar rojotek avatar sergeykishenin avatar sukhitambar77 avatar teemobustin 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

acts-as-messageable's Issues

Rails 3.1 support

Currently doesn't work because of the ActiveRecord and ActiveSupport 3.0 requirement.

No Unread Messages?

I couldnt find a unread received messages (good for inbox unread count) so I added the following under

   received_messages()
      def unread_messages
        result = received_messages_relation.scoped.where(:recipient_delete => false, :opened => 0 )
        result.relation_context = self

        result
      end

delete only works if relation used

delete method does nothing when called on a single message object (not passed to a block from 'process' function).
E.g.

ActsAsMessageable::Message.find(1).delete
# or
user.messages.last.delete

does nothing.

No Method Error for conversations

When I call the conversations method like below;

current_user.received_messages.conversations

I get the error below;

NoMethodError (undefined method `conversations' for #<ActiveRecord::Relation:0x37b0a20>)

Then I checked my gem folder under ruby installation and saw that the files in acts-as-messageable-0.4.7 have not been updated.

What am I doing wrong here? How can I update the gem correctly?

Edit: I uninstalled and then install the gem again. The problem still persists.

Filters error when table_name changed

# use "user_inbox" table name
class User < ActiveRecord::Base
  acts_as_messageable :table_name => "user_inbox",
    :required   => :body,
    :class_name => "UserInbox",
    :dependent  => :destroy
end

# then
@alice = User.first
@bob   = User.last

#then
@alice.messages.are_from(@bob)

result

  User Load (0.4ms)  SELECT `users`.* FROM `users` ORDER BY `users`.`id` DESC LIMIT 1
  User Load (0.5ms)  SELECT `users`.* FROM `users` LIMIT 1
   (1.2ms)  SELECT COUNT(*) FROM `user_inbox` WHERE ((sent_messageable_type = 'User' and
 sent_messageable_id = 2 and
 sender_delete = 0 and sender_permanent_delete = 0) or
 (received_messageable_type = 'User' and
 received_messageable_id = 2 and
 recipient_delete = 0 and recipient_permanent_delete = 0)) AND ((`messages`.`sent_messageable_id` = 1 AND `messages`.`sent_messageable_type` = 'User'))
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'messages.sent_messageable_id' in 'where clause': SELECT COUNT(*) FROM `user_inbox`  WHERE ((sent_messageable_type = 'User' and
                                                sent_messageable_id = 2 and
                                                sender_delete = 0 and sender_permanent_delete = 0) or
                                                (received_messageable_type = 'User' and
                                                received_messageable_id = 2 and
                                                recipient_delete = 0 and recipient_permanent_delete = 0)) AND ((`messages`.`sent_messageable_id` = 1 AND `messages`.`sent_messageable_type` = 'User'))
from /home/cybergarage/.rvm/gems/ruby-1.9.3-p392/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'

send_message with a bang ! to give errors

at the moment, sending an empty message if :body has validation on it gives

Validation failed: Body can't be blank, Body is too short (minimum is 1 characters), Body can't be blank

but since no error is given back when the message tries to be saved to the DB, only the error shows.

is there a way to have a send_message! which will throw the error and not save to the db?
something like

@message = alice.send_message(bob, :body => "")
if @message
// horray
else
//something went wrong
end

Gel all conversations

Is there a way to retrieve the list of conversations ordered by last answered?
Thanks.

I'm having the following issue with acts-as-messageable

When I try to reply I get the following Warning

@message.reply(:topic => "Re: Teszt", :body => "123")

WARNING: Can't mass-assign protected attributes for ActsAsMessageable::Message: topic, body

Person Load (0.3ms) SELECT people.* FROM people WHERE people.id = 2 ORDER BY people.id ASC LIMIT 1
Person Load (0.3ms) SELECT people.* FROM people WHERE people.id = 1 ORDER BY people.id ASC LIMIT 1
WARNING: Can't mass-assign protected attributes for ActsAsMessageable::Message: topic, body

(0.3ms) BEGIN
(0.3ms) ROLLBACK
(0.2ms) BEGIN
(0.2ms) ROLLBACK
=> #<ActsAsMessageable::Message id: nil, topic: nil, body: nil, received_messageable_id: 1, received_messageable_type: "Person", sent_messageable_id: 2, sent_messageable_type: "Person", opened: false, recipient_delete: false, sender_delete: false, created_at: nil, updated_at: nil, ancestry: "1", recipient_permanent_delete: false, sender_permanent_delete: false>

Does this support rails4 strong parameters?

If I execute command "r g acts-as-messageable:migration", I get error about strong_parameters as following:

ruby-1.9.3-p286/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:17:in attr_accessible':attr_accessibleis extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or addprotected_attributes` to your Gemfile to use old one. (RuntimeError)

from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:8:in <class:Message>' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:4:inmodule:ActsAsMessageable'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:3:in <top (required)>' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:228:inconst_get'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:228:in block in constantize' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:ineach'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in inject' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:inconstantize'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/core_ext/string/inflections.rb:66:in constantize' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/model.rb:34:inacts_as_messageable'
from /home/elbbub/D.works/projects/_garage/messageable-app/app/models/user.rb:11:in <class:User>' from /home/elbbub/D.works/projects/_garage/messageable-app/app/models/user.rb:1:in<top (required)>'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in load' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:inblock in load_file'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in new_constants_in' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:inload_file'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in require_or_load' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:inload_missing_constant'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in const_missing' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:inconst_get'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in block in constantize' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:ineach'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in inject' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:inconstantize'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:534:in get' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:565:inconstantize'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise.rb:285:in get' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/mapping.rb:77:into'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/mapping.rb:72:in modules' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/mapping.rb:89:inroutes'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/mapping.rb:156:in default_used_route' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/mapping.rb:66:ininitialize'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise.rb:319:in new' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise.rb:319:inadd_mapping'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/rails/routes.rb:210:in block in devise_for' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/rails/routes.rb:209:ineach'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/devise-3.1.0/lib/devise/rails/routes.rb:209:in devise_for' from /home/elbbub/D.works/projects/_garage/messageable-app/config/routes.rb:2:inblock in <top (required)>'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in instance_exec' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:ineval_block'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:294:in draw' from /home/elbbub/D.works/projects/_garage/messageable-app/config/routes.rb:1:in<top (required)>'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in load' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inblock in load'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inload'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in block in load_paths' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:ineach'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in load_paths' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:16:inreload!'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:26:in block in updater' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:incall'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/file_update_checker.rb:75:in execute' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:27:inupdater'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:6:in execute_if_updated' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application/finisher.rb:69:inblock in module:Finisher'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/initializable.rb:30:in instance_exec' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/initializable.rb:30:inrun'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/initializable.rb:55:in block in run_initializers' from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:150:inblock in tsort_each'
from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:183:in block (2 levels) in each_strongly_connected_component' from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:219:ineach_strongly_connected_component_from'
from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:182:in block in each_strongly_connected_component' from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:180:ineach'
from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:180:in each_strongly_connected_component' from /home/elbbub/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/tsort.rb:148:intsort_each'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/initializable.rb:54:in run_initializers' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application.rb:215:ininitialize!'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in method_missing' from /home/elbbub/D.works/projects/_garage/messageable-app/config/environment.rb:5:in<top (required)>'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in require' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inblock in require'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inrequire'
from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/application.rb:189:in require_environment!' from /home/elbbub/.rvm/gems/ruby-1.9.3-p286/gems/railties-4.0.0/lib/rails/commands.rb:45:in<top (required)>'

message.open/mark_as_read problem

For this one I am not %100 sure, maybe I am missing some point
If you want to read an inbox or outbox message with @message.open or @message.mark_as_read, it doesn't work.
size of @user.received_message doesn't change after @user.received_messages or @message.open operation.

I think it is because of below, in model.rb class, this method is defined as:

def received_messages
result = received_messages_relation.scoped.where(:recipient_delete => false)
result.relation_context = self
result
end

As you see above, db select is done for receipent_delete column, not for opened column.. But after @message.open or @message.mark_as_read opened column is change to TRUE, receipent_delete is not changed

Adding attachments

Hi,

Is there a way to add attachments to conversation while sending replies similar to facebook ?

Rails 4 support - Deprecation warning

I do not know if rails4 support is in scope. Currently I am getting the following warning on logs, and rspec breaks in similar fashion:

DEPRECATION WARNING: Calling #scope or #default_scope with a hash is deprecated. Please use a lambda containing a scope. E.g. scope :red, -> { where(color: 'red') }. (called from class:User at /path/to/application/root/app/models/user.rb:LINE_NUMBER)
DEPRECATION WARNING: Calling #scope or #default_scope with a hash is deprecated. Please use a lambda containing a scope. E.g. scope :red, -> { where(color: 'red') }. (called from class:User at /path/to/application/root/app/models/user.rb:LINE_NUMBER)

This happens when "acts_as_messageable" is added to the user model.

Cannot access CustomMessage methods

If I set acts_as_messageable to use a custom message model, I run into issues that every model that it return using a method of acts_as_messageable (like conversation, etc) is returned as ActsAsMessageable and does not share the methods of my custom model.

This means I cannot add methods to my model..

Is there a way around this?

this is what I added to my user.rb model

acts_as_messageable     :table_name => "messages",
                        :required   => :body,               
                        :class_name => "Message",    
                        :dependent  => :destroy

this my model

class Message < ActsAsMessageable::Message

note that I can access custommessage attributes

I get an error with send_message around :body :Symbol

This is the error I get:

 NoMethodError: undefined method `each_with_index' for :body:Symbol     from /usr/lib/ruby/gems/1.8/gems/acts-as-messageable-0.3.0/lib/acts-as-messageable/acts-as-messageable.rb:55:in `send_message'

This is using the same example in the README. Seems like it does not recognize ;body as a symbol?

associations should be done before message create

In /lib/acts-as-messageable/model.rb method send_message lines 106

message = self.class.messages_class_name.create message_attributes

should be

message = self.class.messages_class_name.new message_attributes

so when you save the model in line 109 it has the associations delcared in lines 106 and 107 instead of just updating to add the associations.

messages method on model does not work with STI

If you have a model with inherited classes and you use acts-as-messageable on the base class, the messages method will always return 0 (because it's trying to make the type match the subclass). The received_messages and sent_messages methods work fine, however.

Example:

class User < ActiveRecord::Base
  acts-as-messageable 
end

class Buyer < User
end

class Seller < User
end

One way to fix this would be to rewrite messages = sent_messages + received_messages (requires 2 database queries).
Or, it could be turned into one union query.

Rail 4 Upgrade Issue

I just upgraded my project to Rails 4. I'm getting the following error message for the GEM.

/usr/local/rvm/gems/ruby-2.0.0-p247/gems/activemodel-4.0.0/lib/active_model/deprecated_mass_assignment_security.rb:14:in attr_accessible':attr_accessibleis extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or addprotected_attributesto your Gemfile to use old one. (RuntimeError) from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:8:inclass:Message'
from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:4:in <module:ActsAsMessageable>' from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/acts-as-messageable-0.4.8/lib/acts-as-messageable/message.rb:3:in<top (required)>'

Is this being worked on or am I missing something I should upgrade?

Thanks

Overwriting existing method ActsAsMessageable

My Rails console log, suddenly returning this log.
What is this?

Creating scope :roots. Overwriting existing method ActsAsMessageable::Message.roots.
Creating scope :ancestors_of. Overwriting existing method ActsAsMessageable::Message.ancestors_of.
Creating scope :children_of. Overwriting existing method ActsAsMessageable::Message.children_of.
Creating scope :descendants_of. Overwriting existing method ActsAsMessageable::Message.descendants_of.
Creating scope :subtree_of. Overwriting existing method ActsAsMessageable::Message.subtree_of.
Creating scope :siblings_of. Overwriting existing method ActsAsMessageable::Message.siblings_of.
Creating scope :ordered_by_ancestry. Overwriting existing method ActsAsMessageable::Message.ordered_by_ancestry.
Creating scope :ordered_by_ancestry_and. Overwriting existing method ActsAsMessageable::Message.ordered_by_ancestry_and.
Creating scope :before_depth. Overwriting existing method ActsAsMessageable::Message.before_depth.
Creating scope :to_depth. Overwriting existing method ActsAsMessageable::Message.to_depth.
Creating scope :at_depth. Overwriting existing method ActsAsMessageable::Message.at_depth.
Creating scope :from_depth. Overwriting existing method ActsAsMessageable::Message.from_depth.
Creating scope :after_depth. Overwriting existing method ActsAsMessageable::Message.after_depth.

unable to do order by created_at

Even though i write
user.recieved_messages.order('created_at desc')

It produce the sql query

SELECT messages.* FROM messages WHERE messages.received_messageable_id = 21 AND messages.received_messageable_type = 'User' AND messages.recipient_delete = 0 ORDER BY created_at, created_at desc

why there is the first created_at in order by clause? It should be only ORDER BY created_at desc

Delete fields' migration created BEFORE table creation

It's the second time it happens to me when installing the gem.

$ rails g acts-as-messageable:migration
      create  db/migrate/20111115204328_add_recipient_permanent_delete_and_sender_permanent_delete_to_messages.rb
      create  db/migrate/20111115204329_create_messages_table.rb

wrong number of arguments error

Sometimes I got this trying to rebuild database from scratch. Also I got this trying to run rails app on Heroku

2012-05-20T16:34:10+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/acts-as-messageable-0.1.0/lib/acts_as_messageable/acts-as-messageable.rb:9:in `acts_as_
messageable': wrong number of arguments (1 for 0) (ArgumentError)

My class looks like

class User < ActiveRecord::Base
  acts_as_messageable :class_name => "Message", :required => :topic
end

read issue

Thanks a lot for this gem, now building my internal messaging system on top of it.

For reading a message, it is written (in github project front page) that we can use read method, however there isn't any read method defined in message.rb class, therefore it throws a missing method exception
Maybe you can remove the line below from the front page.
@message.read

undefined method `acts_as_messageable'

Hi,

I am getting an error after installing acts_as_messageable gem in my rails 4.0.4 app with devise.

Please if you can let me know how can I fix this ?

Thank you,
Gaurav

messages.unread returns wrong number of messages

Hi

I am trying to use member.messages.unreaded but it returns the wrong number of unread messages.

When I inspect the sql generated

SELECT messages.* FROM messages WHERE messages.opened = 0 AND ((sent_messageable_type = 'Member' and
sent_messageable_id = 666762 and
sender_delete = 0 and sender_permanent_delete = 0) or
(received_messageable_type = 'Member' and
received_messageable_id = 666762 and
recipient_delete = 0 and recipient_permanent_delete = 0)) ORDER BY created_at desc

The above sql returns the send messages in unread messages.

if I remove following from sql it returns the correct unread messages

(sent_messageable_type = 'Member' and
sent_messageable_id = 666762 and
sender_delete = 0 and sender_permanent_delete = 0) or

undefined method set_table_name && r g acts_as_messageable:migrations is wrong

Hey

This command is creating the the table after the migration of the columns...

Davidslv$ rails g acts-as-messageable:migration
create db/migrate/20111027174737_add_recipient_permanent_delete_and_sender_permanent_delete_to_messages.rb
create db/migrate/20111027174738_create_messages_table.rb

And is giving me an error about set_table_name

Bug in replying to conversation

@john = User.first # id 1
@dave = User.last # id 2

msg = @dave.send_message(@john, "hello", "how are you?") # id 1, ancestry nil, sender 1, receiver 2
@john.reply_to(msg, "ohey", "working?") # id 2, ancestry 1, sender 2, receiver 1

# That part works fine. But, if you already have a conversation and do this...

msg = ActsAsMessageable::Message.find_by_id(1) # I could not find another way to pull up the root message of a conversation without doing a find for its ID?
@dave.reply_to(msg, "fail", "this is where it breaks") # id 3, ancestry 1 [correct], sender 2 [correct], receiver 2 [incorrect]

# In a nutshell, if you don't have the object stored from the result of a "send message" and have to query for it directly, it marks both the sender and the receiver as the same ID if you do a reply_to

create_at timestamp?

is there somehow we can add create_at timestamp?
editted: i saw you've added the create_at in 0.3.1 but i cant see it in the code

thanks

Remove deprecation warning (set_table_name)

DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from acts_as_messageable at /home/lite/work/acts-as-messageable/lib/acts-as-messageable/model.rb:24)

Topic must be manually set to nil even if not used

In my setup messages doesn't have a topic. I declare

acts_as_messageable :required => :body

It's quite inconvenient to use send_message/reply_to as I always have to pass nil to the second argument

@mother.send_message(@son, nil, "How are ya?")
@son.reply_to(@mother, nil, "Totally drunk")

I can see 2 solutions

  1. rearrange parametrs so topic is after a body and set to nil by default. So we can invoke the method like this:
@mother.send_message(@son, "How are you?")
@mother.send_message(@son, "How was the party? Did you enjoy?", "Party")
  1. use options hash
@mother.send_messages(@son, :body => "How was the party?", :topic => "Party")

Personally I'd choose 2) as it's more flexible.

Installation for rails 2

openfirmware / acts-as-messageable depends on activerecord 3 or newer but my rails 2.3.14 depends on activerecord 2.3.14 ONLY.

  1. how can i define my gemfile so that acts-as-messageable can be installed successfully?
  2. rails2.3.11_compatible branch is for rails 2.3.11 only? can i use it for rails 2.3.14?
  3. do i need to install both master and 2.3.11 ver for my rails 2?

when i run 'bundle install' it showed:
Fetching source index for http://rubygems.org/ Bundler could not find compatible versions for gem "activerecord": In Gemfile:

acts-as-messageable (= 0.3.0) x86-mingw32 depends on
activerecord (~> 3.0.0) x86-mingw32

rails (= 2.3.14) x86-mingw32 depends on
activerecord (2.3.14)

my gemfile:
gem "activerecord", ">= 2.3.14", "<= 3.0.11"
gem "rails", "2.3.14"

please help.

No restore from trash?

I couldnt find a restore from trash so I add the following under

    delete_message()
      def restore_message(message)
        current_user = self

        if message.received_messageable == current_user
            message.update_attributes!(:recipient_delete => false)
        elsif message.sent_messageable == current_user
            message.update_attributes!(:sender_delete => false)
        end
      end

Error with Ancestry

Hi there-

I've installed the acts_as_messagable gem but keep getting the following error:

NoMethodError (undefined method `ancestry' for #ActsAsMessageable::Message:0x00000104576ef8):

Do you have any idea what it might be?

Thanks

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.