My problem is "simple" yet complicated.
I have a 1:1 relation between user and profile.
User Model: has_one :profile
Profile Model: belongs_to :user
then i have a form to create a new user
<% form_tag('/users/create', :method => :post, :multipart => true) do %>
(...)ok, the fields and submit button work as i get the table user populated with the data from the formbut, it should also create a row in the profile table with the correspondent user_id wich is not
heres my controller code:
def new
@user = User.new
@profile = Profile.new
end
def create
cookies.delete :auth_token
@user = User.new(params[:user])
@profile = @user.build_profile(params[:profile])
@user.save!
render :action => 'verify'
rescue ActiveRecord::RecordInvalid
render :action => 'new'
end
Where am i missing?Is a 1:1 relation that complicated?
i know that with has_many works fine as i tried before
when i create a user it should have a row in user table with the data i inserted (working) and a row in profile table with the user_id and the rest null.
any suggestions? :D