i have used two model club and user in one form but validation doesn't
call for child model even i have written validates_associated :user in
parent model..when i fill information for user and don't fill for club
then validations are called for club but user is saved which i don't
want..so please help me..
(e.g. @club = Club.new
@user = @club.users.build(params[:user]) for one(club) to many(users)
relations)
and in view page
specify <%= error_messages_for :club, :user%>
Hope this might help.
Saurabh
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..
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..
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..
hi if i don't fill any field then error messages are displayed for both
the model but also one message "club nil" as i wrote
validates_associated :club, :message => 'nil' in users model..and if i
fill data only for user model and don't fill for club model then
validation called for club with message "club nil" and user doesn't
save... and when i fill information for club model and not for user
model then only users model's validation are called without that "club
nil" message..
so now only remaining thing is to remove that message display "club
nil"..as its work perfectly now..but thing is to now have to remove that
"club nil" message..
hi if i don't fill any field then error messages are displayed for both
the model but also one message "club nil" as i wrote
validates_associated :club, :message => 'nil' in users model..and if i
fill data only for user model and don't fill for club model then
validation called for club with message "club nil" and user doesn't
save... and when i fill information for club model and not for user
model then only users model's validation are called without that "club
nil" message..
so now only remaining thing is to remove that message display "club
nil"..as its work perfectly now..but thing is to now have to remove that
"club nil" message..
hey can u tell me if i write validates_associated :club in users model
then when i don't fill information for club then message is displayed
"club nil" or "club is invalid" so how can i remove this message??
if i write validates_associated :club, :message => 'nil' then club nil
message is displayed on validation called..
and if i write validates_associated :club, :message => nil then club is
invalid message is displayed on validations called..
method after_validation collects all the error messages of club model
and rejects the first error message, which is "club is invalid" and
collects the remaining messages into variable and adds them to the error
list.
Saurabh
hey hello!!
you are not wrong this code is working properly as u told..