简体   繁体   中英

Ransack Gem - Search undefined

I am trying to get Ransack search set up. I have added the gem to the Gem file, run bundle install.

I have then added:

class ProfilesController < ApplicationController

  # GET /profiles
  def index
    @search = Profile.search(params[:q])
    @profiles = @search.result
  end

end

In the index view file I have added: (screenname is a valid field in my profiles table)

<% = search_form_for @search do |f| %>
      <%= f.label :screenname %>
      <%= f.text_field :screenname %>
      <%= f.submit "Search" %>
    <% end %>

(along with some other styles)

However I am getting:

undefined method `search' for #

in app/controllers/profiles_controller.rb:12:in `index'

Any ideas?

Cheers :)

安装gem后应重新启动应用程序服务器。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM