# -*- coding: utf-8 -*- class User ActiveRecord::Base ----------------------------- include Activity::UserMethods end --------------------------------------------------------------------------------------------------------- class Activity
# -*- coding: utf-8 -*-
class User
-----------------------------
include Activity::UserMethods
end
---------------------------------------------------------------------------------------------------------
class activity
attr_accessible :title, :content, :start_time, :end_time
belongs_to :creator, :class_name => 'User', :foreign_key => :creator_id
validates :creator, :presence => true
validates :title, :presence => true
validates :content, :presence => true
validates :start_time, :end_time, :presence => true
validate :validate_start_and_end_time
def validate_start_and_end_time
errors.add(:base,'开始时间必须早于结束时间') if self.start_time > self.end_time
end
module UserMethods
def self.included(base)
base.has_many :activities, :foreign_key => :creator_id
end
end
include ActivityMembership::ActivityMethods
end
ZYCH自由策划企业网站管理系统是一个智能ASP网站管理程序,是基于自由策划企业网站系列的升级版,结合以往版本的功能优势,解决了频道模板不能自由添加删减的问题,系统开发代码编写工整,方便读懂,系统采用程序模板分离式开发。方便制作模板后台模板切换,模板采用动态编写,此模板方式写入快,代码编写自由,即能满足直接使用也能满足二次开发。全新的后台界面,不管是在程序的内部结构还是界面风格及CSS上都做了大量
1
---------------------------------------------------------------------------------------------------------
class ActivityMembership
attr_accessible :activity, :user
belongs_to :user
belongs_to :activity, :foreign_key => :activity_id
validates :user, :presence => true
validates :activity, :presence => true
module ActivityMethods
def self.included(base)
base.send :include, InstanceMethods
base.has_many :activity_memberships
base.has_many :members, :through => :activity_memberships, :source => :user
end
module InstanceMethods
def add_member(user)
self.activity_memberships.create :user => user
end
def remove_member(user)
self.activity_memberships.where(:user_id=>user.id).destroy_all
end
end
end
end
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号