Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [validates-associated]

The tag has no usage guidance.

validates-associated
0 votes
0 answers
34 views

HABTM relationship / validates associated: valid? is true even though I don't think it is

I made the following join table to be used in a HABTM relationship between tasks and itself: create_table :tasks_tasks, id: false do |t| t.belongs_to( :dropoff_task, null: false, ...
rwg05's user avatar
  • 127
0 votes
1 answer
75 views

Validates_overlap custom message?

i try the gem validates_operator. I need to custom my message for this validation: validates :arrival_date, :departure_date, overlap: { scope:"place_id", message_title: "Error", ...
Thomas Birien's user avatar
1 vote
1 answer
565 views

cakephp multiple select not working

I have two tables 'businesses' and business_categories and their association is like BusinessesTable.php $this->hasMany('SellerBusinessCategories', [ foreignKey => 'business_id' ]); and I ...
Anuj TBE's user avatar
  • 9,632
1 vote
3 answers
870 views

Rails 4 form - text field value must match a value in an associated table (autocomplete)

I have two associated models/tables app/models/city.rb has_many :businesses Fields: id, city_name, state_code app/models/business.rb belongs_to :city Fields: id, biz_name, address, city_name, ...
Steve Carey's user avatar
  • 3,016
0 votes
1 answer
363 views

has_one validates_associated firing inconsistently despite 'on: :create'

I'm seeing really weird behaviour when checking valid? on a model that has a validates_associated :contact, on: :create. If I make two calls to valid? the first is true and the second is false. This ...
jim's user avatar
  • 1,025
2 votes
1 answer
2k views

Using :autosave for has_one association: How to show the parent's errors when on the child's controller?

I have created a model that looks like this: class Parent < ActiveRecord::Base attr_accessible :child, :child_id has_one :child, :class_name => 'Child', :autosave => true, :inverse_of =&...
Mauricio Moraes's user avatar
2 votes
1 answer
78 views

Rails : Displaying associated model validations

I have got three models class RateCard < ActiveRecord::Base validate :name, :presence => true, :uniqueness => true has_many :rate_card_countries, :dependent => :destroy has_many :...
Sumit Rai's user avatar
  • 637
1 vote
2 answers
3k views

ActiveModel: Disable failing validation when associated models fail

Does Rails3 always run validates_associated against all models by default? In a simple setup like this class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::...
user545139's user avatar
1 vote
1 answer
201 views

activerecord validation - validates_associated

I'm unclear on what this method actually does or when to use it. Lets say I have these models: Person < ... # id, name has_many :phone_numbers end PhoneNumber < ... # id, number ...
recursive_acronym's user avatar
12 votes
2 answers
8k views

validates_associated not checking existence of associations

Can anyone figure out what's going on here? I was able to get my code to work the way I want it to, but I can't figure out why validates_associated isn't working as I expect. Here's a snippet of my ...
Eric Hu's user avatar
  • 18.1k
18 votes
4 answers
9k views

Better validates_associated method for Rails 3?

Rails 3 includes the validates_associated which is automatically called when saving a nested model. The problem with the method is the message is terrible - "Model(s) is invalid" There have been a ...
Tony's user avatar
  • 19k