Attribute name with cont not accepted with ransack

331 Views Asked by At

I want to search for values like a specialty name attribute but it has not been working. I have been getting this error:

NoMethodError in Specialties#index
Showing C:/Users/surak/Pictures/groups/SD_Project_Website/app/views/specialties/index.html.erb where line #5 raised:

undefined method `SpecialtyName_cont' for #<Ransack::Search:0x000001cc33fd4598>

These are my ransackable attributes:

irb(main):001:0> Specialty.ransackable_attributes
=> ["id", "SpecialtyName", "created_at", "updated_at"]

I have been getting this error, trying to find the right name for the cont prefix, and have tried specialty_specialtyname_cont and specialtyname_cont, as well as SpecialtyName_cont

This is my code: index.html.erb:

<%= search_form_for @q do |f| %>
 <%= f.label :SpecialtyName_cont, 'Group ID' %>
 <%= f.search_field :SpecialtyName_cont %>
 <%= f.submit %>
<% end %>

controller:

  # GET /specialties or /specialties.json
  def index
    @q = GroupAssignment.ransack(params[:q])
    @specialties = @q.result
  end
0

There are 0 best solutions below