Module: Cable::ActsAsCable::InstanceMethods
- Defined in:
- lib/cable/acts_as_cable.rb
Instance Method Summary collapse
Instance Method Details
#first_displayable_attribute ⇒ Object
45 46 47 48 |
# File 'lib/cable/acts_as_cable.rb', line 45 def first_displayable_attribute displayable_attr = [ :title, :name, :first_name, :email, :email_address ].select{|attr| self.respond_to? attr }.first displayable_string = (displayable_attr.nil?) ? "Title not available" : self[displayable_attr] end |
#to_json_for_autocomplete ⇒ Object
39 40 41 42 43 |
# File 'lib/cable/acts_as_cable.rb', line 39 def to_json_for_autocomplete displayable_string = first_displayable_attribute #TODO: find first string attr or look at sphinx index# if displayable_string.nil? { :label => "#{truncate(displayable_string, :length => 34)}" , :value => "#{(displayable_string)}", :type => self.class.name } end |