avallabh/guess_who — pull request #1 by Icelle (2014-01-11 07:02:26+00:00)
Title: member and member_information models and tests

I added the following:
gitignore file

GEMS
- shoulda, factorygirl, simple form, guard and spork gems. I use guard and spork for testing. You can ignore/delete them. Guard generated a guardfile. Simple form generated some files as well.

MEMBER
first_name (required)
last_name (required)
role (required, dropdown button) - created traits student and staff
email (required)- created an email validator on initializer
gender(required, dropdown button) - created traits male and female

MEMBER_INFORMATION
- Had to change the name type to key because type is a special word.

key(required, dropdown button)-
- created traits github, linkedin, twitter, hometown, interests.
- I made a constant called KEYS. KEYS is a hash containing all valid keys for the member info keys.

KEYS = {
"github" => {url: 'http://gihtub.com/'},
"twitter" => {url: 'http://twitter.com'},
"linkedin" => {url: 'http://www.linkedin.com/in/'},
"hometown" => nil,
"interests" => nil
}
validates :key, inclusion: {in:KEYS.keys}

- We want to click on member's username (github: username) and link to member's account: 'http://gihtub.com/username' so in the model, I added a function called get_url for the keys that need urls.

def get_url
if KEYS[self.key][:url].nil?
return nil
else
return KEYS[self.key][:url]+self.value
end
end

value(required)
member_id (automatically generated using references:member when model was created)