20.2. Creating a New Rails Project

简介:

export PATH=$PATH:/home/neo/.gem/ruby/1.8/bin

20.2.1. Creating the Blog Application

$ rails blog
      create
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  config/locales
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application_controller.rb
      create  app/helpers/application_helper.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/locales/en.yml
      create  db/seeds.rb
      create  config/initializers/backtrace_silencers.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/initializers/session_store.rb
      create  config/environment.rb
      create  config/boot.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/runner
      create  script/server
      create  script/plugin
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  test/test_helper.rb
      create  test/performance/browsing_test.rb
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
			

20.2.2. Configuring a Database

default database

$ gem install sqlite3-ruby
			

$ rails blog -d mysql
or
$ rails blog -d postgresql
			

20.2.2.1. Creating the Database

$ cd blog
$ rake db:create
				

20.2.3. Hello world

home controller

$ script/generate controller home index
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/home
      exists  test/functional/
      create  test/unit/helpers/
      create  app/controllers/home_controller.rb
      create  test/functional/home_controller_test.rb
      create  app/helpers/home_helper.rb
      create  test/unit/helpers/home_helper_test.rb
      create  app/views/home/index.html.erb
			

edit view

$ vim app/views/home/index.html.erb
			

20.2.4.  Starting up the Web Server

$ script/server
=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-05-22 16:24:04] INFO  WEBrick 1.3.1
[2010-05-22 16:24:04] INFO  ruby 1.9.1 (2010-01-10) [x86_64-linux]
[2010-05-22 16:24:04] INFO  WEBrick::HTTPServer#start: pid=30711 port=3000
			

20.2.5. Setting the Application Home Page

The first step to doing this is to delete the default page from your application

$ rm -rf public/index.html
or
$ mv public/index.html public/index.html.off
			

$ vim config/routes.rb

  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
  map.root :controller => "home"
			

20.2.6. FAQ

http://rbjl.net/20-rubybuntu-2-troubleshooting-common-ruby-ubuntu-problems





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
6月前
|
Java Maven 开发工具
maven导入项目出现Unable to import maven project: See logs for details
maven导入项目出现Unable to import maven project: See logs for details
53 0
maven导入项目出现Unable to import maven project: See logs for details
|
3月前
|
Java Maven
IDEA 报 Unable to import maven project: See logs for details
IDEA 报 Unable to import maven project: See logs for details
48 0
|
Android开发 开发工具 IDE
Android gradle问题解决: This app has been built with an incorrect configuration. Please configure your build for VectorDrawableCompat
1. 问题描述: Android Studio在运行模拟器某些机型或者真机某些机型的时候发生闪退。 错误如下: Java.lang.RuntimeException: Unable to start activity ComponentInfo{com.
2358 0
|
C++ iOS开发
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
链接如下:【金山文档】 1-Microsoft Visual C++ Build Tools。找了好久,才找到正确的解决方案,网上一大堆升级setuptools的方法只对少数人管用。注意,虽然我的这个报错内容有点长,但是我感觉和其它的。如果网页提示登录,可以不用登录,直接下载即可。然后打开镜像ios文件(双击即可)错误是一样的解决方案。文件,打开后安装即可。
2633 1
报错解决:Could not build wheels for soxr, which is required to install pyproject.toml-based projects(可用)
|
数据安全/隐私保护
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
导入 Walle 时报:ERROR: A problem occurred configuring project ':app'.
|
Android开发
Migrate Project to Gradle? This project does not use the Gradle build system
Migrate Project to Gradle? This project does not use the Gradle build system
100 0
|
Java Maven
控制台:Unable to import maven project: See logs for details日志:Unable to create injector, see the follow
控制台:Unable to import maven project: See logs for details日志:Unable to create injector, see the follow
179 0
控制台:Unable to import maven project: See logs for details日志:Unable to create injector, see the follow
|
Java 应用服务中间件
Artifact SSMTest:war exploded: Error during artifact deployment. See server log for details.
Artifact SSMTest:war exploded: Error during artifact deployment. See server log for details.
734 0
Artifact SSMTest:war exploded: Error during artifact deployment. See server log for details.
|
Java Maven
Unable to import maven project: See logs for details IDEA问题解决办法
本文介绍Unable to import maven project: See logs for details IDEA问题的解决办法。
361 0
Unable to import maven project: See logs for details IDEA问题解决办法
|
Ruby 开发工具 关系型数据库