Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

schneider-th's Profile

GitHub User: schneider-th

Comments by

Avatar

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.

Avatar

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:

javascript
(function(){

  jQuery(function($) {
    $('form').on('click', '.remove_fields', function(event) {
      $(this).closest('.field').remove();
      return event.preventDefault();
    });
    return $('form').on('click', '.add_fields', function(event) {
      var regexp, time;
      time = new Date().getTime();
      regexp = new RegExp($(this).data('id'), 'g');
      $(this).before($(this).data('fields').replace(regexp, time));
      return event.preventDefault();
    });
  });

}).call(this);

And Firebug gives me this error:

TypeError: $(this).data("fields") is undefined

I would really appreciate any help or hints.

Avatar

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...

Avatar

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?

Avatar

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 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.

Avatar

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"