Quantcast
Viewing all articles
Browse latest Browse all 42

Rails - Best-Practice: How to create dependent has_one relations

What's the best practice to create has_one relations?

For example, if I have a user model, and it must have a profile...

How could I accomplish that?

One solution would be:

# user.rbclass User << ActiveRecord::Base  after_create :set_default_association  def set_default_association    self.create_profile  endend

But that doesn't seem very clean... Any suggestions?


Viewing all articles
Browse latest Browse all 42

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>