标签:基础 七牛云 自定义 initial provider val migrate 技术 内容
身为管理者,我要能够登入后台
Bootstrap
gem ‘bootstrap-sass‘
mv app/assets/stylesheets/application.css app/assets/stylesheets/application.scss
@import "bootstrap-sprockets";
@import "bootstrap";
//= require bootstrap/alert
//= require bootstrap/dropdown
common/_navbar.html.erb
common/_footer.html.erb
weclome#index
flash提示
app/views/common/_flashes.html.erb
<% if flash.any? %>
<% user_facing_flashes.each do |key, value| %>
<div class="alert alert-dismissable alert-<%= flash_class(key) %>">
<button class="close" data-dismiss="alert">×</button>
<%= value %>
</div>
<% end %>
<% end %>
app/helpers/flashes_helper.rb
module FlashesHelper
FLASH_CLASSES = { alert: "danger", notice: "success", warning: "warning"}.freeze
def flash_class(key)
FLASH_CLASSES.fetch key.to_sym, key
end
def user_facing_flashes
flash.to_hash.slice "alert", "notice","warning"
end
end
Devise
rails g devise:install
rails g devise user
rake db:migrate
SimpleForm rails generate simple_form:install --bootstrap
font-awesome-rails
gem ‘carrierwave‘
gem ‘mini_magick‘
rails g uploader image
配置ASW S3 保存图片
gem ‘fog‘
config.fog_provider = ‘fog‘
config.fog_credentials = {
provider: ‘AWS‘,
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
region: ENV["AWS_REGION"]
}
config.fog_directory = ENV["AWS_BUCKET_NAME"]
七牛云
gem ‘carrierwave-qiniu‘
gem ‘qiniu-rs‘
config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.storage = :qiniu
config.qiniu_access_key = ENV["qiniu_access_key"]
config.qiniu_secret_key = ENV["qiniu_secret_key"]
config.qiniu_bucket = ENV["qiniu_bucket"]
config.qiniu_bucket_domain = ENV["qiniu_bucket_domain"]
config.qiniu_block_size = 4*1024*1024
config.qiniu_protocol = "http"
config.qiniu_up_host = "http://up.qiniug.com" #选择不同的区域时,"up.qiniug.com" 不同
end
gem ‘figaro‘
bundle install
figaro install
会自动生成 config/application.yml 文件并自动添加到 .gitignore 档案里
cp config/application.yml config/application.yml.example
production:
XXXXX_KEY_ID: ""
development:
XXXXX_KEY_ID: ""
#排版缩进 非常重要,否则报错
一键部署机密信息到heroku
figaro heroku:set -e production
heroku config
可以列出目前所有的设定
config/environments/production.rb
Rails.application.configure do
...(略)
# config.action_mailer.delivery_method = :letter_opener #dev环境本地预览邮件
config.action_mailer.default_url_options = { :host => ‘你的herokuapp地址‘}
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
address: "smtpcloud.sohu.com",
port: 25,
domain: "heroku.com",
authentication: "login",
enable_starttls_auto: true,
user_name: ENV["SEND_CLOUD_USER_NAME"],
password: ENV["SEND_CLOUD_USER_KEY"]
}
end
https://airbrake.io 三十天免费
gem ‘airbrake‘, ‘~> 5.4‘
bundle install
rails g airbrake PROJECT_ID PROJECT_KEY
配置
config/initializers/airbrake.rb
c.project_id = ENV[‘PROJECT_ID‘]
c.project_key = ENV[‘PROJECT_KEY‘]
测试
rake airbrake:test
标签:基础 七牛云 自定义 initial provider val migrate 技术 内容
原文地址:http://www.cnblogs.com/Jogging/p/JDStore-gou-wu-wang-zhan-fu-pan20170312.html