The First 20 Hours: How to Learn Anything ... Fast by Kaufman Josh

The First 20 Hours: How to Learn Anything ... Fast by Kaufman Josh

Author:Kaufman, Josh [Kaufman, Josh]
Language: eng
Format: mobi, epub, pdf
ISBN: 9780670921935
Publisher: Penguin Books Ltd
Published: 2013-06-05T18:30:00+00:00


Launching the Application the First Time

I have the basic features in place, but I’m having a problem: when I test the application by visiting the home page, I immediately get an error message. The program is trying to find the Home record in the database, but it doesn’t exist, because I just started the application!

The solution for this is to create a “one-time administrative process” using a program called Rake. Rake programs are stored in a Rakefile, which is located in the root folder of the application.

Rakefiles work just like regular Ruby applications, with one exception: they exist outside of your core program, and you have to run the commands manually.

That makes Rake very useful for doing things like adding default information to the database before we officially run the actual program. I copy the important bits of application.rb into the Rakefile, then create a command that creates a new “Home” Page in the database. Then, all I need to do is run this command once:

$ rake setup

Rake creates the “Home” Page record, and my application stops showing errors on startup. When I push this application to Heroku, I’ll run the Rake command remotely to set up the database before I try to use the application.

At this point, we have all of the major features in place. Now, it’s time to add some fun things.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.