Unable to run ruby on rails app? - ruby-on-rails

I am unable to run ruby on rails application. I setup the database and loaded database schema. When I run:
ruby script/server -e production
It says:
=> Booting Mongrel
=> Rails 2.3.2 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Crtl-C to shutdown server
and it just stays there. If I go to the directory where the app is installed, it just lists the directory of files and doesn't run the app. Any suggestions?
Thanks

Have you opened http://localhost:3000/ in a browser?
The '=> Booting Mongrel ...' stuff means the server is running, you just need to navigate a browser to it.

You are starting your server in production mode.
Use the development mode fpr debugging, it will give you a better log output.
Run ruby script/server -e development

Related

Running Rails S with a fresh new app returns ERR_EMPTY_RESPONSE

I am using Vagrant to start a Rails app, everything seems right but then, when I create a test app, run rails s and go to localhost:3000 I get a ERR_EMPTY_RESPONSE and nothing is loaded. I get the following output when running rails s:
vagrant#rails-dev-box:~/projects/NewAppName$ rails s
=> Booting WEBrick
=> Rails 4.2.3 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-08-20 11:45:45] INFO WEBrick 1.3.1
[2015-08-20 11:45:45] INFO ruby 2.2.1 (2015-02-26) [i686-linux]
[2015-08-20 11:45:45] INFO WEBrick::HTTPServer#start: pid=12075 port=3000
I already ran rake db:create && rake db:migrate, and created a controller for the root. Anyone has an idea of what can be happening? Thank you.
It's in localhost on vagrant, so you can't connect it.
Try rails s -b 0.0.0.0 and then connect to vagrant IP(192.168.50.4:3000, for example).

Michael Hatl's Rails Tutorial Chapter 2: Errno::ENOENT in UsersController#index when testing /users

When generating toy_app using scaffolding I can go to the root site using the local server, but when I try to go to the page /users I get the following error message: "Errno::ENOENT in UsersController#index"
The page should allow me to enter a new user.
When I try to restart the server and run rails server -b $IP -p $PORTI get the following:
sunny_dee#rails-tutorial:~/workspace/toy_app (master) $ rails server -b $IP -p $PORT
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://0.0.0.0:8080
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2015-04-27 18:06:55] INFO WEBrick 1.3.1
[2015-04-27 18:06:55] INFO ruby 2.1.5 (2014-11-13) [x86_64-linux]
Exiting
/usr/local/rvm/rubies/ruby-2.1.5/lib/ruby/2.1.0/socket.rb:206:in `bind': Address already in use - bind(2) for 0.0.0.0:8080 (Errno::EADDRINUSE)
I finally got it to work by restarting the workspace. I'm guessing that is what restarted the local server. I was trying Ctrl-C but it was not working.
The tutorial uses Cloud9 and since it's a cloud IDE closing/logging out did nothing but when I clicked on the button to the left of "Share" on the top right corner and the clicked on "Restart" the page ran correctly.
Hopefully my stupid question can help someone else as well. Thanks everyone that took the time to contribute :)
If you running this application in your local Linux system just use -
rails server
Then you can access your site using http://localhost:3000/
You can also specify which port to run on using this command -
rails s -p 3001 -P tmp/pids/server2.pid
Then you can access using 3001 port.
You are getting that error because your 8080 port is already in use by some other process.

WEBRick stays booting for an indefinite amount of time, no error message

I'm trying to execute rails s -e production on an installation of OpenCongress inside a Vagrant box (Ubuntu precise64) that already works in development mode. When I try to run the server in production I get this:
=> Booting WEBrick
=> Rails 3.0.20 application starting in production on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** [Raven] Raven 0.7.1 ready to catch errors
Where it stays for an indefinite amount of time. I can't access the app at localhost:3000, and given the fact that there's no error message, I can't diagnose what is going on.
The app runs on a Postgres DB, the production table specified in database.yml exists in the DB. I sincerely don't know what's going on.
EDIT: Commenting out the gems particular to production in the Gemfile doesn't have any effect whatsoever. Also, trying to run the app with Thin by executing bundle exec thin -e production stays on the Raven message too, and after this the process is not killable (sending the Ctrl-Csignal shows an "Stopping..." message that does not go away).
You are using this gem. I would read up on the different configurations to get the behavior you want.

Why can't I connect to my Heroku rails app when I run the server manually?

In trying to debug another problem, I've tried starting up my Heroku Rails app from the command line using heroku run rails server. The output seems fine, as follows, but attempts to connect to it from the browser fail. If I don't specify a port number, I get the generic "application error" page from Heroku. If I try to connect on port 3000, the browser tells me it cannot connect.
Here's the output to the console after starting up the server:
Running `rails server` attached to terminal... up, run.9912
=> Booting WEBrick
=> Rails 4.0.1 application starting in production on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2013-11-18 01:52:55] INFO WEBrick 1.3.1
[2013-11-18 01:52:55] INFO ruby 2.0.0 (2013-06-27) [x86_64-linux]
[2013-11-18 01:52:55] INFO WEBrick::HTTPServer#start: pid=2 port=3000
I did note the all zeros IP address.
I am unaware of any ability to run Heroku in the fashion you describe. In my experience, you deploy when you push your code the the Git remote on Heroku, and the code runs according to the Procfile you provide in the codebase. Then Heroku configures all kinds of environment settings to enable your app to run properly.
Once there, you can also do a heroku restart for whatever reason.
Incidentally, you probably would be better off ditching WEBrick for Unicorn or Thin.
If seems you're running your app like a localhost process from Heroku...If I'm not mistaken.
Why don't you just run through
heroku run ps:scale web=1

Can't type after "ruby script/server" in InstantRails

I'm a newb to RoR. I'm using the book "Agile Web Development with Rails" to get started on Windows 7.
In the command window, I run the following.
>rails demo
>cd demo
>ruby script/server
At this point, it boots the Mongrel server:
=> Booting Mongrel
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
The book goes on to tell me to run
ruby script/generate controller Say
but, I cannot Ctrl-C -- or type anything for that matter -- after booting the Mongrel server. Am I supposed to create the new controller in another instance of the InstantRails command window? Right now, the only way I can stop the server is closing the window in which I started the server!
Please let me know if you need any other details. tia.
You can always open a new window and run those commands from there.
You either need to put the job in the background or fire up another shell. Control-C should still work, however.

Resources