stouset / twitter_bootstrap_form_for

A Rails FormBuilder DSL for generating Twitter Bootstrap forms
https://github.com/stouset/twitter_bootstrap_form_for
MIT License
409 stars 110 forks source link

make it work for objects other than ActiveModel #7

Closed danpersa closed 12 years ago

danpersa commented 12 years ago

For example if I use the session object

<%= twitter_bootstrap_form_for(session, :url => sessions_path) do |f| %>

I get this error:

undefined method `model_name' for Rack::Session::Abstract::SessionHash:Class

stouset commented 12 years ago

You need to add an :as => :session for a normal form_for or twitter_bootstrap_form_for to work without ActiveModel objects. However it looks like I still expect there to be an ActiveModel-style errors attribute.

I'll patch it to make it optional.

stouset commented 12 years ago

This will go out in the next release. Let me know within the next day or so if you still have problems with non-ActiveModel objects. It's possible that I missed a corner case somewhere.

danpersa commented 12 years ago

ok, thanks for the fast reply!

stouset commented 12 years ago

The quickest way to test the patch to make sure it works for you is to replace the gem stanza in your Gemfile with:

gem 'twitter_bootstrap_form_for',
  :git => 'git://github.com/stouset/twitter_bootstrap_form_for.git'
danpersa commented 12 years ago

I verified with the gem generated from the repository, and it works for my use case. I'll notify you if there are further problems related to this issue.

Thanks

stouset commented 12 years ago

I've got another fix to roll into 1.0.2, so this will go out later tonight or tomorrow morning.

stouset commented 12 years ago

Sorry, I completely forgot that this fix was pending a release. I've pushed out 1.0.2 with this change (and a few other improvements)