Running Your Foundation Application in Local Development Mode

by dbaldwin

This brief article will walk you through the steps to get your Rails GPS tracking application running locally. Here’s what you’ll need to get started:

1. Ruby
2. Rails (>= 2.1.0)
3. Rake
4. MySQL
5. SVN client

After checking out your project from the Subversion repository you’ll have everything in place to begin development.

1. Make sure to change to the RAILS_ROOT directory. RAILS_ROOT is the base directory where all your application files live.

2. From this directory you’ll need to create the MySQL database. You can do this manually from the MySQL command-line, but leverage the power of Rails and do it this way:

rake db:create

This should have created the database ublip_v2_development.

3. Now let’s run the Rails migrations to create the database schema:

rake db:migrate

Your database schema is now in place. If you’d like to learn more about the default schema be sure to read the article titled “Overview of the Developer Foundation Schema”.

4. Although you cannot run the device gateways on your local machine we provide mock data for dev and testing purposes. In the Rails world these are known as fixtures. Let’s load the fixtures into our newly created schema:

rake db:fixtures:load

5. The last thing we’ll need to do is create a local host entry for the application to function properly. As you learn more about the Foundation application you’ll get a better understanding of how we utilize subdomains to differentiate accounts. The default account for development purposes is app and the fully qualified URL should be http://app.ubliplocal.com. So we’ll need to create a host entry that looks like:

127.0.0.1 app.ubliplocal.com

We won’t go into details about how to edit your host file, but this article explains it well. Save your file.

6. Make sure you’re still in RAILS_ROOT and let’s start the built-in web server (known as WEBrick):

ruby script/server

You should see WEBrick start and listen on port 3000.

That’s it! Now you should be able to access your login page at http://app.ubliplocal.com:3000 and login using the default user:

Username: (JavaScript must be enabled to view this email address)
Password: testing

In a future articles we’ll discuss how to utilize the Rails testing framework, extending the schema with migrations, and deploying to your Foundation server using Capistrano.