A Ruby on Rails Journey

October 4, 2011

Survivor Pool Setup

Filed under: survivor — Dick @ 2:29 am

Maybe one of these days I’ll actually complete a rails app. Maybe it will be this one. Maybe not. But I hate doing anything of substance and not blogging about it. I like to go back and read what I did because I don’t do rails stuff enough to be efficient yet.

In any case, my current project is an NFL survivor pool. Pick one team each week. If they win, you survive. If they lose, you’re out. Pretty simple.

I had Ruby 1.8.6 on my Windows 7 machine and Rails 2.3.8. I wrote a good deal of the app, but for some reason I couldn’t push it up to heroku. I decided to upgrade to Ruby 1.9.2 and Rails 3.1. I installed RailsInstaller 2.0 and it was a disaster. I would try to execute commands from the command line and it was clearly looking in the old 1.8.6 directory and couldn’t find them. I’ll bet it’s not really that hard to have multiple ruby versions, but honestly I don’t care to learn. I wiped out everything; uninstall RailsInstaller, delete Ruby directories, delete Git directories. Then I reinstalled RailsInstaller and things seemed to be working better.

I executed ruby -v and got 1.9.2. Good. I executed rails -v and got “file not found”. Then I did

gem install rails

and

gem install heroku

and they installed without incident. Now rails -v returned 3.1. Good. Next, I attempted to run my app locally. It told me I needed to install Rails 2.3.8 when I executed script/server. I didn’t want to use 2.3.8, so I commented out the RAILS_GEM_VERSION line in config/environment.rb. It was set to 2.3.8 and commenting it out should force it use the latest version of Rails. There’s probably a crapload of code in the app that won’t execute using Rails 3. I don’t know and I’m not that interested to find out. So I opted to start from scratch in Rails 3. That sounds like a big cop-out and it is. But the code will be far less crappy, as code always is when you write it the second time. So I

rails new dkusr2

to make a new app called dksur2. I like to use nifty-generators, so I added

gem 'nifty-generators', :group => :development

to my Gemfile and, back at the command line, ran

bundle install

It gave me a bunch of “Using” statements, which I think means it’s already installed, and one “Installing nifty-generators (0.4.6)” statement, which seems to be a good sign.

The next step was to get the empty app on git.

dick@DICK-HPELITE /c/sites/dksur2
$ git init
Initialized empty Git repository in c:/sites/dksur2/.git/

dick@DICK-HPELITE /c/sites/dksur2 (master)
$ git add .

dick@DICK-HPELITE /c/sites/dksur2 (master)
$ git commit -m "dksurvivor2"
[master (root-commit) 595bbd0] dksurvivor2
37 files changed, 1160 insertions(+), 0 deletions(-)
create mode 100644 .gitignore
create mode 100644 Gemfile
create mode 100644 Gemfile.lock
create mode 100644 README
create mode 100644 Rakefile
create mode 100644 app/assets/images/rails.png
create mode 100644 app/assets/javascripts/application.js
create mode 100644 app/assets/stylesheets/application.css
create mode 100644 app/controllers/application_controller.rb
create mode 100644 app/helpers/application_helper.rb
create mode 100644 app/mailers/.gitkeep
create mode 100644 app/models/.gitkeep
create mode 100644 app/views/layouts/application.html.erb
create mode 100644 config.ru
create mode 100644 config/application.rb
create mode 100644 config/boot.rb
create mode 100644 config/database.yml
create mode 100644 config/environment.rb
create mode 100644 config/environments/development.rb
create mode 100644 config/environments/production.rb
create mode 100644 config/environments/test.rb
create mode 100644 config/initializers/backtrace_silencers.rb
create mode 100644 config/initializers/inflections.rb
create mode 100644 config/initializers/mime_types.rb
create mode 100644 config/initializers/secret_token.rb
create mode 100644 config/initializers/session_store.rb
create mode 100644 config/initializers/wrap_parameters.rb
create mode 100644 config/locales/en.yml
create mode 100644 config/routes.rb
create mode 100644 db/seeds.rb
create mode 100644 doc/README_FOR_APP
create mode 100644 lib/assets/.gitkeep
create mode 100644 lib/tasks/.gitkeep
create mode 100644 log/.gitkeep
create mode 100644 public/404.html
create mode 100644 public/422.html
create mode 100644 public/500.html
create mode 100644 public/favicon.ico
create mode 100644 public/index.html
create mode 100644 public/robots.txt
create mode 100644 script/rails
create mode 100644 test/fixtures/.gitkeep
create mode 100644 test/functional/.gitkeep
create mode 100644 test/integration/.gitkeep
create mode 100644 test/performance/browsing_test.rb
create mode 100644 test/test_helper.rb
create mode 100644 test/unit/.gitkeep
create mode 100644 vendor/assets/stylesheets/.gitkeep
create mode 100644 vendor/plugins/.gitkeep

Wow, something worked as I expected it. Next I created a new heroku app.

dick@DICK-HPELITE /c/sites/dksur2 (master)
$ heroku create
Creating evening-snow-8011....... done, stack is bamboo-mri-1.9.2
http://evening-snow-8011.heroku.com/ | git@heroku.com:evening-snow-8011.git
Git remote heroku added

dick@DICK-HPELITE /c/sites/dksur2 (master)
$ git push heroku master
Enter passphrase for key '/c/Users/dick/.ssh/id_rsa':
Counting objects: 63, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (47/47), done.
Writing objects: 100% (63/63), 25.07 KiB, done.
Total 63 (delta 2), reused 0 (delta 0)

and a whole bunch of other lines. I went to http://evening-snow-8011.heroku.com/ and got the always heart-warming Welcome Aboard message that means I didn’t screw anything up.

My next step will be to watch Authentication from Scratch and Authentication in Rails 3.1 so I can make my User model and controllers and such. From there, I expect the app will generally look like:

Team
:name, :string

has_many :picks
has_many :users, :through => picks

Game
:start, :datetime
:weekno, :integer
:away_id, :integer
:home_id, :integer
:awayscore, :integer
:homescore, :integer

has_one :away, from team on away_id = id
has_one :home, from team on home_id = id
has_many :picks

Pick
:user_id, :integer
:team_id, :integer
:game_id, :integer

belongs_to user, team, game

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.