seyhunak / twitter-bootstrap-rails

Twitter Bootstrap for Rails 6.0, Rails 5 - Rails 4.x Asset Pipeline
https://github.com/seyhunak/twitter-bootstrap-rails
4.5k stars 998 forks source link

devise and simple_form conflict #807

Open caeg0n opened 9 years ago

caeg0n commented 9 years ago

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

toadkicker commented 9 years ago

Can you post how you are using form_for please

caeg0n commented 9 years ago

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

toadkicker commented 9 years ago

You can drop using the instance variable on error span and use only the attribute, or pull the develop branch.

error_span :unity

caeg0n commented 9 years ago

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.

toadkicker commented 9 years ago

I've forked this project and on https://github.com/toadkicker/railsstrap am not having this issue. Don't give up!

sachin87 commented 9 years ago

@K43G0N @toadkicker I am also facing this issue.

devise (3.4.1) simple_form (3.1.0) twitter-bootstrap-rails (3.2.1)

caeg0n commented 9 years ago

solved in toadkicker/railsstrap fork.

sachin87 commented 9 years ago

@K43G0N but i am not using railsstrap.

Draiken commented 8 years ago

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

ellesgaard commented 8 years ago

@Draiken where did you put this code, I can't get it to work :/

Draiken commented 8 years ago

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

gustavobap commented 8 years ago

The initializer don't work for me =/ Why not just generate the form in the new way, like f.error_span :unity ?

Draiken commented 8 years ago

Using f.error_span generates undefined method without explicitly including the form helpers in simple form's FormBuilder

gustavobap commented 8 years ago

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"

epineda commented 8 years ago

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

BabichSA commented 8 years ago

Only downgrade to 'twitter-bootstrap-rails', '3.2.0' helps.

luss613 commented 8 years ago

I also have this problem, and downgrade is worked for me. Thank @BabichSA

BarbaraTieko commented 8 years ago

Thank @BabichSA it worked for me I am very very very grateful.

apsheronets commented 8 years ago

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)
brunoocasali commented 7 years ago

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