Skip to content

Instantly share code, notes, and snippets.

@ni-ka
Created March 21, 2012 12:55
Show Gist options
  • Save ni-ka/2146703 to your computer and use it in GitHub Desktop.
Save ni-ka/2146703 to your computer and use it in GitHub Desktop.
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 || {}).merge(as: longtext_field_name), &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