English 中文(简体)
制控器中所有制成的未定方法
原标题:MetaSearch undefined method all in controller

我不想在我的铁路3号卫星上与梅塔斯群岛进行搜索。 然而,当我开始在251号铁路预测之后,Im已在我的用户冷却指数行动中找到一种未界定的方法。 这部法典:

def index
  @search = User.search(params[:search])
  @users = @search.all
end

The start of my form:

<% form_for :search, @search, :html => {:method => :get} do |f| %>
  <%= f.label :high_school_contains %>
  <%= f.text_field :high_school_contains %><br />
  <%= f.submit %>
<% end %>

在Gemfile:

gem  meta_search 

Both Ryan and Ernie Miller recommend code along those lines in the index action, but something is obviously wrong. Any ideas on what it could be?

最佳回答

你们是否使用其他搜索办法,如思潮或确定模型中的搜索方法? 如果是,它首先界定了搜索方法,并使用这种方法,源代码:

alias_method :search, :metasearch unless respond_to?(:search) 

因此,你需要使用计量方法:

@search = User.metasearch(params[:search])
问题回答

暂无回答




相关问题
Remove ActiveRecord in Rails 3

Now that Rails 3 beta is out, I thought I d have a look at rewriting an app I have just started work on in Rails 3 beta, both to get a feel for it and get a bit of a head-start. The app uses MongoDB ...

When will you upgrade your app to Rails 3? [closed]

Now that the Rails 3 beta is here, let s take a little straw poll. Please tell us briefly what your application does and when you will upgrade it to Rails 3. Or, if you re not planning on upgrading ...

Bundler isn t loading gems

I have been having a problem with using Bundler and being able to access my gems without having to require them somewhere, as config.gem used to do that for me (as far as I know). In my Rails 3 app, I ...

bypass attr_accessible/protected in rails

I have a model that, when it instantiates an object, also creates another object with the same user id. class Foo > ActiveRecord::Base after_create: create_bar private def create_bar Bar....

concat two fields activerecord

I m so used to oracle where you can simply concat(field1, , field2) but if I m using activerecord to find the field1 and field2, and I need a space in between, how do I accomplish this? Cheers ...

热门标签