#如何将 Rails 应用程序部署到 VPS 上
如果已经在 VPS 上假设好了 Rails 生产环境,接下来就可以将部署应用程序了。
###需要用到的工具
# regexps to check if a string is pure chinese | |
class String | |
# 20k chars | |
CHINESE_UCS2 = /^(?: | |
[\x4e-\x9e][\x00-\xff] | |
|\x9f[\x00-\xa5] | |
)+$/xn | |
# 20k chars | |
CHINESE_UTF8 = /^(?: |
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
#!/usr/bin/ruby1.9 | |
require 'fiber' | |
require 'benchmark' | |
class Ring | |
attr_reader :id | |
attr_accessor :attach | |
def initialize(id) |
class Avatar < ActiveRecord::Base | |
attr_accessor :content_type, :original_filename, :image_data | |
before_save :decode_base64_image | |
has_attached_file :image, | |
PAPERCLIP_CONFIG.merge( | |
:styles => { | |
:thumb => '32x32#', | |
:medium => '64x64#', |
#如何将 Rails 应用程序部署到 VPS 上
如果已经在 VPS 上假设好了 Rails 生产环境,接下来就可以将部署应用程序了。
###需要用到的工具
def try(title, options = { }, &p) | |
tried_times = 0 | |
max_times = options[:max_times] || 3 | |
exceptions = options[:on] || Exception | |
exceptions = [exceptions] if !exceptions.is_a?(Array) | |
rescue_text = <<-EOF | |
begin | |
# 不能用yield | |
p.call | |
rescue #{exceptions.join(',')} => e |
All code is available in example app - https://github.com/maxivak/webpacker-rails-example-app