So, I now tried everything possible and the only thing that worked was upgrading to Rails 3.1 or newer. So my recommendation for everyone using 3.0.15 or lower would be not to try this Railscast as it seems not to work. The problem must be somewhere with the render command in the link_to_add_fields method.
First of all thanks for the great Episode. But I have two problems:
1) The Dropdown List of how to filter is abbreviated. As example it doesn't say "greater than or equal", but instead says "gte" and I didn't find any configurations on how to change this.
2) And this is a real problem: The javascript code won't work. I can only remove a field, but not add one. So I will always have at least one field, but I can never add one. I tried the Coffeescript code with Barista in my 3.0 app and also translated it to jQuery and tried if with that, but it never worked. Any ideas?
1) If I try to reindex my objects, rails throws the following at me: rake aborted!
undefined method 'paginate' for #<Class:0x00000106e32310>
I'm using Kaminari, so maybe it's because of that.
2) After including query do and boolean do I don't get any of my objects shown. Neither with nor without search term. I also don't get any errors, they just don't show up.
The first one is not a problem, but the second one really bothers me, so any help would be appreciated.
So, I now tried everything possible and the only thing that worked was upgrading to Rails 3.1 or newer. So my recommendation for everyone using 3.0.15 or lower would be not to try this Railscast as it seems not to work. The problem must be somewhere with the render command in the link_to_add_fields method.
So, I tried almost everything I know and still can't get the add_field javascript to work. Barista translates it to the following code:
And Firebug gives me this error:
TypeError: $(this).data("fields") is undefined
I would really appreciate any help or hints.
Okay, I found the solution to my first problem. I didn't include the .yml translation file, which you can see here:
https://github.com/ernie/ransack/blob/master/lib/ransack/locale/en.yml
But I still haven't figured out why the add_field doesn't work...
First of all thanks for the great Episode. But I have two problems:
1) The Dropdown List of how to filter is abbreviated. As example it doesn't say "greater than or equal", but instead says "gte" and I didn't find any configurations on how to change this.
2) And this is a real problem: The javascript code won't work. I can only remove a field, but not add one. So I will always have at least one field, but I can never add one. I tried the Coffeescript code with Barista in my 3.0 app and also translated it to jQuery and tried if with that, but it never worked. Any ideas?
Two quick comments:
1) If I try to reindex my objects, rails throws the following at me:
rake aborted!
undefined method 'paginate' for #<Class:0x00000106e32310>
I'm using Kaminari, so maybe it's because of that.
2) After including
query do
andboolean do
I don't get any of my objects shown. Neither with nor without search term. I also don't get any errors, they just don't show up.The first one is not a problem, but the second one really bothers me, so any help would be appreciated.
I also got it working, but Rails can't recognize dates anymore:
"Object must be a Date, DateTime or Time object. "2011-12-22" given."
But as you can see, it is in the normal date format.
Edit: Found the error myself. Rails wanted an extra ".to_date"