Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes ArgumentError search scope #70

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/acts-as-messageable/scopes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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}%")}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [147/80]
Use the new Ruby 1.9 hash syntax.
Space missing after comma.
Space missing inside }.

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
Expand Down
2 changes: 1 addition & 1 deletion spec/acts-as-messageable_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down