2017-03-01から1ヶ月間の記事一覧

Railsでdevelopmentのエラー画面をproductionと同じにする

config/environments/development.rb ~~~ consider_all_requests_local = false ~~~ consider_all_requests_local を false にするだけ Configuring Rails Applications — Ruby on Rails Guides

Rubyの多重代入 ,(カンマ)で区切られた代入の挙動

こんなやつが出てきて挙動が分からず困っていたら多重代入というやつらしい。 a, b = Hoge.moge 多重代入についてまとめます。 左辺が1つで右辺が複数の場合 配列に変換される a = 1, 2 #=> [1, 2] a #=> [1, 2] 左辺、右辺ともに2つの場合 左辺の各変数に右…

herokuでworkerだけをrestartする方法

heroku ps -a myapp まずはプロセスを確認 $ heroku ps -a myapp === web (Standard-1X): bundle exec puma -C config/puma.rb (1) web.1: up 2017/03/06 00:00:00 +0900 (~ 10h ago) === worker (Standard-1X): bundle exec sidekiq -C config/sidekiq.yml …

constantizeした時にactive_support/inflector/methods.rb:268:in `const_get': uninitialized constant Hoge (NameError)と怒られる問題[Rails]

h = 'Hoge'.constantize h.create(fuga: 'fuga') した時に active_support/inflector/methods.rb:268:in `const_get': uninitialized constant Hoge (NameError) とHogeという定数、クラスがなかったため怒られてしまった。 safe_constantizeで回避 safe_con…

rake taskの中断はreturnではなくnextだった[Rails]

task :test do puts 'hoge' return puts 'moge' end 実行する rake aborted! LocalJumpError: unexpected return 怒られた… rake taskの中断はreturnじゃなくてnextとのこと task :test do puts 'hoge' next puts 'moge' end 以下の場合はreturnとのこと tas…

brew updateしたら/usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directoryと怒られる問題

brew update brew update したら $ brew update /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory /usr/local/Library/brew.sh: line 32: /usr/local/Library/ENV/scm/git: No such file or directory /usr…