Taps Server Error: PGError: ERROR: time zone displacement out of range: "2012-02-29 12:00:00.000000+5894368800"
こんなん出たんですが、
#93: Taps Server Error: PGError: ERROR: time zone displacement out of range: "2011-11-15 12:00:00.000000+5894114400" – Issues – ricardochimal/taps – GitHub
This is a problem due to remote ruby version mismatching. Just use 1.9.2 until heroku updates to 1.9.3.
これでした。ほおぉ。
DEPRECATION WARNING: read_csv_fixture_files is deprecated and will be removed from Rails 3.2.
なんてことを言われてるんですが、なんでcsv受け付けなくなっちゃうんでしょ?
activerecord-3.1.3/lib/active_record/fixtures.rb
684 def read_csv_fixture_files
685 reader = CSV.parse(erb_render(IO.read(csv_file_path)))
686 header = reader.shift
687 i = 0
688 reader.each do |row|
689 data = {}
690 row.each_with_index { |cell, j| data[header[j].to_s.strip] = cell.to_s.strip }
691 fixtures["#{@class_name.to_s.underscore}_#{i+=1}"] = ActiveRecord::Fixture.new(data, model_class)
692 end
693 end
694 deprecate :read_csv_fixture_files
csv便利なのになぁ。
Commit dc94d813e2d158c5a284212c5d8146c677dbb877 to rails/rails – GitHub
fixing invalid yaml [#4418 state:resolved]
ここ、あなたのconfig/locales/active_support_ja.ymlではどうなってますか?
Rails 3 Cheat Sheets « Envy Labs
Today I’m happy to finally release the Envy Labs Rails 3 Cheat Sheets.
ルーティングだとかbundleだとか、書いてて「えーと、なんだっけ?」になるところがまとまってます。いいね!
default_scopeを全部外すにはunscopedだったのですが、特定の条件だけ外すにはどうしたらよいのか調べていたら、こちらにたどり着きました。
default_scopeのorderをキャンセルする – とある技術屋の戯言
Model.reorder(‘id DESC’)
おーなるほどと思いつつ、他にもあるのかとドキュメントを見に行ったら・・・([ show source ]をクリック)
Module: ActiveRecord::QueryMethods
# File activerecord/lib/active_record/relation/query_methods.rb, line 56
56: def reorder(*args)
57: ActiveSupport::Deprecation.warn "reorder is deprecated. Please use except(:order).order(…) instead", caller
58: relation = clone
ん?
class Article < ActiveRecord::Base
default_scope where(:disclosed => true).order('disclosed_at DESC')
end
Article.all #=> SELECT "articles".* FROM "articles" WHERE ("articles"."disclosed" = 't') ORDER BY disclosed_at DESC
Article.except(:where).all #=> SELECT "articles".* FROM "articles" ORDER BY disclosed_at DESC
Article.except(:order).all #=> SELECT "articles".* FROM "articles" WHERE ("articles"."disclosed" = 't')
ほほー。
with_exclusive_scope (ActiveRecord::Base) – APIdock
In Rails3 use "unscoped" instead
The with_exclusive_scope examples no longer work in Rails3 because with_exclusive_scope is now a protected method which can and should not be used in a controller. Use the new unscoped method instead:
ほー。
class Post < ActiveRecord::Base
default_scope :published => true
end
Post.all #=> SELECT * FROM posts WHERE published = true
Post.unscoped.all #=> SELECT * FROM posts
ほほー。
「Rails3でO/RマッパをDataMapperにしてsqliteを選択したときにdbファイルが作られない。」という舌をかみそうな現象に遭遇したのでご紹介。
結論から言うと、こちらのようにdatabaseではなくpathで書いてあげれば解決します。
Rails 3 DataMapper dm-rails sqlite3 issue – Ruby Forum
change "database" to "path"
database: testing_dm3_development.db
to
path: ./db/testing_dm3_development.db
databaseのままだとファイルではなくメモリにデータが作られてしまうために、セッションが切れると飛んでしまうのが原因のようです。
・・・で、このままでは気持ち悪いのでどうしてこうなるかを追ってみました。
続きを読む…
RVM: Ruby Version Manager – rvmrc
The project rvmrc files are intended to be used to setup your project’s ruby environment when you switch to the project root directory.
以下のようにしておくと、それ以下のディレクトリに降りた時に自動で環境が切り替わるようになります。これは便利だなー。
echo "rvm foo@bar" > ~/projects/baz/.rvmrc
Bundler: The best way to manage Ruby applications
Install all gems into vendor/bundle, even gems that are already installed to your system and would normally be used from there instead of installed.
インストール時にnative extensionが作られるgem(たとえばsqlite3-ruby)をBundlerで入れるときに、おすすめされているディレクトリ(vendor/bundle)にインストールするとnativeなものがリポジトリに含まれちゃってわりと残念な感じになるんですが、みなさんどうしてるんでしょうか。
いくつかのディレクトリ(cache,gems,specifications)に撒かれているのをそれぞれ.gitignoreに書くのもそれはそれで気持ち悪いのでなにかうまい方法を考えていたら日が暮れてしまうという始末。あーなんてこと!
改行とるのをベタ実装してたらメソッドあったという話。
activesupport-2.3.8/lib/active_support/core_ext/base64/encoding.rb
10 def encode64s(value)
11 encode64(value).gsub(/\n/, '')
12 end
ほっほー。