Using Ransack with Enumerize
Not solved Solved
12 months ago

Hi! I have trouble with Ransack : I'm trying to make a search bar as a dropdown list. I have this in my pros_controller:

def index @q = Pro.ransack(params[:q].to_yaml) @pros = @q.result end

and this in my view :


<%= searchformfor @q, url: prosurl do |f| %> <%= :jobscont, %> <%= f.submit "Search" %> <% end %>

We used enumerize to create a list of jobs. At first I had this error : "Attribute was supposed to be a Array, but was a String". I added .to_yaml in the controller and that fixed it but the search still doesn't work, it renders all pros and there is this line in my console : Pro Load (1.4ms) SELECT "pros".* FROM "pros"

I don't understand why the SQL query doesn't work entirely. I spent a LOT of time on this and if you have an idea, that would be great! Thanks :)

Submit your answer