Ticket #10775: dom-id-docfix.diff
| File dom-id-docfix.diff, 1.3 kB (added by jbarnette, 8 months ago) |
|---|
-
actionpack/lib/action_controller/record_identifier.rb
old new 53 53 [ prefix, singular_class_name(record_or_class) ].compact * '_' 54 54 end 55 55 56 # The DOM classconvention is to use the singular form of an object or class with the id following an underscore.56 # The DOM id convention is to use the singular form of an object or class with the id following an underscore. 57 57 # If no id is found, prefix with "new_" instead. Examples: 58 58 # 59 # dom_ class(Post.new(:id => 45)) # => "post_45"60 # dom_ class(Post.new) # => "new_post"59 # dom_id(Post.new(:id => 45)) # => "post_45" 60 # dom_id(Post.new) # => "new_post" 61 61 # 62 62 # If you need to address multiple instances of the same class in the same view, you can prefix the dom_id: 63 63 # 64 # dom_ class(Post.new(:id => 45), :edit) # => "edit_post_45"64 # dom_id(Post.new(:id => 45), :edit) # => "edit_post_45" 65 65 def dom_id(record, prefix = nil) 66 66 prefix ||= 'new' unless record.id 67 67 [ prefix, singular_class_name(record), record.id ].compact * '_'