ruby on rails - How to create method that converts attribute's value to new value -


i have form in users input number attribute :bytesize, has integer datatype. number represents amount of bytes object @catcher.

i'd have method convert value of :bytesize megabytes. is, i'd able run @catcher.mbsize, , display number of megabytes object.

i'm pretty new rails, apologies if seems obvious.

conversion methods pretty straight-forward:

class catcher   def mbsize     self.bytesize / (1 << 20)   end end 

remember attributes internally stored instance variables, attr_accessor :bytesize stored in @bytesize.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -