Skip to content

Instantly share code, notes, and snippets.

Avatar

Takehiro Adachi take

View GitHub Profile
View tanshiba.coffee
# Description:
# tanshiba
#
# Dependencies:
# None
#
# Configuration:
# None
#
# Commands:
@take
take / gist:3849060
Created Oct 7, 2012
rails, about master data
View gist:3849060
Takehiro: like theres a table which contains all the state ( = states table )
Takehiro: and theres User table
Takehiro: which contains state_id
Takehiro: when u create a new user, u need to get all the state data to show a select box or something right
pduersteler: Takehire yes. for that you can provide a :collection to your select
Takehiro: oh
Takehiro: kk thx :P
pduersteler: :)
Takehiro: so if i provide :collection to my select, when i do @user = User.new
Takehiro: i get all the data from states aswell?
@take
take / spec_helper.rb
Created Oct 9, 2012 — forked from pauljamesrussell/spec_helper.rb
RSpec matcher for ensuring a model is accepting nested attributes for an association, and accepting/rejecting the right values.
View spec_helper.rb
# Use: it { should accept_nested_attributes_for(:association_name).and_accept({valid_values => true}).but_reject({ :reject_if_nil => nil })}
RSpec::Matchers.define :accept_nested_attributes_for do |association|
match do |model|
@model = model
@nested_att_present = model.respond_to?("#{association}_attributes=".to_sym)
if @nested_att_present && @reject
model.send("#{association}_attributes=".to_sym,[@reject])
@reject_success = model.send("#{association}").empty?
end
model.send("#{association}").clear
@take
take / gist:4078932
Created Nov 15, 2012
ruby-lang.org
View gist:4078932
# Ruby knows what you
# mean, even if you
# want to do math on
# an entire Array
cities = %w[ London
Oslo
Paris
Amsterdam
Berlin ]
visited = %w[Berlin Oslo]
@take
take / database.yml
Created Jan 3, 2013
database.yml mysql adapter
View database.yml
<%
socket = ["/tmp/mysqld.sock",
"/tmp/mysql.sock",
"/var/run/mysqld/mysqld.sock",
"/var/lib/mysql/mysql.sock",
"/opt/local/var/run/mysql5/mysqld.sock"
].detect{|socket| File.exist?(socket)}
%>
development:
View InfoPlist.strings
/* Localized versions of Info.plist keys */
"Credits" = "クレジット";
"Here are some great libraries I used to create this application:" = "これらの素晴らしいライブラリを使ってこのアプリを開発しました:";
"About" = "このアプリについて";
"Thank You" = "ありがとう";
"Thank you to the amazing team at GitHub for creating a great product, without their hard work, none of this would have been possible." = "GitHub社の皆さんにお礼を言いたいと思います。GitHubのスタッフの大変な苦労が無ければ、このようなアプリは作れませんでした。";
"About the Developer" = "このアプリのデベロッパーについて";
"Icon Design" = "アイコンのデザイン";
You can’t perform that action at this time.