All Rails built-in validators populate the details hash with the appropriate validator type. errors[:base] You can add error messages that refer to the state of the object as a whole rather than to a single attribute. This method can be used if you want to say that an object is invalid, regardless of the values […]
Tag: ruby on rails tutorial: learn web development with rails
Modifying Existing Migrations in Ruby
Periodically, you will make mistakes when writing migrations. If you’ve already run a migration, you can’t just edit the migration and run it again: Rails will assume it has already run a migration and will do nothing when you run rails db:migrate. You must rollback the migration (using bin/rails db:rollback, for example), edit the migration, […]
Article updates on website built with Ruby
We have revealed the “CR” part of CRUD. Now let’s focus on the “U” part, updating articles. The first step is to add an edit action to the ArticlesController, usually between the new and create actions, as shown. def new @article = article.new end def edit @article = Article.find(params[:id]) end def create […]