Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 & validate_on_create

Rails 3 warns me that validate_on_create is deprecated. I have def validate_on_create in one of my models. What do I replace it with?

like image 291
ssnkl Avatar asked Oct 04 '11 21:10

ssnkl


People also ask

Does Rails 7 require Ruby 3?

Rails 7 requires Ruby 2.7. 0 or newer. Rails 6 requires Ruby 2.5.

Is Rails 7 released?

September 15, 2021 Welcome to the first alpha release of Rails 7. It brings some very exciting new answers to how we do JavaScript, an awesome approach to at-work encryption with Active Record,...

Is Ruby on Rails still relevant 2022?

Ruby's and Ruby on Rails' Overall Popularity Although way behind main contenders, such as PHP or Python, Ruby still makes the cut for the 20 most popular programming languages list in 2022. The 2022 edition of Stack Overflow Annual Developer Survey also places RoR in a similar spot.


1 Answers

You can use:

validates :name, :presence => true, :on => :create

If you have a method that performs validations, you should run as:

validate :method_name, :on => :create
like image 189
rafamvc Avatar answered Oct 04 '22 08:10

rafamvc