diff options
author | Robin Houston <robin@lenny.robin> | 2011-09-08 00:56:59 +0100 |
---|---|---|
committer | Robin Houston <robin@lenny.robin> | 2011-09-08 00:56:59 +0100 |
commit | 6e0e5e5bed89ff2093e1cca3fa50310f678565fd (patch) | |
tree | ae9a198a8134e90ab2a140d699ed6f3248f467cc /app/helpers/application_helper.rb | |
parent | e286a5a91e449ef01b5ce5f23654d1316bffaf53 (diff) | |
parent | a9002cc8e749df6f5961acab8e3e61fd21987fc1 (diff) |
Merge branch 'develop' of git@github.com:sebbacon/alaveteli into develop
Conflicts:
app/models/request_mailer.rb
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ec56566a9..d12238582 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -94,5 +94,20 @@ module ApplicationHelper block.call end end + # (unfortunately) ugly way of getting id of generated form element + # ids + # see http://chrisblunt.com/2009/10/12/rails-getting-the-id-of-form-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.sub(/\?$/, "") + end + + def form_tag_id(object_name, method_name) + return "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}" + end + end |