user1847224
user1847224

Reputation:

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 :)

Upvotes: 2

Views: 3474

Answers (1)

Vasiliy Ermolovich
Vasiliy Ermolovich

Reputation: 24637

You should restart your application server after installing gem.

Upvotes: 19

Related Questions