Hobo / hobo

The web app builder for Rails (moved from tablatom/hobo)
http://hobocentral.net
103 stars 39 forks source link

belongs_to association with scope argument crashes hobo #150

Closed stevemadere closed 9 years ago

stevemadere commented 9 years ago

Rails 4 allows (and indeed naggingly demands) that conditions on belongs_to associations are specified with a scope lambda rather than a conditions option. e.g.
belongs_to :pet, conditions: { breed: 'beagle'}, class_name: 'Dog' must become belongs_to :pet, -> { where(breed: 'beagle') }, class_name: 'Dog'

However, the various Hobo and HoboFields alias_method_chain actions on belongs_to nail down the arguments to (name,options = {}). This causes an argument count mismatch error at model load time.

Conversely, several wrapping of has_many include the scope lambda argument for Rails 4 compatibility but are very confusing in a Rails 3 context. They only work in Rails 3 by accident. (options actually go into a parameter called scope)

I am working on a pull request that will fix this and unite all such adaptations for has_many and has_one as well with a consistent and robust solution using variable parameters (*args)

iox commented 9 years ago

Thanks Steve for the nice report, looking forward to your PR!