修改属性值,控制时间,联合主键

修改属性:update_attributes

private

    def _update_status(status)
      self.update_attributes :status => status
      self.save

    end


控制时间:Timecop.travel(Time.now - 3.day) do  end

before do
        Timecop.travel(Time.now - 3.day) do
          @hash = {
                    :title      => 'title1',
                    :content    => 'content1',
                    :start_time => Time.now + 2.day,
                    :end_time   => Time.now + 5.day
                  }
          @activity = creator.activities.create(@hash)
        end
      end

联合主键:uniqueness

validates  :user_id,  :uniqueness => {:scope => :activity_id}

你可能感兴趣的:(联合主键,Timecop)