Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    5353      [ prefix, singular_class_name(record_or_class) ].compact * '_' 
    5454    end 
    5555 
    56     # The DOM class convention 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.  
    5757    # If no id is found, prefix with "new_" instead. Examples: 
    5858    # 
    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" 
    6161    # 
    6262    # If you need to address multiple instances of the same class in the same view, you can prefix the dom_id: 
    6363    # 
    64     #   dom_class(Post.new(:id => 45), :edit) # => "edit_post_45" 
     64    #   dom_id(Post.new(:id => 45), :edit) # => "edit_post_45" 
    6565    def dom_id(record, prefix = nil)  
    6666      prefix ||= 'new' unless record.id 
    6767      [ prefix, singular_class_name(record), record.id ].compact * '_'