WebFaction
Community site: login faq

This is a newbie follow-up question to those that SeanF answered at https://community.webfaction.com/questions/18582/newbie-question-about-installing-gems-for-rails and https://community.webfaction.com/questions/2898/rails-environment-vs-rails-application. I'm posting it as a new question so others who have this question can find it more easily.

Through the Control Panel, I have set up one Rails environment, named rails_eval. Like a previous questioner, I'll use the word "environment" here to mean what WebFaction calls an "application" - everything in the rails_eval folder that the Control Panel created for me - because I need the word "application" to mean what Rails calls an "application" - for example, the contents of the hello_world folder that the CP created within the rails_eval folder. An environment can contain one or more applications, and that's what this question is about.

So what I want to do is create a new, skeletal app (called portal_ror) in the rails_eval folder. The "Deploying a Ruby on Rails Application" section of the WF Rails instructions at http://docs.webfaction.com/software/rails.html instructions tells me how to import an existing app from somewhere else. That's not what I want to do. I want to develop the new Rails app in place on the WF server, right from the start.

How can I do that?

Or is developing on the server an unworkable idea?

~ Tx, Ken

asked 20 May '15, 19:22

kenatsun
1929
accept rate: 20%

edited 20 May '15, 19:22


Developing on the server is no problem.

If you want to create a new rails app in your rails_eval directory, first go to that directory:

cd ~/webapps/rails_eval

Then, set up your shell environment so that Ruby will know where to find your gems:

export GEM_HOME=$PWD/gems
export RUBYLIB=$PWD/lib
export PATH=$PWD/bin:$PATH

Then, use the rails command to create your new app:

rails new portal_ror

Then, edit ~/webapps/rails_eval/nginx/conf/nginx.conf to change "hello_world" to "`portal_ror'".

Then, finally, restart your app.

Hope that helps!

permanent link

answered 20 May '15, 22:33

seanf
12.2k41836
accept rate: 37%

Excellent.

One more question: Now that I've set "portal_ror" as the root, is there any way for a request to bring up the other app ("hello_world")?

(20 May '15, 23:40) kenatsun

Yes, just use multiple server blocks in your nginx.conf, like this:

server {
    listen             26326;
    server_name  domain1.com;
    passenger_enabled  on;
    root               /home/you/webapps/rails_eval/portal_ror/public;
    server_name        localhost;
    rails_env          development;

}
    server {
    listen             26326;
    server_name  domain2.com;
    passenger_enabled  on;
    root               /home/you/webapps/rails_eval/hello_world/public;
    server_name        localhost;
    rails_env          development;

}

Then, in the control panel, assign the app to the websites for domain1.com and domain2.com.

(20 May '15, 23:49) seanf

Even more excellent! (Tho the server defs your presented had a redundant definition of "server_name", which Rails promptly caught with an apt error message.)

And I notice that one can even have a third app in the environment to which the server_name localhost can be assigned. This app is brought up with whatever domain name is assigned to the environment as a whole. Sean, obviously you know this; I mention it here just so the next newbie like me doesn't have to rediscover it through trial and error.

(22 May '15, 02:47) kenatsun
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×108
×57

question asked: 20 May '15, 19:22

question was seen: 1,414 times

last updated: 22 May '15, 02:47

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM