lte / acts-as-messageable Goto Github PK
View Code? Open in Web Editor NEWGem that allows communication between the models.
Home Page: http://lte.github.io/acts-as-messageable/
License: MIT License
Gem that allows communication between the models.
Home Page: http://lte.github.io/acts-as-messageable/
License: MIT License
Currently doesn't work because of the ActiveRecord and ActiveSupport 3.0 requirement.
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
sorry, it caused by another gem.
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.
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.
# 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'
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
Is there a way to find the conversations between two users?
Thanks in advance
Is there a way to retrieve the list of conversations ordered by last answered?
Thanks.
User should be able to remove messages from trash.
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>
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 add
protected_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:in
module: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:in
const_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:in
each'
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:in
constantize'
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:in
acts_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:in
block 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:in
load_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:in
load_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:in
const_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:in
each'
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:in
constantize'
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:in
constantize'
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:in
to'
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:in
routes'
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:in
initialize'
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:in
add_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:in
each'
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:in
block 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:in
eval_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:in
block 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:in
load'
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:in
each'
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:in
reload!'
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:in
call'
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:in
updater'
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:in
block 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:in
run'
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:in
block 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:in
each_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:in
each'
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:in
tsort_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:in
initialize!'
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:in
block 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:in
require'
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)>'
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
Hi,
Is there a way to add attachments to conversation while sending replies similar to facebook ?
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.
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 have the following:
u1.send_message(u2, {:body => "body", :topic => "topic"})
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?
My messages aren't just straight messages, I also pass along an account name and sometimes build as a nested-attribute a contact.
Is that possible to do?
in the example controller page:
https://github.com/LTe/acts-as-messageable/wiki/Example-controller
def show
@message = current_user.messages.with_id(params[:id])
end
We have to get the first element like this one => @message = current_user.messages.with_id(params[:id]).first
Or @message is null. Maybe you can also correct this..
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.
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.
I have the following:
u1.send_message(u2, {:body => "body", :topic => "topic"})
u1.messages
>>[]
If I send a message, the user that sent the message shows no message.
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 add
protected_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:in
class: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
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.
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
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
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
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
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
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
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
@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
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
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)
Refactor specs, should be more DRY.
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
@mother.send_message(@son, "How are you?")
@mother.send_message(@son, "How was the party? Did you enjoy?", "Party")
@mother.send_messages(@son, :body => "How was the party?", :topic => "Party")
Personally I'd choose 2) as it's more flexible.
openfirmware / acts-as-messageable depends on activerecord 3 or newer but my rails 2.3.14 depends on activerecord 2.3.14 ONLY.
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.
@alice.messages.with_id(@id_of_message) # message with id id_of_message
error: undefined method `with_id'
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
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
Thanks @masa-iwasaki for great fix 19cf377
How can I display, facebook style, the entire thread of a message including the replies?
I have in my message model a belongs_to association that doesn't appear to work......am I limited to the asociations through the gem?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.