Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

handle belongs_to association with a block

closes #50 #51
  • Loading branch information...
commit 2bca8c90ae2672e39d1dac6a9920d82bedd3fd4b 1 parent 4b124fe
@nashby nashby authored
Showing with 13 additions and 1 deletion.
  1. +5 −1 lib/show_for/content.rb
  2. +8 −0 test/association_test.rb
View
6 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
View
8 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"
Please sign in to comment.
Something went wrong with that request. Please try again.