Railsが次のようなハッシュを変換する方法を見つけようとしています(これは例です。これを文字通りに解釈しないでください。このクエリがUser.find(1)と同じであることを知っているため、概念を理解するために何かを組み合わせました):
{
:select => "users.*",
:conditions => "users.id = 1",
:order => "username"
}
Into: SELECT users.* FROM users where users.id = 1 ORDER BY username
私が見つけることができる最も近いものは ActiveRecord::Base#find_every です
def find_every(options)
begin
case from = options[:from]
when Symbol
instantiate_collection(get(from, options[:params]))
when String
path = "#{from}#{query_string(options[:params])}"
instantiate_collection(format.decode(connection.get(path, headers).body) || [])
else
prefix_options, query_options = split_options(options[:params])
path = collection_path(prefix_options, query_options)
instantiate_collection( (format.decode(connection.get(path, headers).body) || []), prefix_options )
end
rescue ActiveResource::ResourceNotFound
# Swallowing ResourceNotFound exceptions and return nil - as per
# ActiveRecord.
nil
end
end
生のmysqlステートメントが何であるかを返すようにこれを変更する方法がわかりません。