diff --git a/README.md b/README.md index 25fb01ecf..4399251b8 100644 --- a/README.md +++ b/README.md @@ -350,7 +350,7 @@ Search ## Search text from messages ```ruby -@alice.messages.search("Search me") @alice seach text "Search me" from all messages +@alice.messages.text_search("Search me") @alice seach text "Search me" from all messages ``` Copyright © 2011-2012 Piotr Niełacny (http://ruby-blog.pl), released under the MIT license diff --git a/lib/acts-as-messageable/scopes.rb b/lib/acts-as-messageable/scopes.rb index fd0f4ff10..bde2bf14d 100644 --- a/lib/acts-as-messageable/scopes.rb +++ b/lib/acts-as-messageable/scopes.rb @@ -12,7 +12,7 @@ module ClassMethods def initialize_scopes scope :are_from, lambda { |*args| where(:sent_messageable_id => args.first, :sent_messageable_type => args.first.class.name) } scope :are_to, lambda { |*args| where(:received_messageable_id => args.first, :received_messageable_type => args.first.class.name) } - scope :search, lambda { |*args| where("body like :search_txt or topic like :search_txt",:search_txt => "%#{args.first}%")} + scope :text_search, lambda { |*args| where("body like :search_txt or topic like :search_txt",:search_txt => "%#{args.first}%")} scope :connected_with, lambda { |*args| where("(sent_messageable_type = :sent_type and sent_messageable_id = :sent_id and sender_delete = :s_delete and sender_permanent_delete = :s_perm_delete) or diff --git a/spec/acts-as-messageable_spec.rb b/spec/acts-as-messageable_spec.rb index b313cef8e..7f34e7d52 100644 --- a/spec/acts-as-messageable_spec.rb +++ b/spec/acts-as-messageable_spec.rb @@ -246,7 +246,7 @@ end it "bob should be able to search text from messages" do - recordset = @bob.messages.search("I am fine") + recordset = @bob.messages.text_search("I am fine") recordset.count.should == 1 recordset.should_not be_nil end