Ruby on rails 脚本/rails vs rails
我正在编写一个教程,演示一些rails命令。在我的机器上,Ruby on rails 脚本/rails vs rails,ruby-on-rails,ruby-on-rails-3,Ruby On Rails,Ruby On Rails 3,我正在编写一个教程,演示一些rails命令。在我的机器上,rails和script/rails两者都工作得同样好。是否有“首选”表格?这两个选项中哪一个更通用?在Rails 3中,它应该是Rails。在Rails 3中,它应该是Rails rails …当您在rails 3应用程序中运行rails可执行文件时,它会查找脚本/rails文件,如果存在,则使用传递给rails的参数执行该文件 使用rails而不是script/rails的原因通常在于它较短 还有一点需要注意,还有rails c命令
rails
和script/rails
两者都工作得同样好。是否有“首选”表格?这两个选项中哪一个更通用?在Rails 3中,它应该是Rails。在Rails 3中,它应该是Rails
rails
…当您在rails 3应用程序中运行
rails
可执行文件时,它会查找脚本/rails
文件,如果存在,则使用传递给rails
的参数执行该文件
使用rails
而不是script/rails
的原因通常在于它较短
还有一点需要注意,还有
rails c
命令,在rails2应用程序中,它将在当前目录中生成一个名为c
的应用程序文件夹。使用script/rails
,这不会发生;相反,它会抱怨script/rails
不存在。rails s
或rails g scaffold
查找script/rails
,只需传入参数即可rails
通常更受欢迎,因为它更短,打字更快。但是,如果有人试图在rails 2.X应用程序中使用rails s
或rails c
,它会添加另一个同名的应用程序文件夹,因为2.X中的rails命令会生成一个应用程序
如果您的演示程序设计为在Rails 3上运行,只使用
Rails…
如果是为了更一般的目的,请务必提及Rails 2使用script/server…
而不是Rails…
您应该只编写Rails,这不是因为它是首选的,而是因为从现在起它将成为标准。
script/rails在以前版本的rails中使用过,现在已经弃用
然而,这两个命令在此时的效果是相同的,使用rails没有什么不能做的,相反,script/rails
script/rails
命令用于Rails2。Rails 3使用Rails
<代码>脚本/命令在我的安装中不起作用。“rails”将显示有关脚本使用的所有信息:
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.
rails社区提供了许多选项,使开发人员的生活更轻松。命令rails也做同样的事情,很多开发人员都在使用它。由于同样的原因,rails非常流行。如果您使用Bundler,那么说起来更安全
bundle exec rails
这样,您就可以放心地运行应用程序包中的rails版本。同样的道理也可以说
bundle exec rake
在窗口控制台中,我们必须编写ruby脚本/服务器 但在Ubuntu脚本/服务器上就足够了
rail3的rails s和rails c只能在项目应用程序文件夹中访问。具体来说,使用此选项将中断操作系统从环境路径定位
rails
的尝试,并可能引发错误(就像在我的电脑上那样)。要创建新的Rails应用程序,script/Rails
将不起作用,但Rails
会起作用。我建议您坚持使用rails
命令
其他命令,如
script/generate
,script/server
,script/console
都已成为rails
调用的参数。No,在旧版本的rails中没有script/rails
。对于rails 2,它是脚本/server。我还为所有rails 2和3命令在my.bashrc中放置了大量别名,例如,问题是是否有首选表单。如果周围有Gemfile,则捆绑gems中已经运行了rails。