-
Notifications
You must be signed in to change notification settings - Fork 0
new steps
fancyoung edited this page Nov 1, 2011
·
4 revisions
rails new abc --skip-active-record
bundle install
git init
git add .
git ci -m 'xxx'
gem 'bson_ext' # $ rails s 启动时提示要加这一行 gem 'compass' # CSS框架 gem 'haml' # 模板语言 gem 'mongoid' # mongodb的Object-Document-Mapper封装 gem 'fancy-buttons' # 美化按钮 gem 'devise' # 认证(authentication)框架 # 添加到assets group gem 'nifty-generators' gem 'haml-rails' # haml生成器
bundle install
生成mongoid配置
rails g mongoid:config
compass init rails . --using blueprint/semantic
生成后调整生成文件的路径
更换之前html页面,之前用$rails g nifty:layout –haml –scss 的话可自动生成haml,可略过此步
rm app/views/layouts/application.html.erb
touch app/views/layouts/application.html.haml
rm app/assets/stylesheets/application.css
touch app/assets/stylesheets/application.scss
并且添加:
!!!
%html
%head
%title rails-compass-haml-sass-scss
= stylesheet_link_tag 'compiled/screen.css', :media => 'screen, projection'
= stylesheet_link_tag 'compiled/print.css', :media => 'print'
/[if lt IE 8]
= stylesheet_link_tag 'compiled/ie.css', :media => 'screen, projection'
= csrf_meta_tag
%body.bp
#container
= yield
修改config/application.rb 在config.filter_parameters += [:password] 下一行添加:
config.generators do |g|
g.template_engine :haml
end
rm public/index.html
rails g controller home index
config/routes.rb 里添加默认路径:
root :to => "home#index"
用nifty的话有些地方需要修改
rails g nifty:layout --haml
rails g nifty:scaffold Post title:string --haml --skip-migration
rails generate devise:install
生成完毕后,请注意出现的提示,可能需要做一些修改,比如:
# 添加至config/environments/development.rb
# 应该是在config.action_mailer.raise_delivery_errors = false 后
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
# "User"也可以用其他名字,比如"Admin"
rails g devise User
添加至某controller测试是否安装成功(可选)
before_filter :authenticate_user!, :except => [:index, :show]
现在权限已能使用,为了将来修改方便,建议将views取出(可选)
#
rails g devise:views
# 生成views/devise文件夹,若想生成的目录为users,则:
# $ rails g devise:views users
# 为了生成haml,记得Gemfile里加上:hpricot和ruby_parser
# Gemfile里加上(dependencies of html2haml,devise生成haml模板必用)
# gem 'hpricot'
# gem 'ruby_parser'
# 然后执行 $ rails g devise:views -e haml
# 但是不知为何现在不生效
# 所以建议先手工转,参考:https://gist.github.com/1318948
devise I18n 选取一配置文件保存至config/locales/devise.zh-cn.yml
# config/application.rb里添加
config.i18n.default_locale = 'zh-cn'.to_s