Creation of owned model

2010/05/10 at 6:53 pm (Hobo, Programming, Ruby on Rails, WebApplication)

I didn’t use owner actions because they are designed to take owner as parameter and I want current_user to always be owner of created object. Solution for that is quite simple. Luckily hobo_new takes a parameter – a record to be created.
def new
hobo_new Friend.new(:owner => current_user)
end

Does exactly what I needed.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: