From a614b285589d14457a2e75567900adcffbb0d193 Mon Sep 17 00:00:00 2001 From: Jason Denney Date: Thu, 25 Apr 2013 21:38:55 -0400 Subject: [PATCH] Make it possible to limit roles by date --- app/models/user.rb | 2 +- app/models/user_role_join.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 9de57d2..17be074 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,7 +14,7 @@ class User < ActiveRecord::Base has_many :user_profiles accepts_nested_attributes_for :user_profiles, allow_destroy: false - has_many :user_role_joins + has_many :user_role_joins, :conditions => ["ends IS NULL OR ends > ?", Time.now] has_many :roles, through: :user_role_joins belongs_to :bike diff --git a/app/models/user_role_join.rb b/app/models/user_role_join.rb index 64b961a..f55b93c 100644 --- a/app/models/user_role_join.rb +++ b/app/models/user_role_join.rb @@ -1,6 +1,6 @@ class UserRoleJoin < ActiveRecord::Base set_table_name :user_role_joins - attr_accessible :role_id, :user_id + attr_accessible :role_id, :user_id, :ends belongs_to :user belongs_to :role