diff --git a/lib/show_for/content.rb b/lib/show_for/content.rb index 2668c3f..1c5e28a 100644 --- a/lib/show_for/content.rb +++ b/lib/show_for/content.rb @@ -27,7 +27,11 @@ def content(value, options={}, apply_options=true, &block) when NilClass, Numeric value.to_s else - value + if block + template.capture(value, &block) + else + value + end end options[:content_html] = options.except(:content_tag) if apply_options diff --git a/test/association_test.rb b/test/association_test.rb index ed0ce69..6269861 100644 --- a/test/association_test.rb +++ b/test/association_test.rb @@ -42,6 +42,14 @@ def @user.tags end end + test "show_for accepts a block with an argument in belongs_to associations" do + with_association_for @user, :company do |company| + company.name.upcase + end + + assert_select "div.show_for p.wrapper", /PLATAFORMATEC/ + end + test "show_for accepts :using as option to tell how to retrieve association values" do with_association_for @user, :tags, :using => :alternate_name assert_select "div.show_for p.wrapper ul.collection"