广告
返回顶部
首页 > 资讯 > 后端开发 > Python >Rails 3 Script/ 改版
  • 196
分享到

Rails 3 Script/ 改版

RailsScript 2023-01-31 02:01:25 196人浏览 泡泡鱼

Python 官方文档:入门教程 => 点击学习

摘要

1.环境 # ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux] # rails -v Rails 3.0.7 gem -v 1.3.7  # 

1.环境

  1. # ruby -v 
  2. ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-linux]
  1. # rails -v 
  2. Rails 3.0.7
  1. gem -v 
  2. 1.3.7 
  1. # gem list 
  2.  
  3. *** LOCAL GEMS *** 
  4. abstract (1.0.0) 
  5. actionmailer (3.0.7) 
  6. actionpack (3.0.7) 
  7. activemodel (3.0.7) 
  8. activerecord (3.0.7) 
  9. activeresource (3.0.7) 
  10. activesupport (3.0.7) 
  11. addressable (2.2.4) 
  12. arel (2.0.10) 
  13. bson (1.3.1) 
  14. bson_ext (1.3.1) 
  15. builder (2.1.2) 
  16. bundler (1.0.13) 
  17. capistrano (2.6.0) 
  18. capybara (0.4.1.2) 
  19. celerity (0.8.9) 
  20. childprocess (0.1.9) 
  21. configuration (1.2.0) 
  22. cucumber (0.10.2) 
  23. cucumber-rails (0.4.1) 
  24. culerity (0.2.15) 
  25. database_cleaner (0.6.7) 
  26. diff-lcs (1.1.2) 
  27. erubis (2.6.6) 
  28. factory_girl (2.0.0.beta2, 1.3.3) 
  29. factory_girl_rails (1.1.beta1, 1.0.1) 
  30. faraday (0.6.1) 
  31. fcgi (0.8.8) 
  32. ffi (1.0.9) 
  33. gherkin (2.3.8) 
  34. highline (1.6.2) 
  35. i18n (0.5.0) 
  36. JSON (1.5.1) 
  37. json_pure (1.5.1) 
  38. launchy (0.4.0) 
  39. login_generator (1.2.2) 
  40. mail (2.2.19) 
  41. mime-types (1.16) 
  42. minitest (1.6.0) 
  43. monGo (1.3.1) 
  44. mongoid (2.0.2) 
  45. mongoid-rspec (1.4.2) 
  46. multi_json (1.0.2) 
  47. multi_xml (0.2.2) 
  48. multipart-post (1.1.1) 
  49. Mysql2 (0.2.6) 
  50. net-ldap (0.2.2) 
  51. net-scp (1.0.4) 
  52. net-sftp (2.0.5) 
  53. net-ssh (2.1.4) 
  54. net-ssh-gateway (1.1.0) 
  55. nokogiri (1.4.4) 
  56. oa-basic (0.2.6) 
  57. oa-core (0.2.6) 
  58. oa-enterprise (0.2.6) 
  59. oa-more (0.2.6) 
  60. oa-oauth (0.2.6) 
  61. oa-openid (0.2.6) 
  62. oauth (0.4.4) 
  63. oauth2 (0.4.1) 
  64. omniauth (0.2.6) 
  65. polyglot (0.3.1) 
  66. pyu-ruby-sasl (0.0.3.2) 
  67. rack (1.2.2) 
  68. rack-mount (0.6.14) 
  69. rack-openid (1.3.1) 
  70. rack-test (0.5.7) 
  71. rails (3.0.7) 
  72. railties (3.0.7) 
  73. rake (0.9.0, 0.8.7) 
  74. rdoc (2.5.8) 
  75. rest-client (1.6.1) 
  76. rspec (2.6.0) 
  77. rspec-core (2.6.2) 
  78. rspec-expectations (2.6.0) 
  79. rspec-mocks (2.6.0) 
  80. rspec-rails (2.6.0) 
  81. ruby-fcgi (0.8.9) 
  82. ruby-openid (2.1.8) 
  83. ruby-openid-apps-discovery (1.2.0) 
  84. rubyntlm (0.1.1) 
  85. rubyzip (0.9.4) 
  86. selenium-WEBdriver (0.2.0) 
  87. sqlite3 (1.3.3) 
  88. sqlite3-ruby (1.3.3) 
  89. term-ansicolor (1.0.5) 
  90. thor (0.14.6) 
  91. treetop (1.4.9) 
  92. tzinfo (0.3.27) 
  93. xpath (0.1.4) 

2.尝试指令

相信如果之前用过 2.* rails 的人都知道. 我们习惯用 ./script/generate [xxxx] 或者 ./script/* [xxxx].

现在这些在rails 3.*都没有了?

  1. # rails new lala 
  2.       create   
  3.       ... ... 
  4.       create  script 
  5.       create  script/rails 
  6.       ... ... 

研究才发现,新版rails,在一次封装分类了.

  1. Usage: rails COMMAND [ARGS] 
  2.  
  3. The most common rails commands are: 
  4.  generate    Generate new code (short-cut alias: "g") 
  5.  console     Start the Rails console (short-cut alias: "c") 
  6.  server      Start the Rails server (short-cut alias: "s") 
  7.  dbconsole   Start a console for the database specified in config/database.yml 
  8.              (short-cut alias: "db") 
  9.  new         Create a new Rails application. "rails new my_app" creates a 
  10.              new application called MyApp in "./my_app" 
  11.  
  12. In addition to those, there are: 
  13.  application  Generate the Rails application code 
  14.  destroy      Undo code generated with "generate" 
  15.  benchmarker  See how fast a piece of code runs 
  16.  profiler     Get profile infORMation from a piece of code 
  17.  plugin       Install a plugin 
  18.  runner       Run a piece of code in the application environment 
  19.  
  20. All commands can be run with -h for more information. 

比如我们之前常用的,./script/generate controller [xxxx] 现改为:

  1. # ./script/rails generate controller account 
  2.       create  app/controllers/account_controller.rb 
  3.       invoke  erb 
  4.       create    app/views/account 
  5.       invoke  test_unit 
  6.       create    test/functional/account_controller_test.rb 
  7.       invoke  helper 
  8.       create    app/helpers/account_helper.rb 
  9.       invoke    test_unit 
  10.       create      test/unit/helpers/account_helper_test.rb 

同时加了几个选项:

  1. Usage: rails generate GENERATOR [args] [options] 
  2. General options: 
  3.   -h, [--help]     # Print generator's options and usage 
  4.   -p, [--pretend]  # Run but do not make any changes 
  5.   -f, [--force]    # Overwrite files that already exist 
  6.   -s, [--skip]     # Skip files that already exist 
  7.   -q, [--quiet]    # Suppress status output 

以此类推。。。

--结束END--

本文标题: Rails 3 Script/ 改版

本文链接: https://www.lsjlt.com/news/186707.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作