RailsCasts Pro episodes are now free!

Learn more or hide this

Alex's Profile

GitHub User: kakubei

Comments by Alex

Avatar

I second the warning aboiut Searchlogic not working with Rails 3. Took me a while to figure this one out, and I had gotten all excited about using it too :(

It produces this error:

error [long path] 'alias_method': undefined method merge_joins' for classClass' (NameError)

Avatar

Turns out that the field expects the values to be an array and in a many to one the result is a string so I've amended the code to this in the form:

Rails
        = f.input :format_tokens, :input_html => { :data => { :load => [@book.format] } }

Which does list the entry properly, but even if I add another one, it will not save it. The resulting json list is in proper array format (I can see it with: http://localhost:3000/list_formats.json?q=hard), so I'm still missing something.

Thanks.

Avatar

I was able to create the relationship with a many to many, but with a many to one (where the book table has a corresponding ID for the format table for example) it doesn't work.

I can search but it will not save the values, nor will it prepolue the existing ones.

I'm sure I'm doing something wrong, but I pretty much copy/pasted the one for authors. Is there anything else that needs to change for this to work?

I don't get any javascript errors or warnings whatsoever.

Thanks.

Avatar

Please disregard, I was being an idiot and my method in book.rb had this

def author_tokens(tokens)

Instead of this:

def author_tokens=(tokens)
Avatar

I tried this as well and I get the same error. I even tried this:

Rails
 f.input :author_tokens, :input_html => { "data-pre" => @book.author.collect{ |author| { :id => author.id } } }.to_json
Avatar

Hello, I get this error when trying to create the author_token field using simple_form:

wrong number of arguments (0 for 1)

The funny thing is I get that error even if I do this:

rails
= f.input :author_tokens, :data => '1,2'

Seems that no matter what I put into :data => I keep getting this error. I even get it if I don't use simple_form but the regular form_for tag. I should mention that I'm using Ruby 1.8.7 if that makes any difference.

Help please.

Avatar

I'm also getting this error:

wrong number of arguments (0 for 1)

using simple_forms, even with your syntax above which, by the way, has a small typo, the last closing parentheses should be a curly brace.

Funny enough, I get this same error even if I don't use simple forms, just a regular form_for tag.

Any help would be greatly appreciated.