How to require and re-load a Ruby file during an IRB session

11/24/14  Public, Command Line, Ruby General

This is so you can upload some existing classes and/or methods that you have written in a file, during an IRB session.

  1. Make sure you are in the same directory as the file in question, then start the IRB session, i.e. $ irb
  2. Enter into...

1 vote - harrylevine

Way to test a specific section in a file without using Focus

11/24/14  Public, Tricks, Testing / TDD

Adding a focus to a spec file is good way to just test that specific area. The one drawback is you have to remember to remove the...

1 vote - harrylevine


01/01/15  Public, Online Resources

What's the difference between procs/lambdas.

Method visibility in ruby

Here's an...

1 vote - e47my54uc3

Summary of rake database migration commands in development

11/16/14  Public, Command Line, Databases

$ rake db:migrate
$ rake db:migrate VERSION=0 --> Removes all migrations, resetting back to ground zero
$ rake db:migrate VERSION=20141013165213 --> Migrates back down to the specific named migration
$ rake db:migrate:status --> *P...

3 votes - plawler

Very common recurring workflow with Git

11/15/14  Public, Workflows, Git

$ git branch --> Should be on your master branch
$ git checkout -b welcome-controller --> This creates a new branch called welcome-controller. Replace "welcome-controller" with name of your new branch
$ git branch --> *Should be o...

3 votes - harrylevine

After log in should redirect to a page other than default root

11/16/14  Public, Rails General, Gems

When using Devise, when a registered user logs in, they are, by default, directed to the root.

Here is the code to change this to being directed to a page of your choosing

In `app/controllers/appl...

1 vote - harrylevine

Create records directly in the database through the rails console

11/15/14  Public, Rails General

In the Rails Console:

First method
1. instantiate an object - $ subject =
2. set a value - $ = “John”
3. save the object to the database - $

Second method
1. use the cr...

1 vote - plawler

Rails database column migration methods

11/15/14  Public, Databases, Rails General

add_column(table, column, type, options)
remove_column(table, column)
rename_column(table, column, new_name)
change_column(table, column, type, options)

1 vote - brookemcg

Two Rails syntax methods for creating a table with columns in the database

11/15/14  Public, Rails General

Full syntax method. Used when adding a one-off column

create_table "table" do |t|
  t.column "name", :type, options

Shortened syntax method. More common.

create_table "table" do |t|
  t.type "name", options...

1 vote - brookemcg

Command for seeing all available rake tasks

11/15/14  Public, Command Line

$ rake -T

To see just the rake database related tasks:

$ rake -T db

1 vote - brookemcg