Undefined method search_form_for for ransack gem

739 views
Skip to first unread message

Puneet Pandey

unread,
Aug 25, 2015, 6:48:33 AM8/25/15
to bangalorerug
Hi Folks,

Hope you guys are doing good!

I am using ransack gem in my project and while generating the form for it, I am getting "undefined method 'search_form_for' for Class Object"

Here's the code snippet:

#Gemfile
gem "ransack"

#{PATH_TO_APP}/vendor/engines/my_engine/app/controllers/home_controller.rb
class HomeController < ApplicationController
  def index
    @search = User.ransack( params[:q] )
  end
end

#{PATH_TO_APP}/vendor/engines/my_engine/app/views/home/index.html.erb
<%= search_form_for @search, url: my_url, method: :post do | f | %>
  <%= f.submit "Search" %>
<% end %>

​Am I missing something here?

Thanks in advance for the help!​


​Regards,​

Puneet Pandey
Technical Specialist
NOIDA/INDIA - 201301
B:
My Blog
 
 
Linkedin Profile | GitHub Profile

Puneet Pandey

unread,
Aug 25, 2015, 6:55:28 AM8/25/15
to bangalorerug
In addition to my last email, environment details are:

Ruby: 1.9.3
Rails: 3.2.13
Ransack: 1.7.0

--

Puneet Pandey

unread,
Aug 25, 2015, 8:37:47 AM8/25/15
to bangalorerug
So, after troubleshooting this in depth, I found that, Ransack form helpers were not getting called inside views. So, in application_helper.rb, I called it explicitly:

module ApplicationHelper
  include Ransack::Helpers::FormHelper
end


Reply all
Reply to author
Forward
0 new messages