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   […]