w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Changing a proprety inside a rails model just for the views

Try using read_attribute to avoid the recursion:

class Product < ActiveRecord::Base
  ...
  def item_number
    read_attribute(:item_number).to_s.rjust(5, '0')
  end
  ...
end




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.