这几天一直在研究一个 ROR 项目的 DEMO,发现 ruby 真的是一门很优秀的语言,但是刚刚入手,不像 Java,php 网上的资料一搜一大片,基本上有问题了去 overstack 上搜,但是正经学习的资料很少。昨天发了一个贴子,被屏蔽了,可以是因为我发的帖子太简单了,十分抱歉。 windows 下安装失败,怎么也搭不起来 ROR 环境。所以放到了云主机上(CentOS),环境搭建 OK。一点点开始研究代码,但是项目跑不起来。很苦恼,查不到资料,所以在这里发帖求助,先在这里谢谢大家!
问题一: 这里是这个项目的 database.yml 文件
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
pool: 5
username: root
password:
socket: /tmp/mysql.sock
# encoding: utf8
encoding: utf8mb4
collation: utf8mb4_unicode_ci
development:
<<: *default
database: iceage_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: iceage_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: iceage_production
host: <%= ENV['DATABASE_HOST'] %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
这里面 &default 与 <<: *default 是什么语法,还有 <%= ENV['DATABASE_HOST'] %>是什么语法? 这里我把
host: <%= ENV['DATABASE_HOST'] %>
username: <%= ENV['DATABASE_USERNAME'] %>
password: <%= ENV['DATABASE_PASSWORD'] %>
改为我自己的数据库。我运行 rake db:migrate RAILS_ENV=production
报错:
rake aborted!
YAML syntax error occurred while parsing /home/chenx/project-master/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): could not find expected ':' while scanning a simple key at line 55 column 3
/home/chenx/iceage-master/config/environment.rb:5:in `<top (required)>'
Psych::SyntaxError: (<unknown>): could not find expected ':' while scanning a simple key at line 55 column 3
/home/chenx/iceage-master/config/environment.rb:5:in `<top (required)>'
我该怎么配置一下着 database 呢? 谢谢!