zoukankan      html  css  js  c++  java
  • tip

    Me No Blog Hella Ugly!

    April 10th, 2009

    Welcome to the 2000’s, self!

    I’m ever so excited to be blogging at a blog that not only understands code highlighting, but doesn’t look like it was crafted by a mad scientist with cataracts in 1992. Now it looks more like it was crafted by a mad scientist without cataracts circa 2008 — which is an entirely more accurate representation of the truth.

    That’s the good news.

    The bad news?  That I have don’t anything meaningful to report in this post.

    Maybe I’ll just write some highlighted code instead.

    # ---------------------------------------------------------------------------
    # options[:except_list]: list of symbols that we will exclude form this copy
    # options[:dont_overwrite]: if true, all attributes in from_model that aren't #blank? will be preserved
    def self.copy_attributes_between_models(from_model, to_model, options = {})
    	return unless from_model && to_model
    	except_list = options[:except_list] || []
    	except_list << :id
    	to_model.attributes.each do |attr, val|
    		to_model[attr] = from_model[attr] unless except_list.index(attr.to_sym) || (options[:dont_overwrite] &amp;&amp; !to_model[attr].blank?)
    	end
    	to_model.save if options[:save]
    	to_model
    end


      def created_date
        created_at.strftime("%Y.%m.%d")
      end
    
      def updated_date
        updated_at.strftime("%Y.%m.%d")
      end
    
  • 相关阅读:
    App调试的几个命令实践【转】
    解决sdk更新时候报错 http://dl-ssl.google.com/android上不去,链接拒绝
    fastjson序列化排序问题
    Java中的四种引用
    equal&==&hashcode
    ThreadPool线程池的关注点
    JVM的本地方法栈
    JVM的堆分配
    JVM的类装载子系统
    JVM的数据类型
  • 原文地址:https://www.cnblogs.com/lexus/p/1867117.html
Copyright © 2011-2022 走看看