In my case, it was sufficient to use validates_length_of
:
class Album
has_many :photos
validates_length_of :photos, maximum: 10
end
class Photo
belongs_to :album
validates_associated :album
end
More Related Contents:
- ActiveRecord OR query
- ActiveRecord Query Union
- Rails routing to handle multiple domains on single application
- Rails where condition using NOT NIL
- How to get Twitter-Bootstrap navigation to show active link?
- Deprecated warning for Rails 4 has_many with order
- OpenSSL::SSL::SSLError on Heroku [duplicate]
- Float vs Decimal in ActiveRecord
- ruby/ruby on rails memory leak detection
- How can I uninstall Ruby on ubuntu?
- Overriding id on create in ActiveRecord
- What does Rails 3 session_store domain :all really do?
- Rails: Can’t verify CSRF token authenticity when making a POST request
- Convert Time from one time zone to another in Rails
- Ruby on Rails — multiple selection in f.select
- Ruby on Rails : symbol as argument in form_for
- How do I display Ruby on Rails form validation error messages one at a time?
- Grouping by week/month/etc & ActiveRecord?
- Docker: Is the server running on host “localhost” (::1) and accepting TCP/IP connections on port 5432?
- Rails + Postgres drop error: database is being accessed by other users
- Haml: Control whitespace around text
- undefined method `visit’ when using RSpec and Capybara in rails
- How to change a Ruby on Rails application name?
- How to configure Log4r with Rails 3.0.x?
- Why can’t I install the SQLite gem?
- Adding foreign key to a rails model
- RVM installed by Ruby not working?
- Heroku SSL on root domain
- using has_many :through and build
- How can I use ActiveRecord on a database that has a column named ‘valid’? (DangerousAttributeError)