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

undefined method `result' for []:ActiveRecord::Relation #266

Closed
zeroed opened this issue Aug 6, 2013 · 5 comments
Closed

undefined method `result' for []:ActiveRecord::Relation #266

zeroed opened this issue Aug 6, 2013 · 5 comments

Comments

@zeroed
Copy link

zeroed commented Aug 6, 2013

Hi.

I'm following the simple steps in the readme but I receive this error when i try to open the page.

undefined method  'result'  for []:ActiveRecord::Relation

In my controller:

def index
  @search = Book.search(params[:q])
  @catalog = @search.result
end

In my view:

= search_form_for @search do |f|
  .field
    = f.label :title_cont, "Title contains"
    = f.text_field :title_cont
  .actions= f.submit "Search"

With:

    ransack (0.7.2)
      actionpack (~> 3.0)
      activerecord (~> 3.0)
      polyamorous (~> 0.5.0)

What could be the reason of this error? If I create a new application from scratch I do not have this problem ...

Thank you so much.

@jonatack
Copy link
Contributor

jonatack commented Aug 6, 2013

@zeroed try using a newer version of polyamorous (0.6.0 or 0.6.3).

@nijikon
Copy link

nijikon commented Aug 6, 2013

At first glance it looks like @search is not Ransack::Search, you need to check why.

@zeroed
Copy link
Author

zeroed commented Aug 6, 2013

Thank you @nijikon ... your first glance was correct.

I have another gem that override the search method... (sigh).

Thank you both...

@zeroed zeroed closed this as completed Aug 6, 2013
@seanlinsley
Copy link
Contributor

@zeroed in case you didn't know, you can always use the ransack method if other gems override the search method.

@zeroed
Copy link
Author

zeroed commented Aug 6, 2013

^_^
Interesting!
Thanks @daxter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants