This weekend I wanted to take a bit of a stroll down the Ruby road. I’ve never used it before so I figured I’d give it a whirl and see what happened. I followed a tutorial that had a few little hick-ups so I decided to blog this in case anyone else runs into this problem.
If I am looking at something new I generally look to this github page to find a good place to start. I started with a couple of the ruby language primers just so I could get a feel for the language and how it works. After I spend enough time on that I went to this tutorial to get ruby on rails set up on Ubuntu. Everything worked well up until part 1.2.5. Running the command
Gave me this error
/var/www/ruby/first_app/config/environments/development.rb:1:in `<top (required)>': undefined method `configure' for #<FirstApp::Application:0x90efc78> (NoMethodError)
After googling a bit I found a solution by opening config/environments/development.rb and changing this line
When I originally ran the rails new command I used
rails new first_app
Which means my app folder is /first_app/ so you might have to change that
accordingly. Ok first problem solved. When I ran
rails server it showed up
this time but when I tried to access the webpage I got this error
DEPRECATION WARNING: You didn't set config.secret_key_base. Read the upgrade documentation to learn more about this new config option.
I found another answer to this one on StackOverflow by creating the file config/initializers/secret_token.rb and using this content
# Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. # You can use `rake secret` to generate a secure secret key. # Make sure your secret_key_base is kept private # if you're sharing your code publicly. FirstApp::Application.config.secret_key_base = 'de6156670dfadf0101011000112310980198236544e55623a143c9ae5254842b2c66fcc59849'
First note that like the first problem the FirstApp part will have to be changed to what ever your name is and you MUST change the secret key base. DO NOT REUSE THE SAME SECRET KEY BASE. After solving these two little issues I could finally get my demo app running so hopefully this saves someone a bit of time in the future.