ruby on rails - How to modify an attribute of a certain item in a model -


i have model called category contains categories used categorise products. 1 of categories called experiences. on specific query, i'd modify experiences experiences * display purposes.

i have tried via map, getting blank value experiences.

this code:

  def self.with_exp_star     category.all.map { |element|       if element.name == "experiences"         element.name = "experiences *"       else         element       end       }   end 

any ideas?

well, when element.name == "experiences" pushing element.name result array, element object otherwise, while should return element in both ways:

category.all.map { |element|   element.name += ' *' if element.name == 'experiences'   element } 

Comments