Saurabh Peshkar wrote:
>> hi Saurabh
>> 
>> there is one-to-one relationship between club and user..
>> and in club model i have used both
>> validates_associated :user
>> validates_presence_of :user_id, :message => nil
>> then also it is not working..
>> 
>> and in view page i already specified error_messages_for..
> 
> Ok,
> 
> Try this,
> 
> def create
>  @club = Club.new(params[:club])
>  @user = @club.build_user(params[:user])
> 
>  if @club.valid?
>   @club.save
>  end
> 
> end

 hi Saurabh

but i don't need to write @user.save any where?


> 
> This will check if both are valid or not and save them at same time, if 
> any one of them is invalid nothing gets saved.
> 
> Saurabh.

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to