More than 5 years have passed since last update.
railsで、コントローラに渡されたパラメータを、キーワード引数としてメソッドにそのまま渡そうとするとエラーになる。
ハッシュがのキーシンボルであるため、これらのキーを文字列に変換してやる必要がある。
hash_change
my_hash = my_hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
参考
http://stackoverflow.com/questions/800122/best-way-to-convert-strings-to-symbols-in-hash
追記
railsであればハッシュに対してstringify_keys メソッドを使用するほうが簡単である。
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
