-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove email, provider, uid fields, and replace with link to a user. Keep the user account, so the same user can't try to make a new account.
- Loading branch information
Showing
11 changed files
with
118 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
class DishonorableDischarge < ActiveRecord::Base | ||
attr_accessible :email, :provider, :uid, :officer, :reason | ||
attr_accessible :user_id, :reason | ||
|
||
email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i | ||
validates :reason, presence: true | ||
validates :email, format: {with: email_regex} | ||
validates :provider, presence: true | ||
validates :uid, presence: true | ||
validates :officer, presence: true | ||
validates_each :officer do |m, attr, val| | ||
if( !val || !User.exists?(val) || User.find(val).rank < 3 ) | ||
validates :reason, presence: true | ||
validates :user_id, presence: true | ||
validates :officer_id, presence: true | ||
validates_each :officer_id do |m, attr, val| | ||
officer = val && User.find(val); | ||
if( !officer || officer.rank < 3 ) | ||
m.errors.add(attr, "must have officer rank") | ||
end | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
db/migrate/20111209085641_create_dishonorable_discharges.rb
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
db/migrate/20120212230339_create_dishonorable_discharges.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class CreateDishonorableDischarges < ActiveRecord::Migration | ||
def self.up | ||
create_table :dishonorable_discharges do |t| | ||
t.integer :user_id | ||
t.integer :officer_id | ||
t.text :reason | ||
|
||
t.timestamps | ||
end | ||
|
||
add_index :dishonorable_discharges, :user_id | ||
add_index :dishonorable_discharges, :officer_id | ||
end | ||
def self.down | ||
remove_index :dishonorable_discharges, :user_id | ||
remove_index :dishonorable_discharges, :officer_id | ||
|
||
drop_table :dishonorable_discharges | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.