SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: overwrite save

  1. #1
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question overwrite save

    Hello Folks,
    I have a couple of models on my Rails app: order and element
    and in both of them I have a checksum that I calculate hashing all the other values. In which way can I overwrite the save function in order to save all the values and calculate the checksum ??? Or is it better calculate the checksum earlier and after save all the values(the checksum as well) using the "default" save function ????


    THANKS
    Alla prossima ...

  2. #2
    SitePoint Addict
    Join Date
    Jan 2006
    Posts
    268
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code ruby:
     #in your model
      before_save :build_check_sum
     
      def build_check_sum
        self.checksum = #w/e you wanna do for your checksum
      end
    If you give someone a program,
    you will frustrate them for a day;
    if you teach them how to program,
    you will frustrate them for a lifetime.

  3. #3
    SitePoint Zealot
    Join Date
    May 2007
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks pjleonhardt,
    I would like to build_check_sum for all the models in my application so it is enough moving your code in application.rb. isn't it ???

    THANK YOU ONCE AGAIN
    Alla prossima ...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •