新手问题 关于 Rails 的数据库配置文件 database.yml 当中,Yaml 的表达式解释的问题,查阅了一些资料还是没有了解

kakaxi2 · 2015年10月04日 · 最后由 lb563 回复于 2015年10月06日 · 2184 次阅读
# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# 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: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3 

其中&default定义了引动点,*defalut进行了引用,不明白的地方在于符号<<:的作用是什么?

http://www.yaml.org/refcard.html

'<<' : Merge keys from another mapping.

#2 楼 @kakaxi2 把引用点的配置合并到你引用“<<“的地方

需要 登录 后方可回复, 如果你还没有账号请 注册新账号