サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
アメリカ大統領選
rubyquicktips.com
Ever wanted to try out any of Rails’ view helper methods in the console? Just include ActionView::Helpers after starting the Rails console: include ActionView::Helpers # => Object text_field(:post, :title) # => "<input id=\"post_title\" name=\"post[title]\" size=\"30\" type=\"text\" />"
Using “try” with a hash to check existence of a key The try method is awesome. Check the documentation. It is usually used to call a method on an object if it exists, or return nil if it doesn’t. But sometimes, it is not used with hashes, but this also works perfectly: params[:search] ? params[:search][:name] : nil # Can also be written as... params[:search].try(:[],:name)
Random Ruby and Rails tips. This blog is dedicated to deliver short, interesting and practical tidbits of the Ruby language and Ruby on Rails framework. Read more... Your submissions are more than welcome!
このページを最初にブックマークしてみませんか?
『Ruby Quicktips』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く