Plain Text Popular Movie Titles List – 1990-2015

I’m not sure if anyone will find this movie titles list useful, but I put together a plain text file of the top 100 grossing movies from each year from 1990-2015. The format of each line in the file is


I created this list to help me solve a Games magazine puzzle involving movie titles and actors in the said movies.

Here’s the file. Enjoy! 1990-2015 movie titles

My Experience with Comcast – Part 2


My internet connection has been going in and out over the last few days and now it’s completely out. I called tech support tonight (well, technically my wife called them) and they said my modem was “outdated.”

This explanation seems less likely to be accurate and more likely to be a lazy excuse on Comcast’s part to not look any further into the issue. Why would the modem suddenly become outdated? Isn’t it more likely that something suddenly happened with the service?

Also, my modem is an ARRIS/Motorola SB6121 SURFboard DOCSIS 3.0. I’m no modem expert but I think that’s a pretty popular and well-regarded modem. If it’s outdated for some reason, I think a lot of people would be making a stink about it.

AND … Comcast has tried to blame my modem in the past and of course they were dead wrong (as I documented in my earlier post about Comcast).

I posted most of the above to the Comcast Help & Support Forums. Other posts seem to get pretty well-informed responses. Maybe I’ll get lucky.


After two days without internet I figured I had to do something. So I went into my local Comcast store and “rented” a modem. It’s $10/month, but I have a strong feeling I will be returning it soon because the problem is with the line, not the modem.

I took the modem home and hooked it up, then called Comcast as instructed to finish the installation. After losing a half hour of my life in the fruitless effort to get a proper connection to the new modem, I scheduled a tech support visit for Sunday (three days from now). This means I will have had no internet service for five days thanks to Comcast misdiagnosing my issue, but it looks like that’s the best I can do.

Comcast is really terrible.


My Experience with Comcast – So Far


Signed up online for Performance with Blast. It costs $44.99/mo for the first 12 months. There is no contract. I had already purchased a refurbished modem on, so I did not need to rent on of their modems for $8/mo. They will set up my line 12/7/14, five days from now.


Comcast technician was supposed to be here between 12-2pm. He did not show up during this time period. When I called support, I was informed he would arrive around 3:30pm. If I had not called support I imagine I would never have been alerted to this fact.

Technician finally showed up and got everything working.

It’s worth noting that everything is working and I am currently using my modem. Not a Comcast-supplied modem.

12/10/14 (Need to confirm date)

Connection has become intermittent. Either slow or not working at all. A technician will arrive on 12/16/14 to fix it.


Technician is supposed to arrive between 8-10am. I scheduled this time window so I could get to work at a reasonable hour. He is late.

Technician determined there was something wrong with my modem, so he installed a Comcast modem. The new modem works, though it will cost me $8 per month.

Technician offers to clean up a second line (verify it’s working, put a protective housing on it) but because it will take an hour or so and I’m already late for work, I postpone it.

Internet connection is now working great on the primary line.


Just got back from vacation. Internet is not working. Called Comcast and based on their efforts over the phone, they have determined there is something wrong with the modem. That is, there is something wrong with the new modem provided by Comcast.

They will send a technician out on 1/3/15. That means I will be without an internet connection for five days. I have no choice but to accept it.

I call tech Arris support for my modem. They walk me through some steps that clearly indicate there is something wrong with the connection, not either of the modems.

I call Comcast back with this information, but their remote tests still indicate nothing wrong with the line


The internet connection has suddenly come online again. AND, I am using my modem! I am getting 44mbps download speeds. The technician is coming out tomorrow, and because these technician visits are so hard to come by, I am not going to cancel it.


Technician arrives on time. Technician determines the line connected to the modem is bad. Technician activates the other line and it now has a better signal than the other line did.

There is nothing wrong with my modem, as the phone technician had previously diagnosed.

I now I have to take the time go to the Comcast store in person to return my Comcast modem. The modem I never needed to begin with.

Update 1:

Received a call from Comcast on 2/15/15 (not 100% sure about that date, but it’s close at least). I hadn’t payed for any of my services since I first signed up. I thought I had signed up for auto payment, but I guess not. Ok, let’s pay what I owe.

The amount comes to $229.15. Wait, what? I am paying about $45/mo for Xfinity internet only. That should be maybe $130 plus taxes, fees, etc. And I should have $40 in credit for two late technician visits. Not even close to $230.

It turns out Comcast has charged me $70 for one of the tech visits, and $50 for another. I didn’t mention it in my original recap, but before each tech visit, a Comcast phone operator assured me that there would be no charge for the visit. On at least one of the visits, the technician repeated this promise (although a phone operator later told me they are not authorized to say this).

My head nearly exploded. My Comcast story was becoming even worse. Hard to believe but true.

I was ready to cancel on the spot but the download speeds are so good (for the US, I mean)! I had to be practical. I calmed down enough and was able to get them to knock the $70 charge of my bill. That left the bogus $50 charge remaining, but I decided to cut my losses for the time being, and told the guy I would pay my bill later.

Update 2:

I still hadn’t payed my bill, and I was worried Comcast was throttling my connection, so I called them today (3/13/15). This time I was armed with my invoices and this blog entry with a record of all my interactions. I waded through the byzantine invoices with the operator and I think because I just kept asking questions he finally relented and took the $50 charge off my bill!

I guess I should be happy it all worked out, but look how much of my life I have wasted on this garbage.

Update 3:

Agh … I thought everything was settled and I could simply pay my bill from here on out. But no. Today I noticed that they charged me a $5.99 “convenience fee” on 3/14/15 – the day after my previous update. I am tempted to just let it go but that must be what they want me to do right? They must just put miscellaneous charges on peoples’ bills and hope they just pay them without questioning.

On the other hand, I really don’t want to call them again. I’ll try emailing them.

Update 4:

I finally mustered up the energy to contact Comcast about the $5.99 charge, although I didn’t take care of it until a month later. On 4/14/15 I chatted with a Comcast customer service agent via their Web site. The operator informed me the charge was “a one time charge for the payment on live chat or in the phone assisted by a professional agent.”

I wasn’t sure if that meant the charge was for chatting with an agent or “convenience” of having an agent take my payment. Turns out it was the latter. I can assure you that the agent never informed me there would be a $5.99 fee for him to take my payment by phone.

That’s three separate charges they’ve made without informing me. One might be inclined to think this is a pattern: Charge the customer without telling them, then hope the customer either doesn’t notice or can’t be bothered to complain.

Update 5:

More connection problems. Looks like round 2 has begun. 🙁 See my new post for details.


  • 12/7/14 – Technician late. Internet connection working after visit
  • 12/10/14 – Internet connection failing
  • 12/16/14 – Technician late. Internet connection working after visit, but Comcast modem is now supposedly required.
  • 12/30/14 – Internet connection not working. Just back from vacation, so I’m not sure how long it’s been out. Phone support says it’s the modem. The Comcast modem.
  • 1/2/15 – Internet connection spontaneously starts working. AND it’s working via my modem – the modem that supposedly was the cause of an earlier failure.
  • 1/3/15 – Technician diagnoses a problem with the first line, so he sets up a different line. All working now, including my modem. But, I need to return the Comcast modem in person.
  • 2/15/15 – Phone operator informs me I have been charged $70 and $50 for two of the (mostly ineffectual) technician visits. I am refunded the $70 charge.
  • 3/13/15 – I plead my case to another Comcast phone operator and they reverse the remaining $50 charge.
  • 3/14/15 – Mystery $5.99 “convenience fee” shows up on my bill.
  • 4/14/15 – Chat operator informs me $5.99 fee was for operator taking my payment by phone on 3/13. Of course they didn’t tell me about this charge at the time. Chat operator credits me for the charge.

Getting started with the MEAN stack and – Part 1

If you haven’t heard about it, the MEAN stack consists of:

  • mongoDB
  • ExpressJS
  • AngularJS, and
  • Node.js

The installation and set up process is described in a bunch of
places on the Web. I struggled through it, despite the supposedly
easy process.

I wish I had taken better notes on my initial set up troubles, but I’ll
have to begin by documenting my current state. I think I’ve finally
installed and set up my stack, and (based mostly on the guidance
provided in the tutoral) I’ve run grunt to start the server.

When I go to http://localhost:5858, however, I get this:

Type: connect
Protocol-Version: 1
Embedding-Host: node v0.10.33
Content-Length: 0

What’s that? I thought it might be some debugging information
that would appear at the bottom of a page, but where’s the page?

In addition to installing the mean stack using the tools,
I am following the tutorial at, so I’ve created an index.html
and an app.js file. The server is definitely picking them up because it
was giving me some jshint error messages concerning the app.js file
(not using ‘use strict’). I am not, however, seeing anything from the
index.html file.

I have tried to search on the strings in the ostensible debugging info,
but I am coming up empty. Did I neglect to install something?

Maybe the grunt  command doesn’t start MongoDB and maybe
I have to have the DB running? I tried to start Mongo by running
“mongod” at the command line, but I got an error:

exception in initAndListen: 10310 Unable to lock file: /data/db/mongod.lock. Is a mongod instance already running?, terminating

A popular StackOverflow answer says the following command will solve this:

sudo chown -R `id -u` /data/db

That didn’t help though. I had already set the proper permissions on that directory.

Then I tried just checking to see if mongo was already running. I know I tried
this before but I must have just spaced out when I tried it. So I ran this:

ps ax | grep mongod

and killed the process called “mongodb”. Then I started it back up, and successfully viewed localhost:3000.

What I saw on my local server, however, was basically just a big advertisement
for the MEAN stack. Where was this page coming from? It certainly isn’t the
index.html file I had created in the tutorial.

Ok … I found it. The page, which looks like this: default home page

This index.html file for this page is located here on my system:

[my mean project root path]/packages/system/public/views/index.html

I think I’m going to stop here for now. I feel like I’ve accomplished something
anyway. I have the server running, the db running, and I have at least a rough
idea of where the files are that I need to edit.

Install Eclipse on Ubuntu Linux for Java Development

Installing Eclipse on Ubuntu isn’t all that complicated, but I had to do some digging before I found the right combination of steps to get this to work. These are the steps I followed today 12/5/14. They may be out of date by the time you read this, but hopefully they will still provide some guidance.

  1. Download eclipse and install
    2. Download Eclipse IDE for Java EE Developers, 64bit
    3. I found the resulting file “eclipse-jee-luna-SR1-linux-gtk-x86_64.tar.gz” in my “Downloads” folder.
    4. Right click on the .tar.gz file and choose “extract here.”
    5. The resulting folder is simply called “eclipse”
    6. I moved the “eclipse” folder to a directory I created in my “Home” directory. I called the new directory “Applications”.
    7. There is no installation process for Eclipse. It’s all ready to go once you uncompress it.
  2. Download the Java SDK and install (based on this StackOverflow thread)
    1. sudo apt-get install openjdk-7-jdk (Replace “7” with whatever version you want)
    2. Follow the prompts to install. I think I only had to hit enter a couple times.
  3. Install Tomcat
    1. sudo apt-get install tomcat7
    2. tomcat is now here: /usr/share/tomcat7

Creating a Tomcat server in Eclipse failed with this error: “‘Could not load the Tomcat server configuration at /usr/share/tomcat7/conf.”

Finding the best way to install the JDK was my biggest stumbling block. I manually downloaded it, moved it around, tried to change my paths, etc. but nothing worked until I found the command line instructions in StackOverflow.

Everything is running well for me now. I’ll report back if there are any extra steps needed later.

Update: Added step 3. I wasn’t able to create a server in Eclipse, so I had to install Tomcat.

Rails Tutorial Part 2: Setting Up a Server on Heroku for Free!

Continuing from my previous post, in part two of this Rails Tutorial I am going to continue to add to my nascent project. The theme of the project is getting set up on heroku with lots of cool addons … for FREE!.

In part two we will be adding, as promised:

  • Papertrail: an awesome log management service (free)
  • New Relic: Site monitoring (free)
  • PG Backups: postgres backup (free)

Like most heroku add-ons, adding Papertrail was a piece of cake. Just go to the Papertrail add-on page and choose the “Choklad” (i.e. FREE) option. Done.

I add New Relic by simply going to and selecting the either the ‘Stark’ or ‘Wayne’ free version. (I’m not sure which one will better suit my needs, but I’ll go with the one that offers more features for now. I can always switch to another configuration later.)

When I went to verify that everything was connecting, however, I only received a generic message saying “Welcome, ! Thanks for taking advantage of our partnership with heroku.” For some reason it’s not clicking.

