`
netfork
  • 浏览: 487932 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

Override automatic updated_at in ActiveRecord/Rails

    博客分类:
  • Ruby
阅读更多
http://www.neeraj.name/blog/articles/800-override-automatic-updated_at-in-activerecord-rails

module ActiveRecord     
  class Base     
  
    def update_record_without_timestamping     
      class << self  
        alias_method :orig_record_timestamps, :record_timestamps  
        def record_timestamps; false; end     
      end     
  
      yield if block_given?   
  
      class << self     
        remove_method :record_timestamps  
        alias_method :record_timestamps, :orig_record_timestamps  
      end     
    end     
  
  end     
end  
分享到:
评论

相关推荐

    opreator-override.zip_override+c++_运算符重载

    "opreator-override.zip_override+c++_运算符重载"这个压缩包文件,显然包含了关于C++运算符重载的详细信息,特别是如何通过`override`关键字来更精确地控制重载。 首先,运算符重载并不是创建新的运算符,而是给已...

    Android 获取SENSORX Y Z各个方向的磁场分量.rar

      @Override   public void onAccuracyChanged(int sensor, int accuracy) {}//重写onAccuracyChanged方法   @Override   public void onSensorChanged(int sensor, float[] values) {//重写onSensorChanged方法...

    Android 加速度传感器的用法实例.rar

      @Override   public void onAccuracyChanged(int sensor, int accuracy) {} //重写onAccuracyChanged方法   @Override   public void onSensorChanged(int sensor, float[] values) { //重写onSensorChanged...

    initrd_table_override.rar_Table

    `initrd_table_override.rar_Table`这个标题可能指的是一个特定的配置或修改,涉及到initrd的加载和初始化过程中的表项覆盖。 描述中提到的“_PRT (PCI Routing Table) function”是指PCI(Peripheral Component ...

    Android DatePickerDialog、TimePickerDialog时间日期选择用法.rar

     @Override  public void onDateSet(DatePicker dp, int year, int month,int dayOfMonth) {   EditText et = (EditText)findViewById(R.id.et);   et.setText("您选择了:" year "年" month "月" dayOfMonth ...

    androidGPS经纬度速度方向

    @Override public void onGpsStatusChanged(int event) { // TODO Auto-generated method stub gpsStatus=lm.getGpsStatus(null); Iterator&lt;GpsSatellite&gt; Iteratorsate; ...

    android监控音量键并自定义动画

    @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) { // 处理音量键上抬或下按的逻辑 return true; ...

    Twitter分享android推特分享

    @Override public void onClick(View v) { Intent intent = new TweetComposer.Builder(context) .text("这是我要分享的内容") // 设置要分享的文字 .url(Uri.parse("http://example.com")) // 添加分享链接 ....

    android 笔记

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // 获取SensorManager实例 mSensorManager = ...

    Android 静音控制 音量控制 减小增大音量.rar

     @Override  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {//重写onCheckedChanged方法   am.setStreamMute(AudioManager.STREAM_MUSIC, !isChecked);//设置是否静音  }  });...

    android百度地图

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); SDKInitializer.initialize...

    Android有未接来电后处理(判断未接来电)

    @Override public void onCallStateChanged(int state, String incomingNumber) { super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_RINGING: // 电话...

    Android实时判断网络连接(wifi/2G/3G/4G)

    @Override public void onReceive(Context context, Intent intent) { ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); ...

    Android ontouch事件处理的三种方式

    @Override public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: // 用户触摸屏幕时的处理 break; case MotionEvent.ACTION_UP: // 用户释放...

    安卓Android源码——来电弹屏实例代码,带关闭按钮.zip

    @Override public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: // 来电时执行的操作 break; case TelephonyManager.CALL_...

    android 电话拦截 呼叫转移

    @Override public void onCallStateChanged(int state, String incomingNumber) { switch (state) { case TelephonyManager.CALL_STATE_RINGING: // 电话正在响铃 break; case TelephonyManager.CALL_STATE_...

    springbootwebsocket实例.zip

    @Override public void configureMessageBroker(MessageBrokerRegistry config) { config.enableSimpleBroker("/topic"); config.setApplicationDestinationPrefixes("/app"); } @Override public void ...

    Android-Android-RxLocationSettings用RxJava请求位置之前确认设置

    @Override public void onSubscribe(Disposable d) {} @Override public void onNext(LocationSettingsResult locationSettingsResult) { Status status = locationSettingsResult.getStatus(); if (status....

    快递和电话号码归属地查询(android)

    @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtMsg = (TextView) findViewById(R.id.txtMsg); txtExpressnum = ...

    Android GifView的入门级Demo

    @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); gifView = findViewById(R.id.gif_view); // 加载本地GIF...

Global site tag (gtag.js) - Google Analytics