Ruby On Rails Where's my app?

July 21, 2014 4.3k views

I'm using ruby on rails one click installer

What I've done so far is

1.rvm use 2.0.0

2.rails new website

3.rails generate scaffold status name:string content:text

4.rake db:migrate

5.rails server

Goto my digital ocean I.P

http://165.233.62.89/statuses/

But I get message

"The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved."

Where can I find my app I've just started please?

Thanks for your help

7 Answers

By default, a Rails app created and served like that should be available on port 3000. When you run rails server the output should tell you what port it runs on:

# rails server
=> Booting WEBrick
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2014-07-21 16:19:30] INFO  WEBrick 1.3.1
[2014-07-21 16:19:30] INFO  ruby 2.0.0 (2013-11-22) [x86_64-linux]
[2014-07-21 16:19:30] INFO  WEBrick::HTTPServer#start: pid=1943 port=3000

I'd suggest that you take advantage of the unicorn app server and Nginx proxy that are installed on the one click image by creating your app in the /home/rails directory. See this article for more details.

Thank you for your help :)

this is my first time with ruby

I went to

nano /home/unicorn/unicorn.conf

listen "112.0.0.1:8080"
worker_processes 2
user "rails"
working_directory "/home/**mysite**"
pid "/home/unicorn/pids/unicorn.pid"
stderr_path "/home/unicorn/log/unicorn.log"
stdout_path "/home/unicorn/log/unicorn.log"

and

server {
        listen   80;
        root /home/**mysite**/public;
        server_name _;
        index index.htm index.html;

        location / {
                try_files $uri/index.html $uri.html $uri @app;
        }

then I did

rails server

Then I went to

http://112.0.0.1:8080

But the page was blank?

Many thanks for your help

Where did you get that IP address 112.0.0.1? That should probably be 127.0.0.1.

Sorry I changed the IP address in this forum
post 127.0.0.1 because I thought might be a security risk

The I.P address is 127.0.0.1

but the IP address 127.0.0.1:8080

still shows a blank page

Many thanks for your help

  • Are there any errors in Nginx's error log?

    sudo tail -30 /var/log/nginx/error.log
    

    Checking Unicorn's error log might help too:

    sudo tail -30 /home/unicorn/log/unicorn.log
    

For future reference, publishing 127.0.0.1 is not a security risk. 127.0.0.1 is known as the loopback address, and is essentially just a self-referencing IP address. It is frequently used when communicating with another service on the same droplet, which is what is going on here - Nginx receives a external request on port 80 (the standard HTTP port) and sends that request on to Unicorn internally using port 8080.

*Then I went to

http://112.0.0.1:8080

But the page was blank?*

Are you saying that you are trying to view 127.0.0.1:8080 in your browser? If that's the case, you probably won't see anything, because you are trying to view a web page on your own machine. (See my other comment regarding 127.0.0.1/loopback address.)

Your Unicorn server should be listening on 127.0.0.1:8080. Once configuration is done and the application is running, view the site using your droplet's IP address. You should see what you're expecting to see, assuming that the Nginx proxy is configured correctly.

I take I need to change this line to my application folder.
Is that right?

nano /home/unicorn/unicorn.conf

listen "127.0.0.1:8080"
worker_processes 2
user "rails"

working_directory "/home/rails"

pid "/home/unicorn/pids/unicorn.pid"
stderrpath "/home/unicorn/log/unicorn.log"
stdout
path "/home/unicorn/log/unicorn.log"

listen "127.0.0.1:8080"
worker_processes 2
user "rails"

working_directory "/home/rails/myfirstapp"

pid "/home/unicorn/pids/unicorn.pid"
stderrpath "/home/unicorn/log/unicorn.log"
stdout
path "/home/unicorn/log/unicorn.log"

Have another answer? Share your knowledge.