Turns out my server was not running correctly. Fortunately, Papertrail helped me track down the source of the issue: My app was not connecting to the Postgres DB successfully. The error message was “FATAL: password authentication failed for user “zapetulgfrdywm” (PG::Error).”

StackOverflow to the rescue, of course. I had to “promote” my heroku DB – I guess it was trying to use the credentials from my local DB. Once I did that the errors went away and my server was up and running successfully.

At this point I went back to New Relic to see if it was starting to show any monitoring information. It wasn’t. Solution: Fortunately it was simple. I just restarted heroku

heroku restart

Not much to show so far, of course, but it looks like it’s running. Yay!

Finally, I’d like to add PG Backups to make regular, automatic (and FREE) backups of my DB. To add it, just go to the PG Backups page and choose one of the three options: “Auto – One Month Retention,” “Auto – One Week Retention,” or “Plus.” I must admit I don’t really understand the differences between the options. The “Plus” option seems geared toward people who want to only do manual backups, but the two “Auto” options seem pretty similar. Maybe the One Month Retention option seems superior. That’s the one I chose anyway. Maybe I’ll discover something preferable about the One Week Retention option later.

Looks like I’m ready to start coding! More specifically, I’m ready for part 3: Getting users authenticated so they can eventually create content for my site.

Rails Tutorial: Setting Up a Server on Heroku for Free!

In this Rails tutorial I am going to set up dev, stage, and production environments. Dev will be on my local machine and I’ll use heroku for stage and production. I’m going to use Unicorn to provide a performance boost and I’ll use postgres as my DB because that’s what heroku will allow me to use.

Why use Unicorn, you may ask. I’m no expert on servers and performance, so I’ll let this quote speak for itself (from “More concurrency on a single Heroku dyno with the new Celadon Cedar stack” by Michael van Rooijen. Read it!).

In any case, what’s important to understand for now is the fact that there’s a master process which loads in your application’s environment, and forks off child processes to serve your application.

The first step to set up my site is to create my local (dev) environment with the basic rails new [app_name] from my command line. [Note that you may want to run rails new [app_name] -d postgresql instead. I haven’t tried it yet but it may save some steps described below.

Next I create my git repository on Bitbucket. The process is terribly simple. Just go to, click “Create a repository,” then follow their very clear instructions for adding and committing your source files to your new repo.

After I commit my files, I set up unicorn. I follow the simple instructions in the blog entry “Deploying Rails Applications With Unicorn” and, after running foreman start at the command line, I now have Unicorn running smoothly locally.

Heroku doesn’t like the default db, sqlite, so I followed the instructions in the ASCIICast version of Railscast #342 so I can use postgresql instead. I then edit my ‘database.yml’ file as instructed in the Railscast and StackOverflow thread. When I try to run rake db:create:all, however, I get an error saying I need to run gem install activerecord-postgresql-adapter. So I do. I also change  gem ‘sqlite3’ to  gem ‘pg’ in my Gemfile. Now when I run rake db:create:all, all is good.

Note that in previous attempts to set up my environment, I have run into the same problem as the Railscast commenter “blackpond” – my environment was still using the old version of postgres that cam installed on my mac. Fortunately user “aharte” had the suggestion that worked:

Edit /etc/paths and make sure /usr/local/bin is above /usr/bin in the file. Open a new shell, and you’re good to go!

When I try to push to heroku, however, it complains that I am still using sqlite. I didn’t add my Gemfile to the repo! Simply do a normal git add . followed by git commit -m “[message], then push to heroku with git push staging master and we’re good to go.

Well, not quite. After changing /etc/paths I was getting a “role does not exist” error. This StackOverflow thread recommended that I remove ‘username’ line for my stage and production servers in my database.yml file. It worked!

Now to hook everything up with heroku. I carefully followed the instructions on the Managing Multiple Environments for an App how-to page on This set up my staging and production servers.

Now if I run git push stage master everything processes correctly on the heroku side of things for my stage environment. When things look good on stage, I can just run git push stage production. Woo-hoo!

In the next part of this series, I’m going to add a few add-ons to my heroku set up:

  • Papertrail: an awesome log management service (free)
  • PG Backups: postgres backup (free)
  • New Relic: Site monitoring (free)

Definitely a theme going on here: FREE! If the site gets rolling, hopefully I’ll need to upgrade things, but for now my set up definitely works fine.

Ruby on Rails Cheat Sheet Part 2 – More Tips and Reminders

I am still finding new Ruby and Ruby on Rails tricks (and I keep forgetting them) so I am starting a second Ruby on Rails cheat sheet to help me remember how to accomplish simple tasks.

Check out my first Ruby on Rails cheat sheet if you’re interested. It’s based on the Ruby on Rails Tutorial by Michael Hartl.

Set up a new Heroku app:

heroku apps:create app-name

Push git repo to new Heroku app:

git push heroku master

Reset a postgres DB on Heroku:

heroku pg:reset postgres

View Heroku logs:

heroku logs

Restart Heroku server:

heroku restart

Migrate DB on Heroku server:

heroku run rake db:migrate

Generate a resource without controller actions and without a view

rails g resource resource_name {space-delimited property names}



Ruby on Rails Tutorial: Creating a Rails Instance from an Existing MySQL DB

In this Ruby on Rails tutorial, I will show how to create a Rails instance from an existing MySQL database.

I have an existing site that used Codeigniter and a MySQL DB, and I want to more or less convert that site into a Ruby on Rails site. I would like to make things as automatic as possible so I don’t have to manually port any of the existing data or create the model properties.

I found this thread on that explains the basics of how to migrate an existing MySQL DB so it works with Rails. Let’s follow the steps provided:

1. Write config/database.yml to reference your database.
I’m going to follow the guidelines in the RailsGuides for configuring a MySQL DB. The guidelines say that I should change my config/database.yml file to look something like this:

  adapter: mysql2
  encoding: utf8
  database: blog_development
  pool: 5
  username: root
  socket: /tmp/mysql.sock

With some small tweaks to match my local environment, I’m ready for step 2:

2. Run “rake db:schema:dump” to generate db/schema.rb.
First stumbling block. I get the following error upon trying “rake db:schema:dump”:
Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (mysql2 is not part of the bundle. Add it to Gemfile.)

After following the suggestions I’ve been given (1. gem install activerecord-mysql2-adapter and 2. Adding “gem ‘mysql2′” to my Gemfile) I try “rake db:schema:dump” again.

Second stumbling block. I get this error:
Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ (2)

This StackOverflow thread tells me that I need to figure out the correct socket file and specify it in my database.yml file. I run ‘mysqladmin variables | grep socket’ from the command line and find out that my socket file is located at ‘/Applications/XAMPP/xamppfiles/var/mysql/mysql.sock’ because, of course, I’m running XAMPP for my MySQL server.

Success! Well, I think so anyway. At least I didn’t get any error messages this time.

3. Convert schema.rb into db/migrate/001_create_database.rb
My schema.rb file reflects a successful connection to my MySQL DB. It seemingly faithfully describes the tables and fields of my DB. So I create a ‘/db/migrate’ folder, copy my ‘schema.rb’ file into it, rename it ‘001_create_database.rb’ and wrap the schema as suggested by the thread:

class CreateDatabase < ActiveRecord::Migration
  def self.up
    # insert schema.rb here

  def self.down
    # drop all the tables if you really need
    # to support migration back to version 0

One note about this: The instructions in the thread say the first line of the migration file should be:

class CreateMigration < ActiveRecord::Migration

But it didn’t work for me until I changed it to:

class CreateDatabase < ActiveRecord::Migration

(Note the updated class name.) All good now.

So now I think I have what I need to create the DB if I need to.

Now for the cool part. If I create a simple model whose class name matches one of the tables in my DB, I can immediately start accessing the data in the DB. Simple model:

class Tweet < ActiveRecord::Base
  # I have a table called 'tweets' in the DB

Now in the Rails console I can type:

> i = Tweet.find(296) # 296 is an ID of an item in the DB

And I get the data related to that record!

One last thing to really show that a connection has actually been made to the old DB. I want to display some records in the browser. There are really only three steps to accomplish this, but I’ll add a fourth step to allow for pagination between all the records.

Step 1: Add routes to set up basic CRUD functions
This is pretty simple, just add the following line to the beginning of the routes.rb file:

resources :tweets   # replace 'tweet' with the name of your model

Now if I go to I get an error “uninitialized constant TweetsController.” That’s because, well, I haven’t created my Tweets controller.

Step 2: Add a controller and define an index function
In the ‘/app/controllers’ directory, I simply created a file called ‘tweets_controller.rb’ and added the following text (replacing the names of the classes and models as necessary):

class TweetsController < ApplicationController
 def index
    @tweets = Tweet.paginate(page: params[:page], :per_page => 10)

This won’t work until we get through step 3.

Step 3: Add the ‘will_paginate’ gem
In the Gemfile, add the following line:

gem 'will_paginate', '3.0.3'

Then run ‘bundle install’

Step 4: Create a view
In the ‘/app/views’ directory I created a ‘tweets’ directory and within that directory I created a file called ‘index.html.erb’. The ‘index’ part of that file name matches the index function of my TweetsController for a reason – this view gets called automatically when the user goes to ‘/tweets/index.html’.

In the same ‘/app/views/tweets/’ directory I create a very simple partial file that will be called whenever an individual tweet needs to be displayed. That file is called “_tweet.html.erb” and the contents look like this:

  <!-- tweet_text is a field in the tweets table -->
  <%= tweet.tweet_text %> 

The contents of the ‘/app/views/tweets/index.html.erb’ file I mentioned above look like this:

<%= will_paginate %>
 <ul class="users">  <!-- Knows to repeatedly render the _tweets partial -->  <%= render @tweets %>  </ul> <%= will_paginate %>

And that’s it! I get all my DB records listed, 10 at a time, with pagination links so I can jump around between them. There’s no formatting and a lot more work will go into displaying and organizing the data, but this is a really good start.

I create these rough tutorials as I go, so I fear some of the info may be disjointed or inconsistent. Please let me know if you have any questions or need anything clarified. I’m happy to help.

Ruby on Rails Cheat Sheet – Handy Tips Gleaned from RoR Tutorial Book

Every time I go away from RoR for a while, I forget everything I had learned. In order to get me up to speed more quickly in the future, I am going to create a Ruby on Rails cheat sheet that describes how to accomplish simple tasks with Rails.

These tips all come from the Ruby on Rails Tutorial by Michael Hartl and the section #s below refer to it (

Create static pages (3.1.2):

Tell generate to use RSpec:

rails generate rspec:install

Generate static pages:

// generates home and help pages
rails generate controller StaticPages home help --no-test-framework

 Undoing generate commands

// Example
rails generate controller FooBars baz quux
rails destroy  controller FooBars baz quux
// Example 2
$ rails generate model Foo bar:string baz:integer
$ rails destroy model Foo
// Rake db:migrate example
rake db:migrate
rake db:rollback

Everything in Ruby (even a string and nil) is an object (4.2.3)

=> ""
=> false

 Array operations followed by a bang (!) affect the array (4.3.1)

>> a
=> [42, 8, 17]
>> a.sort
=> [8, 17, 42]
>> a
=> [42, 8, 17]
>> a.sort!
=> [8, 17, 42]
>> a
=> [8, 17, 42]

You can think of symbols as basically strings without all the extra baggage (4.3.3)

>> user = { :name => "Michael Hartl", :email => "" }
=> {:name=>"Michael Hartl", :email=>""}
>> user[:name]       # Access the value corresponding to :name.
=> "Michael Hartl"

Alternate syntax for using symbols as hash keys (4.3.3):

>> h1 = { :name => "Michael Hartl", :email => "" }
=> {:name=>"Michael Hartl", :email=>""}
>> h2 = { name: "Michael Hartl", email: "" }
=> {:name=>"Michael Hartl", :email=>""} 
>> h1 == h2
=> true

Adding Bootstrap and Sass (5.1.2)

  1. Make sure the bootstrap gem is listed in your gemfile
    gem 'bootstrap-sass', '2.0.4'
  2. Create a Sass file (app/assets/stylesheets/custom.css.scss) with the following line
    @import "bootstrap";
  3. That’s it!

Creating and referencing partials (5.1.3)

  1. File name and location:
  2. Reference to partial:
    <%= render 'layouts/partial_name' %>

 Asset directories and their purposes (5.2.1)

  • app/assets: assets specific to the present application
  • lib/assets: assets for libraries written by your dev team
  • vendor/assets: assets from third-party vendors

Each has images, javascripts, and stylesheets subdirectories.

Routes to static pages (5.3.2)

The following line redirects /help to the help.html.erb layout in the static_pages directory

match '/help',    to: 'static_pages#help''

It also creates the following two named routes:

about_path => '/about'
about_url  => 'http://localhost:3000/about'

Creating a controller (5.4.1)

# Creates a simple "new" view and empty "new" controller method
# --no-test-framework prevents creation of initial testing spec
rails generate controller Users new --no-test-framework

Creating a model (6.1.1)

rails generate model User name:string email:string

 Annotating model definitions with details from their DB counterparts (6.1.2)

# Add gem to Gemfile (only for development)
gem 'annotate', '2.5.0', group: :development
# Goes through DB tables and comments corresponding model files
bundle exec annotate

 Test Driven Development (3.2.1, 6.2.1)

  • Create a ‘request’ test for each static page (/spec/requests/…)
  • Create a model test for each model (/spec/models/…)

Adding migrations to an existing model (6.2.5)

rails generate migration add_index_to_users_email

Look for the new migration file and edit it appropriately. Then run:

bundle exec rake db:migrate

Example #2 (specifying a column to add to a table):

rails generate migration add_password_digest_to_users password_digest:string

Post migration creation:

$ bundle exec rake db:migrate
$ bundle exec rake db:test:prepare
$ bundle exec rspec spec/

Also, use add_index (8.2.1) to create an index on any column that will be used to retrieve info

Add debug info to a view (7.1.1)

<%= debug(params) if Rails.env.development? %>

Run console in a different environment (test/development/production) (box 7.1)

rails console test

Run server in a different environment (test/development/production) (box 7.1)

bundle exec rake db:migrate RAILS_ENV=production

Reset the database (7.2)

bundle exec rake db:reset

# "ensures that the data model from the development database is reflected in the test database" 
bundle exec rake db:test:prepare 

[restart Web server]

Completely clear and reset the data base (

rake db:drop
rake db:create
rake db:migrate

Run a subset of rspec tests matching a string (7.4.4)

rspec -e "signup page"

Deploy to Heroku (7.4.4)

1. git push heroku
2. heroku run rake db:migrate
3. heroku open (opens the site in a browser)

Reset a Heroku DB (9.5)

$ git push heroku
$ heroku pg:reset HEROKU_POSTGRESQL_CHARCOAL_URL [probably]
$ heroku run rake db:migrate
$ heroku run rake db:populate

Making error messages more user friendly (7.6)

Flash messages vs. messages (8.15)

  • flash messages stay on the screen for one request (ex: redirect)
  • messages for one render. Goes away on next request.

Note about helpers

  • By default, all the helpers are available in the views but not in the controllers
  • So, it is necessary to explicitly include helpers within controllers

Cool shortcut to finding objects by a property (8.2.3 and elsewhere)

ex: User.find_by_name("Joel B")
ex: User.find_by_email("")

 Writing tests for checking cookie values (not a great idea) (8.2.6)

… experience shows that direct tests of cookie values are brittle and have a tendency to rely on implementation details that sometimes change from one Rails release to the next. The result is breaking tests for application code that still works fine. By focusing on high-level functionality—verifying that users can sign in, stay signed in from page to page, and can sign out—we test the core application code without focusing on less important details.

Visiting a typical page with RSpec:

before { sign_in user }

Visiting a path involving an update with RSpec (9.2.1)

before { put user_path(user) }

Note that direct use of the PUT HTTP request here. There’s no other way to do it.

Using exclamation points with actions (9.3.2)

  • create will return “false” if it doesn’t work
  • create! will raise an exception if it fails

Populating the DB with sample users (see section 9.3.2)

Adding a boolean field to a db table = awesome (9.4.1)

1. $ rails generate migration add_admin_to_users admin:boolean
2. Creates
      class AddAdminToUsers < ActiveRecord::Migration
        def change
          add_column :users, :admin, :boolean, default: false
3. Change line to: add_column :users, :admin, :boolean, default: false 4. This automatically creates test user.admin? test

Only attr_accessible attributes can be assigned through mass assignment (9.4.1)

A note about arrays in Ruby (10.1.4)

Array assignment in Ruby copies a reference to the array, not the full array itself, which means that changes to the original array also affect the copy.