-
Notifications
You must be signed in to change notification settings - Fork 352
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
control_group method fails on nested attributes in serialized attributes #23
Comments
I think you misunderstood the usage of Here is an explanation of what is I'll close this issue now but if you have any other doubt ask me! |
I'm sorry: I didn't provide enough specificity in my issue report. I'm not calling When that chain of methods executes on a key/value pair within a serialized hash (via fields_for), your code for |
Let me know if you need a stack trace or full example code. |
Hm yes, it would be nice if you create a gist with a stack trace and an example code 😉 |
Thanks. I'm taking a look at this now. I believe it may have been fixed in the 1.0 release, but I want to verify (from the stack trace, I see you're using 0.3.2). |
Ah, thank you so much. We're on Rails 3—is the 1.0 release only for Rails 4? |
You should be fine on 1.0 (I should note this in the README). In Rails 4, sending a block to FormBuilder.new is deprecated. To handle this, we just default the block to nil: https://github.com/potenza/bootstrap_form/blob/master/lib/bootstrap_form/form_builder.rb#L10 I also created a Rails 3 test project with bootstrap_form 0.3.2 and was able to reproduce the error. Upgrading to 1.0 fixed it. FYI, I had to explicitly set the text_field values to pull them from the preferences hash: <%= bootstrap_form_for @user do |f| %>
<%= f.text_field :email %>
<%= f.fields_for :preferences do |builder| %>
<%= builder.text_field :favorite_color, value: @user.preferences[:favorite_color] %>
<%= builder.text_field :favorite_animal, value: @user.preferences[:favorite_animal] %>
<% end %>
<% end %> If you know the keys in advance, it might be simpler to define getters/setters for the preferences keys and skip fields_for altogether. |
I'm gonna close this for now, but let me know if you're still having issues. Thanks! |
The control_group method calls
object.errors
, which will fail if object is nil, or if object doesn't respond to errors.This is valid Rails form syntax, which fails under bootstrap_form_for:
The text was updated successfully, but these errors were encountered: