> loginctl enable-linger [username]
> sudo loginctl enable-linger [username]
> vi .config/systemd/user/xxx_puma_production.service
> systemctl --user enable xxx_puma_production.service
> systemctl --user daemon-reload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p = Refinery::Page.create( | |
title: '北海道', | |
custom_slug: 'hokkaido', | |
parent_id: 40, | |
layout_template: 'application', | |
view_template: 'show' | |
) | |
Refinery::PagePart.create!([ | |
{refinery_page_id: p.id, title: 'Body', body: "<p>北海道のページ</p>"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
before_save :encrypt_password | |
after_save :clear_password | |
def encrypt_password | |
if password.present? | |
salt = BCrypt::Engine.generate_salt | |
self.encrypted_password= BCrypt::Engine.hash_secret(password, salt) | |
end | |
end | |
def clear_password | |
self.password = nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s3 = AWS::S3.new(access_key_id: 'YOUR_ACCESS_KEY_ID', secret_access_key: 'YOUR_SECRET_ACCESS_KEY') | |
bucket = s3.buckets['bucket_name'] | |
bucket.objects.each{|obj| obj.acl = :public_read } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def lazy_image_tag source, options = {} | |
options['data-original'] = source | |
if options[:class].blank? | |
options[:class] = "lazy" | |
else | |
options[:class] = options[:class].to_s + " lazy" | |
end | |
image_tag 'image_grey.jpg', options | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
content_tag :ul do | |
items.each do |item| | |
concat content_tag(:li, item.name) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActionView | |
module Helpers | |
module UrlHelper | |
alias original_link_to link_to | |
def link_to(*args, &block) | |
if block_given? | |
options = args.first || {} | |
html_options = args.second | |
link_to(capture(&block), options, html_options) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(window, $) { | |
var document = window.document; | |
$(document).ready(function() { | |
// ...write some code... | |
}); | |
}(this, jQuery)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :set_locale_from_remote_addr | |
private | |
def set_locale_from_remote_addr | |
return do_something(session[:locale] if session[:locale] | |
raise UnknownIPAddessError unless request.remote_addr | |
geoip = GeoIP.new(Rails.root + "db/GeoLiteCountry.dat").country(request.remote_addr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ApplicationController < ActionController::Base | |
before_filter :set_locale_from_remote_addr | |
private | |
def set_locale_from_remote_addr | |
return do_something(session[:locale] if session[:locale] | |
raise UnknownIPAddessError unless request.remote_addr | |
geoip = GeoIP.new(Rails.root + "db/GeoLiteCountry.dat").country(request.remote_addr) |
NewerOlder