Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use InstanceTag / TextArea based on Rails version, so that it works in Rails 4 #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/sir-trevor/helpers/form_helper.rb
Original file line number Diff line number Diff line change
@@ -14,16 +14,22 @@ def sir_trevor_text_area(object_name, method, options = {})
input_html['class'] = "sir-trevor-area visuallyhidden"
hash = input_html.stringify_keys

instance_tag = ActionView::Base::InstanceTag.new(object_name, method, self, options.delete(:object))
instance_tag.send(:add_default_name_and_id, hash)

output_buffer = ActiveSupport::SafeBuffer.new
output_buffer << instance_tag.to_text_area_tag(input_html)
# support both Rails 3 & 4
if defined? ActionView::Base::InstanceTag
instance_tag = ActionView::Base::InstanceTag.new(object_name, method, self, options.delete(:object))
instance_tag.send(:add_default_name_and_id, hash)
output_buffer << instance_tag.to_text_area_tag(input_html)
else
instance_tag = ActionView::Helpers::Tags::TextArea.new(object_name, method, self, input_html)
instance_tag.send(:add_default_name_and_id, hash)
output_buffer << instance_tag.render
end

output_buffer

end

end
end
end
end