Skip to content

Instantly share code, notes, and snippets.

# Copy database.yml
run 'cp config/database.yml config/database.yml.example'
# Delete unnecessary files
run 'rm README'
run 'rm public/index.html'
# Install plugins
plugin 'restful-authentication', :git => 'git://github.com/technoweenie/restful-authentication.git'
plugin 'will_paginate', :git => 'git://github.com/mislav/will_paginate.git'
# 勉強会メモ
n次元からn-1次元への展開
超立方体
微分の概念
瞬間の速度を求めたい
スピードガン
ドップラー効果
マイクロ波
rails my_app
cd my_app
ruby script/generate model user name:string email:string
ruby script/generate model entry title:string body:text user_id:integer
rake db:migrate
ruby script/generate i18n ja
class User < ActiveRecord::Base
has_many :entries
accepts_nested_attributes_for :entries
validates_presence_of :name, :email
end
class Entry < ActiveRecord::Base
belongs_to :user
validates_presence_of :title, :body
end
u = User.new
u.entries.build
u.valid?
u.errors.full_messages
#=> ["名前を入力してください。", "Entries bodyを入力してください。", "Entries titleを入力してください。", "Eメールを入力してください。"]
ja:
activerecord:
models:
entry: エントリ
user: ユーザ
attributes:
entry:
title: タイトル
body: 体
user:
u.errors.full_messages
#=> ["名前を入力してください。", "本文を入力してください。", "タイトルを入力してください。", "Eメールを入力してください。"]
# coding: utf-8
# 定数をモジュールにすることでグルーピングする試み
class Foo
module Statuses
INVALID = 0
VALID = 1
end
include Statuses
RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# testing
config.gem 'rspec', :lib => false
config.gem 'rr', :lib => false
config.gem 'rspec-rails', :lib => false
config.gem 'bmabey-email_spec', :lib => 'email_spec', :source => 'http://gems.github.com'