Search code examples
ruby-on-railsrubymultiple-projectsdiaspora

How to start another rails project along with the current project on Ubuntu 12.04?


I was trying to run another Rails project along with Diaspora.
I used the commands rails server -p 3001 and rails server -p 3002 in the same directory with cd Diaspora.
I visited http 127.0.0.1:3001 and in project two http 127.0.0.1:3002.
But I could open diaspora server only on both the ports.
I also tried to create a new project folder (Projects) in the directory Diaspora.

cd Diaspora
cd Projects
rails new project2

I got this output:

Can't initialize a new Rails application within the directory of another, please change to a non-Rails directory first.
Type 'rails' for help.

How do I solve this problem?


Solution

  • It looks like you started Diaspora two times.

    First make sure to you have Diaspora and your other projects alongside each other, not nested.

    ~/Diaspora
    ~/Projects
    

    Then change into your projects folder, get the latest version of Rails and create a new project:

    cd ~/Projects
    gem install rails
    rails new project2
    cd project2
    bundle install
    

    There start your other project first:

    cd ~/Projects/project2
    bundle exec rails server -p 3002
    

    Now in a second shell start Diaspora:

    cd ~/Diaspora
    bundle exec rails server -p 3001
    

    Make sure to use bundle exec to avoid any version conflicts between the gems Diaspora uses and the gems your new application uses.