More Related Content Similar to 20130929 tottoruby (20) 20130929 tottoruby2. 自己紹介
●
@hamajyotan – SAKAGUCHI Takashi
–
鳥取IT企業、オフィスウームの代表し
てます
–
http://www.ummm.info
–
う〜むとお困りの際にはご用命を
–
主にRuby on Railsに関しての技術的
な相談を請け負っています。
実装もお受けします。
4. 説明で使うアプリ作ります
$ rails new hoge && cd hoge/
$ git init && git add . && git commit -m “frst commit”
$ rails g controller welcome index && rm public/index.html
$ rails g scafold User name age:integer && rake db:migrate
$ echo "<%= link_to nil, users_path %>" >> ¥
> app/views/welcomde/index.html.erb
$ echo "body { width: 640px; margin: 0 auto; }" >> ¥
> app/assets/stylesheets/application.css
$ # confg/routes.rb の修正
Hoge::Application.routes.draw do
resources :users
root to: "welcome#index"
end
$ rails server # ⇒ access to http://127.0.0.1:3000
5. Gemfle(for debug)抜粋
group :development, :test do
gem 'pry-doc', require: false
gem 'pry-rails'
gem 'pry-debugger' # gem 'pry-byebug'
gem 'hirb'
gem 'hirb-unicode'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'rack-mini-profler'
gem 'quiet_assets'
end
10. .pryrcファイル例
if defned? Hirb
●
Hirb::View.instance_eval do
●
def enable_output_method
●
@output_method = true
●
@old_print = Pry.confg.print
●
Pry.confg.print = proc do |output, value|
●
Hirb::View.view_or_page_output(value) || @old_print.call(output, value)
●
end
●
end
●
●
def disable_output_method
●
Pry.confg.print = @old_print
●
@output_method = nil
●
end
●
end
●
●
Hirb.enable
●
end
14. おまけ - .bashrc
alias g="git"
function irb { if which pry >/dev/null 2>&1; then pry $*; else `which irb` $*; f; }
function be { if bundle check >/dev/null 2>&1; then bundle exec $*; else $*; f; }
for cmd in rails rake rspec guard cap; do
alias $cmd="be $cmd"
done
alias r="rails"
alias ra="rake"