Fix for issue #332 #393

Closed
wants to merge 5 commits into
from

Projects

None yet

4 participants

@bjornblomqvist

Fix for issue #332

bjornblomqvist added some commits Dec 12, 2011
@bjornblomqvist bjornblomqvist Added the macro method from ActiveRecord::Reflection::MacroReflection…
… to make Formtastic happy.

This makes it possible to use mongomappers "many" in combination with Formtastics ":collection => ...".

<%= form.input :themes ,:as => :select, :collection => Theme.all %>
4d83cac
@bjornblomqvist bjornblomqvist Revert "Added the macro method from ActiveRecord::Reflection::MacroRe…
…flection to make Formtastic happy."

This reverts commit 4d83cac.
b7343ae
@bjornblomqvist bjornblomqvist Merge branch 'master' of git://github.com/jnunemaker/mongomapper a64d67e
@bjornblomqvist bjornblomqvist Adding test to trigger issue #332
mongomapper#332 (comment).

form_for in rails expects doc.#{name}_before_type_cast to retun the default value.
ff10c56
@bjornblomqvist bjornblomqvist fix for Issue #332 f6d559b
@bearded

👍

@jnunemaker

Seems like it would be better to just make sure that attributes with defaults are always set in initialize. That is what I did in toy store.

https://github.com/jnunemaker/toystore/blob/master/lib/toy/attributes.rb#L29-33
https://github.com/jnunemaker/toystore/blob/master/lib/toy/attributes.rb#L102-107

Thoughts?

@bjornblomqvist

Two thoughts.

1) Setting defaults on initialize makes sure that defaults like bellow behaves the way people exepct it to (Set on initalize).

:default => lambda { Time.now }

2) Setting them on initialize makes new just a tiny bit slower.

I think setting it on initialize is the better way to do it.

@bkeepers

Thanks for the pull request! I'm going to close this one for now, but I'd love to see this fixed. Please open another pull request that sets them on initialize.

Thanks!

@bkeepers bkeepers closed this Mar 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment