# Splitting the user into user and user\_profile

**URL:** <https://www.ruby-forum.com/t/splitting-the-user-into-user-and-user-profile/170242>\
**Category:** Rails\
**Created:** [June 14, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/splitting-the-user-into-user-and-user-profile/170242 "2009-06-14T22:40:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arnekolja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arnekolja](https://www.ruby-forum.com/u/arnekolja)\
**Post date:** [June 14, 2009, 10:40pm UTC](https://www.ruby-forum.com/t/splitting-the-user-into-user-and-user-profile/170242/1 "2009-06-14T22:40:40Z")

</div>

Hi there,

I am totally new to Rails, so please forgive me that probably dumb  
question, but I am stuck with the constellation of having a user and a  
user\_profile model.

The idea behind this is to have a user with only the user\_id that  
has\_many user\_profiles and only the newest user\_profile is active.  
This way I can keep track of all user data changes. But it also  
requires me to create a new user and a new user\_profile in one step.

So… do you know a good starting point for doing this? I have set up  
the relationships and tried to work with

\<% u.fields\_for :user\_profile do |p| %\>  
// profile fields here  
\<% end %\>

nested into the user’s default creation form, but I do not know how to  
save it in my action (do I have to add something to my model too?).

So please, any help is welcome and I assure to ask better questions  
next time, lol 🙂

Thanks in advance

Arne

---

<div class="post-metadata">

**Author:** ![arnekolja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arnekolja](https://www.ruby-forum.com/u/arnekolja)\
**Post date:** [June 15, 2009, 6:52am UTC](https://www.ruby-forum.com/t/splitting-the-user-into-user-and-user-profile/170242/2 "2009-06-15T06:52:40Z")

</div>

Hi–

On Jun 14, 2009, at 1:09 PM, arnekolja wrote:

> requires me to create a new user and a new user\_profile in one step.
> 
> So please, any help is welcome and I assure to ask better questions  
> next time, lol 🙂
> 
> Thanks in advance
> 
> Arne

You might want to check this out:

> **[\#73 Complex Forms Part 1 - RailsCasts](http://railscasts.com/episodes/73-complex-forms-part-1)**
>
> Short Ruby on Rails screencasts containing tips, tricks and tutorials. Great for both novice and experienced web developers.

One thing I should mention is that Rails is now supporting a lot of  
cool complex-form types of stuff so also read this:

[http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes](http://ryandaigle.com/articles/2009/2/1/what-s-new-in-edge-rails-nested-attributes)

Hope this helps.

---

<div class="post-metadata">

**Author:** ![arnekolja](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ee7513/32.png) [@arnekolja](https://www.ruby-forum.com/u/arnekolja)\
**Post date:** [June 15, 2009, 7:33pm UTC](https://www.ruby-forum.com/t/splitting-the-user-into-user-and-user-profile/170242/3 "2009-06-15T19:33:11Z")

</div>

If you are versioning records, as in your UserProfile, then you may  
want to consider a plugin that does this for you. Consider this:

> **[GitHub - technoweenie/acts\_as\_versioned: ActiveRecord plugin for versioning your...](https://github.com/technoweenie/acts_as_versioned/tree/master)**
>
> master

HTH,  
Nicholas
