Skip to content

Instantly share code, notes, and snippets.

@johnable
Created March 23, 2016 07:24
Show Gist options
  • Save johnable/4a4f5ec679876a66b145 to your computer and use it in GitHub Desktop.
Save johnable/4a4f5ec679876a66b145 to your computer and use it in GitHub Desktop.
##Amalgam CMS v3.x新建项目指南
###1. 从模板新建:
包含表单的版本:
git clone [email protected]:xtunes/cms_template.git -b with_request 项目名称
不包含表单的版本:
git clone [email protected]:xtunes/cms_template.git 项目名称
- 其中项目名称为导出的目录名, 在生成部署脚本时会被用作默认的项目名称
- [规则]项目名称使用项目域名,以便部署
###2. 重新建立Git库
rm -rf .git #删除模板的git信息
git init
git add .
git commit -am 'Initial Commit' #初始化提交
git remote add <name> <url> #添加远端地址
###3.安装依赖
在程序根目录执行`bundle`
###4. 设定网站
####设定secret token
- 生成一个64位的随机字符串,可以使用以下命令:
`ruby -e "require 'securerandom';puts SecureRandom.hex(64)"`
- 将生成的代码填入 `config/settings.yml` 中覆盖原值
####设定session key
- 编辑 `config/initializers/session_store.rb` 修改 `key` 为网站域名相关, 如`marrymeqiuhun_cms_session`
- 此举是为与其他.xtunes.cn域名下网站隔离,以防冲突或安全问题
####设定数据库
从database.yml.example复制一份到新建文件database.yml
可在程序目录执行以下命令:
cp config/database.yml.example config/database.yml
然后编辑 database.yml ,设定相应的数据库信息, 并创建数据库
rake db:create
然后编辑 db/migrate 下的数据表结构, 添加需要的自定义字段. 例如,以下代码修改了附件模型,增加了link字段
#20130122032805_create_attachments.rb
class CreateAttachments < ActiveRecord::Migration
create_table :attachments do |t|
t.references :attachable ,:polymorphic => {:default => 'Page'}
t.string :name
t.string :file
t.string :content_type
t.string :original_filename
t.string :description
t.string :link #=> 添加一个字段
t.string :secure_token
t.integer :file_size
t.integer :position
t.timestamps
end
end
创建表结构:
rake db:migrate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment