Created
March 21, 2012 12:26
-
-
Save ni-ka/2146597 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def longtext_and_parts(*names, &block) | |
options = names.pop if names.last.is_a?(Hash) | |
names.each do |name| | |
longtext_field_name = (name.to_s + '_longtext').to_sym | |
@setup.add_text_field_factory(longtext_field_name, options || {}, &block) | |
new_name = (name.to_s + '_longtext_parts').to_sym | |
block ||= Proc.new { self.send name } # for regular attributes | |
@setup.add_text_field_factory(new_name, (options || {}).merge(as: new_name), &block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment