twitter-bootstrap-rails
twitter-bootstrap-rails copied to clipboard
devise and simple_form conflict
with simple_form show me a error in line <%= error_span(@information[:unity]) %> with description: undefined local variable or method `object' for #<#Class:0x000000061ac740:0x000000064307a0> on partial view file _form.html.erb
Can you post how you are using form_for please
this a complete form generated by scaffold i run the bootstrap:layout and bootstrap:themed too
<%= simple_form_for @information, :html => { :class => 'form-horizontal' } do |f| %> <%= f.input :unity %> <%= error_span(@information[:unity]) %> <%= f.input :slogan %> <%= error_span(@information[:slogan]) %> <%= f.input :address %> <%= error_span(@information[:address]) %> <%= f.input :owner %> <%= error_span(@information[:owner]) %> <%= f.input :phone %> <%= error_span(@information[:phone]) %> <%= f.input :mail %> <%= error_span(@information[:mail]) %>
<%= f.button :submit, :class => 'btn-primary' %> <%= link_to t('.cancel', :default => t("helpers.links.cancel")), information_index_path, :class => 'btn btn-default' %> <% end %>
You can drop using the instance variable on error span and use only the attribute, or pull the develop branch.
error_span :unity
right toadkicker but i think that a gem can't generate wrong code. i having too many problems with this gem. i give up to use it with the gems Devise and Simple Form.
I've forked this project and on https://github.com/toadkicker/railsstrap am not having this issue. Don't give up!
@K43G0N @toadkicker I am also facing this issue.
devise (3.4.1) simple_form (3.1.0) twitter-bootstrap-rails (3.2.1)
solved in toadkicker/railsstrap fork.
@K43G0N but i am not using railsstrap.
For anyone who cares, I've managed to fix the problem with this on an initializer:
if defined?(SimpleForm::FormBuilder)
SimpleForm::FormBuilder.send(:include, FormErrorsHelper)
end
The helper is included into the rails' form builder and simple_form extends it, so I'm not sure why this happens (maybe depends on the order of the gem loading?), but this ensures the form builder simple form uses has the method
@Draiken where did you put this code, I can't get it to work :/
I've put it into an initializer.
Twitter bootstrap rails adds the error helpers to the Rails' FormBuilder
, but SimpleForm uses his own form builder on top of it, creating the conflict.
If this doesn't work, I'm not sure what else could be done, other than taking a look at both gems and producing a real fix
The initializer don't work for me =/ Why not just generate the form in the new way, like f.error_span :unity ?
Using f.error_span
generates undefined method
without explicitly including the form helpers in simple form's FormBuilder
You mean f.error_span only works with simple_form ? It works for me using devise and simple_form and no change in intializers. I installed the gem this way: gem "twitter-bootstrap-rails", :git => "https://github.com/seyhunak/twitter-bootstrap-rails.git", :branch => "master"
I also have this problem.
I'm using:
devise (3.5.3) simple_form (3.2.0) twitter-bootstrap-rails (3.2.2)
what can I do?
thank you in advance for any help...
Only downgrade to 'twitter-bootstrap-rails', '3.2.0' helps.
I also have this problem, and downgrade is worked for me. Thank @BabichSA
Thank @BabichSA it worked for me I am very very very grateful.
It helps, but not for rails 5:
twitter-bootstrap-rails (= 3.2.0) was resolved to 3.2.0, which depends on
railties (~> 4.1)
When I've generated was like this:
= error_span(@information[:slogan])
And I changed to:
= f.error_span(:slogan)
And worked!
Rails 5, devise + simple_form + bootstrap templates