Rails General

This is why you’re here, ain’t it? Then don’t forget this, that and the other thing.
You’ve probably been told that Ruby is a language and Rails is a framework, but truly appreciating that distinction takes time. As you progress you will sharpen your interpretation of what makes Rails, Rails. And as you become more aware of how you can leverage Rails to accomplish a given task, you will want to remember how to do it again in the future. This stack is dedicated to capturing these types of Rails framework revelations. Things that might be found in a Rails guide, if you were the author.

Rollback or forward just one migration file

01/17/17  Public, Command Line, Rails General

You can rollback, or forward, just one migration file, regardless of where it is in the stack. Thereby putting it in either the down, or up, status.

Here is the syntax:

rake db:migrate:down VERSION=20160506010740
rake db:migrate:up V...

1 vote - harrylevine

Creating a local copy of the routes.rb file to speed up your grepping of the routes

10/08/16  Public, Command Line, Rails General

Grepping your routes.rb file, for decent size projects, can take a long time. One solution to speed up this process is to create a local copy of the current state of your routes.rb ...

1 vote - harrylevine

Creating a scaffold migration in Rails

08/21/16  Public, Rails General

1 - Make sure you have already created your rails app
2 - $ rails generate scaffold topic title:string description:text

This generate scaffold tells Rails to create everything necessary to get up and running with topics model.
- `topi...

1 vote - harrylevine

`update_all` does not trigger callbacks or validations

07/25/16  Public, Rails General

We usually use custom validations or callbacks on the model, when we want to throw a large net and catch everything.

Something to be aware of is that update_all does not trigger callbacks or validations.

1 vote - harrylevine