2011-07-11から1日間の記事一覧

Classクラスに関する仮説

Object.class #=> Class Module.class #=> Class Class.class #=> Class Class.superclass #=> Module irbで上記のような結果を得たので、これよりClassクラスってこんな感じじゃないかと思った。あくまで仮説だけどねー。 class Class < Module Object = se…

ある条件であるクラスを追加するヘルパーメソッドつくりました

# application_helper.rb def tag_add_class_if(tag, conditions, cl, attributes = {}, &block) if conditions if attributes.keys.include?(:class) attributes[:class] += " #{cl}" else attributes.merge(:class => cl) end end content_tag tag, attrib…

ある条件でhiddenなHTMLタグを出力するヘルパーメソッドつくりました

# application_helper.rb def tag_hidden_if(tag, conditions, attributes = {}, &block) attributes = attributes.merge({'style' => 'display:none;'}) if conditions content_tag tag, attributes, &block end # index.html.erb <% @articles.each_with_i…