🏃♀️
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
require 'zeus/rails' | |
class CustomPlan < Zeus::Rails | |
def server Dir.chdir(::Rails.application.root) | |
`unicorn_rails` | |
end | |
end | |
Zeus.plan = CustomPlan.new |
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
str = '' | |
yaml_test = str.to_yaml | |
=>"--- \"\"\n" | |
YAML.load(yaml_test) | |
=> "" |
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 Facebook::Notification | |
attr_accessor :canvas_auth, :graph | |
def initialize | |
conf = Rails.configuration.facebook_canvas | |
@canvas_auth = Koala::Facebook::OAuth.new(conf[:app_id], conf[:app_secret]) | |
@graph = Koala::Facebook::API::new(canvas_auth.get_app_access_token, conf[:app_secret]) | |
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
require 'spec_helper' | |
describe MyModel do | |
it "should create a new instance given valid attributes" do | |
Factory(:my_model) | |
end | |
describe "name" do | |
it "should be required" do | |
blank = Factory.build(:my_model, :name => "") |
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
# model | |
serialize :body | |
# controller | |
def inquiry_params | |
params.require(:inquiry).permit(:read_at, :inquiry_form_id, inquiry_contents_attributes: [{body: []}, :part_id]) | |
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
# spec/support/site_prism/user_page.rb | |
class UserPage | |
class FormBase < SitePrism::Section | |
element :first_name, "input[name='user[first_name]']" | |
element :last_name, "input[name='user[last_name]']" | |
element :button, "input[name='commit']" | |
def input(args) | |
first_name.set args[:first_name] | |
last_name.set args[:last_name] | |
button.click |
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
# app/models/account.rb | |
class Account | |
include ActiveModel::Model | |
validates :name, presence: true | |
def initialize | |
# ~ | |
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
# app/models/syllabus.rb | |
class Syllabus | |
include ActiveModel::Model | |
attr_accessor :records, :academic_year, :course | |
validates :academic_year, presence: true | |
def initialize(academic_year, course = nil) | |
@academic_year = academic_year | |
@course = course |
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
# Gem | |
gem 'composite_primary_keys' | |
# 複合keyの設定の為、idのprimary_keyを解除して、複合keyでindex追加 | |
class CreatePageviews < ActiveRecord::Migration | |
def change | |
create_table :pageviews, id: false do |t| | |
t.integer :id, null: false | |
t.integer :article_id, null: false | |
t.integer :category_id, null: false |
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 Hook | |
def increment | |
super | |
expire | |
end | |
end | |
class Ranking | |
prepend Hook |
OlderNewer