Understand rails server command - ruby-on-rails

As I'm newbie in Rails ,So is there any document which help me to understand the internal process of commands. Like when I use
$ rails server , so I need to understand what the process going behind the scene and how its started webric server and create a deameon IP if I used option $ rails server -d 198.0.0.0 etc..

Railties is what takes care of the command line interface, including rails server.
This file should be your entrypoint: https://github.com/rails/rails/blob/master/railties/lib/rails/commands/server.rb
You can see the default options and the option parser implemented in there.
However, if you want to dig deeper in how Rails communicates with the server, you should study Rack, since Rails is after all a Rack app.

You can watch through all of these screencasts and documentation from Rails Guide.
http://guides.rubyonrails.org/initialization.html
http://www.bigbinary.com/videos/2-how-rails-boots
http://railscasts.com/episodes/299-rails-initialization-walkthrough

Related

I have a complete ruby project on my system but how do I run it?

I have a complete ruby project on my system that I downloaded from github.com and I want to run it on my Windows machine.
I have already installed Ruby and Rails on my system, but I have no idea how to run this project. The directory of this project is something like:
C:\Users\{username}\Desktop\BitcoinFundi\BitcoinFundi
How would I run this project on my system?
To run your Ruby on Rails application, use the following command:
rails server
This will start the server and you will be able to access the application in your browser at http://localhost:3000. Port 3000 is default and you can change it in the application settings.
To run a Ruby script use:
ruby name_of_script.rb
You should check out various resources and tutorials on getting started with rails.
As you say in your comment this is your first experience with Ruby on Rails, I think you should follow through chapter 1 and 2 (at least) of Ruby on Rails Tutorial. After that you should have a better understanding of how you start up a rails app and configure the DB. You also need a bunch of other libraries and software such as mysql from the sounds of it.
You should also read Getting Started with Rails. Section 4 covers how to start the default rails server.
Here is a guide on setting up a Rails environment for Windows, which is one of many guides, that shows you some of the needed steps to get a fully working environment.

How to detach JRuby on Rails

I created a small application using Ruby on Rails and I recently transferred it to JRuby.
The issue I have is before when I was using MRI, I used to run the server using rails server -d to run it in the background.
Now with JRuby, it seems that this option is not available and I can't just leave it in the background.
Is there a way to do this? I've found a few threads on how to this using gems like spoon but I can't find any documentation on how to install then implement it on my application
Also, it seems the answers I found are little out dated.
I was wondering, are there new gems out there that can be easily installed/used to run a JRuby on Rails app in the background?
Any guidance would be greatly appreciated. Thank you.
I am not sure what OS you are using, but on linux/unix you can put any command into the background by placing an "&" after it. for example
rails server &
or if you have it running a cntl-z and then bg should place it into the background as well.
In Ubuntu it has to be
rails s -d &
The -d stands for run in detached mode.
the & is standard UNIX for command line detach.

Where can I find developer output from Rails application deployed to Torquebox

I have a JRuby on Rails application, which is usually deployed as war to Tomcat. In development mode we use either WEBrick or trinidad (usually first). Now we are considering using Toquebox.
I was able to deploy app using Torquebox, but I wonder where can I find development logs (things like request/response details, executed SQL queries etc). I got used to that stuff. JBoss'es console, boot.log and server.log don't contain those - only torquebox specific logging.
Thanks
When you are currently in your applications directory, use
$ less log/development.log
For every enviorement: env
$ less log/<env>.log
For following it (as it appends) use:
$ tail -f log/<env>.log

Any Xampp Like For Ruby On Rails?

I'm still new to ruby and i'm in the process to learn it, i'm actually using Xampp for php on windows, but i'm stuck at finding a complete package to install a RoR server just like Xampp without any manual work.
Is there any tool out there?
You can try Rails Installer
One of your choices is to use built in mongrel/webrick server which comes with each rails app. Just type $ rails s at the console and you're good to go. Otherwise I don't think it's particularly useful to deploy an app each time you change something.

Ruby on Rails: How to start the WEBrick server automatically on Windows in background?

In order to run the my Rails application on Windows XP I open a command line, cd to application's directory, and then run rails server.
I would like to automate this, such that every time I turn on my computer, all I'll have to do is to type localhost:3000 in a browser.
How could I do this ?
The simpler way is to create a batch file with the instruction what you give in the command prompt like
d:
cd projects\myapp
ruby script\server
and then drop a copy of the file to Windows Start -> All Programs -> start up folder.
You have few possibilities to do that.
using the registry you can use HKLM\Software\Microsoft\Windows\CurrentVersion\Run or the better approach would be to create a service, you can see this KB with some instruction how to make a service of whatever executable you want.
have you thought about , AUTOEXEC.BAT or creating some batch files. you create right cmd commands that are run at start up. http://www.aumha.org/a/batches.php
The best approach is turn your application into a service. There is a solution for Mongrel (a web server similar to webrick) called mongrel_service, but is not compatible with Rails 3 (due several changes of Rails internals)
However, you can repurpose mongrel_service codebase to work with thin, another webserver that works with Rails 3.
Please look here where is the only reference to mongrel_service script. changing it to thin start could work.
Perhaps is not the answer you're looking for (as there is some work to be done) but is something :)
start rubyw script/rails server webrick
start -> start in another console
rubyw -> run ruby detached from console

Resources