Skip to content

Instantly share code, notes, and snippets.

@raarellano
Created May 12, 2015 15:21
Show Gist options
  • Save raarellano/e30378ad38b5668475e0 to your computer and use it in GitHub Desktop.
Save raarellano/e30378ad38b5668475e0 to your computer and use it in GitHub Desktop.
Fields inside a fields_for block
def sanitized_object_name(object_name)
object_name.gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
end
def sanitized_method_name(method_name)
method_name ||= @method_name.sub(/\?$/,"")
end
def form_tag_id(object_name, method_name)
"#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment