Fork me on GitHub

GetOrBuild by ka8725

Association builder for belongs_to and has_one association

This is a gem which will help you to avoid duplicated code like

f.object.user || f.object.build_user
for belongs_to and has_one association. Use
f.object.user_or_build
instead of this piece of code. There is no longer reason to type stupid duplicated code like
f.object.user || f.object.build_user
! Also you are able to call
f.fields_for :user, :build_association => true
and that's it - you will have new builded associatiated object user if it doesn't exist yet.

Dependencies

None

Install

Add line gem 'get_or_build' to your Gemfile

License

Open Source

Authors

Andrey Koleshko (ka8725@gmail.com)

Contact

Email: ka8725@gmail.com
Skype: kaleshka.a

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/ka8725/get_or_build

"