Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError - can't convert Fixnum to String #526

Closed
linko opened this issue Apr 12, 2013 · 3 comments
Closed

TypeError - can't convert Fixnum to String #526

linko opened this issue Apr 12, 2013 · 3 comments

Comments

@linko
Copy link

linko commented Apr 12, 2013

I got this error here

https://github.com/bcardarella/client_side_validations/blob/3-2-stable/lib/client_side_validations/action_view/form_builder.rb#L98

child_index = @options[:child_index] ? "(\\d+|#{Regexp.escape(@options[:child_index])})" : "\\d+"

with the @options[:child_index] value equal to 70250948893180 (added debug output into gem file)

if I just add .to_s like this

child_index = @options[:child_index] ? "(\\d+|#{Regexp.escape(@options[:child_index].to_s)})" : "\\d+" 

the problem is solved. What is a best solution for this? Or can I force cast .to_s on that option?

Here is a trace:

  (gem) client_side_validations-3.2.5/lib/client_side_validations/action_view/form_builder.rb:99:in `escape'
  (gem) client_side_validations-3.2.5/lib/client_side_validations/action_view/form_builder.rb:99:in `build_validation_options'
  (gem) client_side_validations-3.2.5/lib/client_side_validations/action_view/form_builder.rb:75:in `collection_select_with_client_side_validations'
  (gem) simple_form-2.0.4/lib/simple_form/inputs/collection_select_input.rb:7:in `input'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:29:in `block in render'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:27:in `each'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:27:in `render'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:29:in `block in render'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:27:in `each'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/many.rb:27:in `render'
  (gem) simple_form-2.0.4/lib/simple_form/wrappers/root.rb:15:in `render'
  (gem) simple_form-2.0.4/lib/simple_form/form_builder.rb:116:in `input'
  (gem) client_side_validations-simple_form-2.0.1/lib/client_side_validations/simple_form/form_builder.rb:29:in `input_with_client_side_validations'
 app/views/application/_medium_classification.html.haml:2:in `_app_views_application__medium_classification_html_haml__1927438638199952841_70250948595540'

The code which raises this error.

= f.simple_fields_for :medium_classifications, validate: false do |builder|
  = render 'medium_classification', f: builder 

and _medium_classification.rb below

.sub
  - collection = @products || []
  = f.input :product_id, collection: collection.collect{|x| [x.title.gsub(' ', ' '), x.id]}, label: false, prompt: 'Select One or More'
  = link_to_remove_fields("Remove", f)

Gemfile

simple_form (2.0.4)
client_side_validations (3.2.5)
client_side_validations-simple_form(2.0.1)
jacklynrose pushed a commit to jacklynrose/client_side_validations that referenced this issue Apr 14, 2013
bcardarella added a commit that referenced this issue Apr 14, 2013
@linko
Copy link
Author

linko commented Apr 15, 2013

@bcardarella @fluffyjack Thank you guys

@fluffyjack I think that my grandma could do better this fix

@jacklynrose
Copy link

Haha she probably could but your suggestion was simple and worked for now and I needed to get on with what I was doing instead of fighting bugs in my gems :) I'm sure @bcardarella will work out a better solution

@tagliala
Copy link
Contributor

Hi,

I'm shutting down old issues.

If it still is an issue, feel free to open a new one but make sure it meets our Contributing Guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants