Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

script/rails vs rails

I'm writing a tutorial where I demo some rails commands. On my machine rails and script/rails both work equally well. Is there a "preferred" form? Which of the two works more universally?

like image 534
Jo Liss Avatar asked Feb 28 '11 21:02

Jo Liss


People also ask

What is a Rails script?

The Rails include code generation scripts, which are used to automatically generate model and controller classes for an application. Code generation increases your productivity when developing Web applications. By running generator command, skeleton files for all your model and controller classes will be generated.

Is Ruby on Rails or JavaScript better?

Differences between Ruby on Rails and Javascript Performance – Ruby on Rails has medium level performance as it doesn't support asynchronous programming. It also has a high CPU processing time, while Javascript has greater performance with asynchronous support and event driven single threaded architecture.

Is Ruby on Rails scripting?

Rails is also open-source, but it is not a scripting language. Ruby on Rails is a web development framework that is based on model view controller (MVC) architecture.

What is Ruby and RoR?

Ruby on Rails, sometimes known as "RoR" or just "Rails," is an open source framework for Web development in Ruby, an object-oriented programming (OOP) language similar to Perl and Python.


3 Answers

When you run the rails executable within a Rails 3 application, it looks for the script/rails file and, if it's present, executes that file with the arguments you passed to rails.

The reason why you'd use rails over script/rails generally falls down to the fact that it's shorter.

One more thing to note, there's also the rails c command which, in a Rails 2 application, will generate an application folder called c inside the current directory. Using script/rails, this wouldn't happen; instead it would complain that the script/rails doesn't exist.

like image 123
Ryan Bigg Avatar answered Oct 27 '22 08:10

Ryan Bigg


In Rails 3 it should be just rails.

like image 14
methyl Avatar answered Oct 27 '22 07:10

methyl


"rails" will show all about the script usage:

Usage: rails COMMAND [ARGS]

The most common rails commands are:
 generate    Generate new code (short-cut alias: "g")
 console     Start the Rails console (short-cut alias: "c")
 server      Start the Rails server (short-cut alias: "s")
 dbconsole   Start a console for the database specified in config/database.yml
             (short-cut alias: "db")
 new         Create a new Rails application. "rails new my_app" creates a
             new application called MyApp in "./my_app"

In addition to those, there are:
 application  Generate the Rails application code
 destroy      Undo code generated with "generate"
 benchmarker  See how fast a piece of code runs
 profiler     Get profile information from a piece of code
 plugin       Install a plugin
 runner       Run a piece of code in the application environment

All commands can be run with -h for more information.
like image 5
Anatoly Avatar answered Oct 27 '22 07:10

Anatoly