Skip to content

Instantly share code, notes, and snippets.

View YumaInaura's full-sized avatar

いなうらゆうま ( 稲浦悠馬 ) YumaInaura

View GitHub Profile
@YumaInaura
YumaInaura / file0.txt
Last active August 31, 2015 14:23
Hamlでidを正しく出力する方法( {id: "my-id"} のようにベタ書きで出力されてしまう原因) ref: http://qiita.com/Yinaura/items/9e3afdfe2204e7c12b53
%div{id: "my-id"}
@YumaInaura
YumaInaura / file0.txt
Last active September 3, 2015 10:46
Rails: ActiveAdmin.register_page でのアクションの作り方とはまりどころ。 ref: http://qiita.com/Yinaura/items/3572d34e1c00f9f5533e
ActiveAdmin.register_page "AuthorPage" do
content do
panel 'メニュー' do
link_to '新規作成', admin_authorpage_new_path
end
table_for authors do
column "名前", :name
column "性別", :gender
column ("name_changed"){ |author| author.name_changed }
column ("編集"){ |author| link_to('編集する', admin_authorpage_edit_path(id: author.id)) }
@YumaInaura
YumaInaura / file0.txt
Last active September 7, 2015 00:49
Rails & Haml の form で 閉じタグが出力されなかったりエラーが起きたりするときの対処。 ref: http://qiita.com/Yinaura/items/2b6a0a2a8061027e961d
= form_tag do
= text_field_tag :text
@YumaInaura
YumaInaura / human.rb
Created September 10, 2015 02:12
Rails: ActiveModel の table_for を i18nに対応させる ref: http://qiita.com/Yinaura/items/403300f663750df81c5e
class Human
include ActiveModel::Model
end
@YumaInaura
YumaInaura / file0.txt
Created September 14, 2015 01:40
Rails : VCRでリクエスト内容が足りないと言われる時の対策 ref: http://qiita.com/Yinaura/items/22908c8f5c866120fc5f
An HTTP request has been made that VCR does not know how to handle:
GET http://example.com
@YumaInaura
YumaInaura / file0.txt
Last active September 14, 2015 09:19
Capybara + rspec で selected の状態を判定する : Rails ref: http://qiita.com/Yinaura/items/b9fb268142f4d75f84c8
expect(page).to have_select('book[id]', selected: 'ソフィーの世界')
@YumaInaura
YumaInaura / book.rb
Last active September 15, 2015 09:14
Rails: ActiveModel でバリデーションエラーを自分で起こす ( raise ActiveRecord::RecordInvalid ) ref: http://qiita.com/Yinaura/items/24997f0005e187f54210
class Book
include ActiveModel::Model
attr_accessor :title
validates :title, presence: true
def self.new! (params = [])
model = self.new(params)
@YumaInaura
YumaInaura / book.rb
Last active September 16, 2015 01:05
Ruby: 絶対パスでメソッドを呼び出す。 ref: http://qiita.com/Yinaura/items/bbad6d788f2a0d5463f0
class Book
def self.example
p 'Class'
end
end
module Example
class Book
#このモジュールの example を呼ぶ
def self.call_module_method
@YumaInaura
YumaInaura / user.rb
Created September 17, 2015 09:12
Rails: アクションによってバリデーションを切り替えた時の、モデルのテスト方法 ref: http://qiita.com/Yinaura/items/7cd94e338ae031c04820
class User
validates :name, presence: true, on: :index
validates_length_of :introduction, maximum: 10000. on: :create
end
@YumaInaura
YumaInaura / example
Last active September 18, 2015 01:20
ActiveAdmin にカスタムアクションを追加する。(idが必要な場合、必要ない場合) ref: http://qiita.com/Yinaura/items/3a16fc5f7eb7785b3cdf
ActiveAdmin.register Example do
collection_action :action_name, method: :get do
end