Creating a model form inside another model, how to pass 'this'?

I am inside a model, and need to create another model, how to I pass
‘this’
as a parameter?

Example:

class User < AR
has_one :company
def create_associations!
@company = Company.build_with_user(this)
end
end

So I’m trying to create the company association using a method from the
Company model, and pass it a User parameter.

How do I pass ‘this’ in ruby?

self :slight_smile:

On 8 May 2014 16:03, S Ahmed [email protected] wrote:

@company = Company.build_with_user(this)

use self.build_company instead. See
http://guides.rubyonrails.org/association_basics.html#has-one-association-reference

Colin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs