Forums/Community/Questions & Answers

Answered

Ruby on Rails

David Vaassen
asked this on January 24, 2012 02:47

Can I currently use Cloud9 for Ruby on Rails development?  Can I run tests, view the equivalent of localhost: etc. 

 

Comments

User photo
YogiZoli
Ajax_loader_small Answer

Would be awesome to use with RVM too!

February 17, 2012 06:52
User photo
Charles de Bueger
Ajax_loader_small Answer

The Cloud9 home page says I can run ruby projects - and it seems to have opened a rails project intelligently, but it doesn't look like I have enough to actually do any real development. Searching the knowledge base for rails gave me 0 results. Running rails s to start the server in the console doesn't seem to have done anything (I guess I need to somehow install rails and all the gems into my cloud9 env or something?) and deploy wants to send it to a real server (ie heroku, joyent....) to run there. Am I missing something - or is just plain and simple not supported right now?

February 23, 2012 18:45
User photo
Me

Still have yet to successfully build ruby this way. Has anyone gotten this to work?

July 13, 2012 05:29
User photo
Dima

What kind of problems have you encountered?

Maybe it works only on premium accounts, but for me it worked on a number of public/private workspaces.

Of course it is a kind of broken way to do things, I think Cloud9 should install ruby1.9 alongside ruby1.8. 

July 13, 2012 05:38
User photo
Me
Ajax_loader_small Answer

I'm currently on a premium account. I have tried this in two workspaces. The script never finishes executing. In some cases, the entire workspace becomes unresponsive.

Without being able to run tests before committing, cloud9 is *not* a viable work environment for ruby projects. 1.8.7 is unacceptably ancient in this regard. If there is only one ruby version installed it should be the current stable release.

Barring that, allowing RVM or something would be acceptable, but I have had less luck with that route.

July 13, 2012 20:06
User photo
Me

So, it looks like I was finally able to get this to run on one of my workspaces. 

[bm5k@cloud9]:/workspace$ ruby -v # => ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

However, when I try to run bundle install, I get  syntax errors for hashes that use the 1.9 syntax, and I am unable to install gems.

July 13, 2012 20:41
User photo
Me
[bm5k@cloud9]:/workspace$ which ruby
/var/lib/stickshift/d86d5144b9ca4dee817614e40e118166/app-root/data/bin/ruby
[bm5k@cloud9]:/workspace$ /var/lib/stickshift/d86d5144b9ca4dee817614e40e118166/app-root/data/bin/ruby -v
Permission denied
July 13, 2012 20:48
User photo
Me

sorry about all the white space

July 13, 2012 20:48
User photo
Dima

I feel your pain. It is obviously wrong way of getting modern Ruby on Cloud9.

To have bundler you need to run:

gem install bundler

And "rm -rf installs", or you will get into file quota error (Cloud9 workspaces allow only 40k files). I modified original script to include these messages.

July 14, 2012 01:52
User photo
Me

I've got bundler installed

$ bm5k@cloud9]:/workspace$ bundle install
Gemfile syntax error:
/var/lib/stickshift/d86d5144b9ca4dee817614e40e118166/app-root/data/231847/Gemfile:6: syntax error, unexpected ':', expecting $end
gem 'best_in_place',  git: 'git://github.com/bernat/best_in_place.git' 

July 14, 2012 06:04
User photo
daniel anggrianto

i run into the same problem when i try to run rspec it threw me this error

 

<internal:gem_prelude>:1:in `require': cannot load such file -- rubygems.rb (LoadError)
from <internal:gem_prelude>:1:in `<compiled>'
August 31, 2012 03:23
User photo
Robb Shecter

FYI, it's working for me: A Rails 3.2.8 app, ran bundle install, and now rake -T shows all my tasks.

I'm not sure how the development process would work here - e.g., there are no databases set up. I guess I could open one up on a server. 

September 26, 2012 11:23
User photo
Denis Peplin
Ajax_loader_small Answer

It's working for me too, but when I run rails server, it says `permissions denied`.

 

Probably, binding to 0.0.0.0 is not allowed, but what address to use in this case?

September 29, 2012 12:13
User photo
Denis Peplin

There is new docs available, Rails can be run now!

https://docs.c9.io/running_a_rails_app.html

rails s -b $IP -p $PORT

October 04, 2012 21:01
User photo
Me

Running `bundle install` definitely works now. I haven't tried running the server locally in the workspace yet. I have had some luck with using heroku postgres, although it is quite slow.

October 17, 2012 04:31
User photo
Tnypxl
Ajax_loader_small Answer

Anyone know how to get databases working?

December 21, 2012 16:49
User photo
Cloud9 IDE Support
Cloud9 IDE, Inc

Simply running rails:

rails s -b $IP -p $PORT

More rails docs can be found in https://docs.c9.io/running_a_rails_app.html

Same for rails testing and any other server start operations - Just configure your tests to use port $PORT and host $IP

Switch ruby versions:

rvm use 1.9.3 or rvm use 1.8.7

More on Ruby & RVM support https://docs.c9.io/writing_a_ruby_app.html

For database: You can use sqlite3 (it's already installed on workspaces)

January 31, 2013 13:33