Running a Rails App



Cloud9 IDE also supports the ability to run a Rails application. The rails command is only available on the terminal.

To run a Rails application:

  1. Open the terminal and type gem install rails
  2. When done, type rails new example -d mysql
  3. Edit your database configuration in config/database.yml
  4. Type rails s -b $IP -p $PORT

That’s it! Your rails app will now be running.

Note: should be running your application.

Do not try to access the project through the IP address and port number rails returns to you–it won’t work!

Use MySQL in your rails app

  1. Set up MySQL - note your DB connect parameters

  2. Open the terminal and type gem install mysql2

  3. edit config/database.yml

  adapter: mysql2
  encoding: utf8
  database: c9
  username: <%=ENV['C9_USER']%>
  host: <%=ENV['IP']%>


Config/database.yml not detected RoR
Using MYSQL in rails app
Tutorials - Table of Contents
Running Wrong Application

Hello Brady Dowling,

I am new to using Rails combined with mysql.

This question is about the different environments. I have edited config/database.yml as described and the well-know “Yay! You’re on Rails!” can be seen in my browser now.
( somewhat confusing; since some place else I read that mysql-ctl start was necessary. Is it, or is it not necessary at the start of a project? )

But this is only for development; what to do for :test and :production environments?
Especially a test environment is very necessary, to do Test Driven Development…

Is it OK to use the same setup for a test environment? I am not sure, since I recall having read somewhere that they can’t be the same!

Extra information: I searched, came here and discovered this support page. But the direct motivation was, that I could not run tests.

The error message is:

ActiveRecord::StatementInvalid: Mysql2::Error: Table ‘’ doesn’t exist: DELETE FROM recipes

I thought there should be a test-table ; build from the contents of the file /test/fixtures/recipes.yml.

Apparently this does not work for me now, yet. What must I do; what am I missing?

UPDATE: I found the way to test, that seems to work:
Before testing, do rails db:migrate RAILS_ENV=test


mysql-ctl might be necessary after some time you stop using the workspace. I always recommend you start it when you return to working in your workspace.

You can start preparing a database for your test environment by running:

rake db:test:prepare.

This will create the database in your tests in the test environment, load your schema, and run the migrations so that you can start using it.

Calls to the database from your test will use that database.


Thank you, @BigChief45. I found out, in my case, the test database can be started with rails db:migrate RAILS_ENV=test. (I am on Rails

Your suggestion; first mysql-ctl start, followed by rails db:test:prepare also does it!


I’m going through Michael Hartl’s Ruby on Rails Tutorial (4th ed).
I think that I’ve managed to get a working development environment configured inside the Cloud9 IDE. I seem to have been able to successfully install Rails, the RoRT “hello_app” and launch it. But I don’t see any way of launching a web browser to look at the rails app. Do you happen to know how to do the equivalent of bringing up a browser in C9? I know that one can’t utilize an external browser, since the IP address used by the Rails app isn’t a “real” IP address (only exists inside the confines of the cloud IDE).


Once your Rails server is running you can use the C9 built-in browser by going to Preview > Preview Running Application.

You can also visit your application with any browser (Firefox, Chrome, etc.) at https://<workspace>-<your_username>


I realize that these seem like the newbiest of questions. But

HOW DO I go to Preview>Preview Running Application? I see no drop downs, buttons, options, etc.

And… please substitute MY and MY <your_username> into that URI. And do I run the browser within c9? If so, how do I do that?


It is right next to the Run button. When you preview the application, a new browser tab will pop up in the IDE. There is a button in that browser that let’s you pop out into a real browser.


I see no RUN button. I see no way to preview the application.



How can I say this in a way that will come across?

I don’t see any of that in any tab that I have open in C9. Tell me how to get to a place where those drop down things are.


Could you take a screenshot of your environment so we can figure out what’s different with it?



I have done the following.

gem install rails -v 5.0.1 (in workspace)
rails new myapp -d postgresql
rake db:create
rails s -b $IP -p $PORT

Rails’ welcome screen shows up OK.

I have an existing Rails app on github. I clone it to a new directory. So how do I run that app on Cloud9?


Run bundle install inside the cloned repository and make sure the database is configured to work with the cloned application. Everything should work just the same then.