This file contains hidden or 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
class Diagnosis < ActiveRecord::Base | |
has_and_belongs_to_many :prescriptions | |
has_many :patients, :through=>:prescriptions | |
end |
This file contains hidden or 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
class Message < ActiveRecord::Base | |
belongs_to :user | |
# accepts_nested_attributes_for :user | |
end |
This file contains hidden or 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
SyncIn::Application.routes.draw do | |
#devise_for :admins, :controllers => { :sessions => "admins/sessions" } | |
devise_for :users, :controllers => { :sessions => "sessions", :registrations => "registrations" }, :skip => [ :sessions, :registations ] | |
as :user do | |
get '/signin' => 'sessions#new', :as => :new_user_session | |
post '/signin' => 'sessions#create', :as => :user_session | |
delete '/signout' => 'sessions#destroy', :as => :destroy_user_session |
This file contains hidden or 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
validates :password, format: { with: /\d/, message: "must contain at least one number" }, | |
allow_blank: true | |
validates :password, format: { with: /[a-zA-Z]/, message: "must contain at least one letter" }, | |
allow_blank: true | |
it "should require a letter" do | |
numbers = "12345678" | |
user = User.new(@attr.merge(:password => numbers, :password_confirmation => numbers)) | |
user.should have(1).error_on(:password) | |
user.errors_on(:password).should include("must contain at least one letter") |
This file contains hidden or 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
Method A: Carrier - Poor Location Precision, Secure | |
Method B: Client(phone) - High Location Precision, Insecure (Can be spoofed) | |
Option 1: Improve precision of Method A (Carrier Location) | |
* Supports all phones on Tier 1 carriers | |
* Find and correct for inaccuracy patterns | |
Option 2: Prevent spoofing of Method B (Client Location) | |
* Supports smart phones on all carriers | |
* Possible spoof prevention: http://stackoverflow.com/questions/6623945/check-if-geo-location-has-been-spoofed |
This file contains hidden or 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
def location | |
# return nil if !subscribed? | |
if last_location && (Time.now - last_location.created_at) < 5.minutes | |
return locations.create!( latitude: last_location.latitude, longitude: last_location.longitude, radius: last_location.radius ) | |
end | |
locate | |
end |
This file contains hidden or 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
def self.active | |
s = arel_table where( | |
s[:begins_at].lteq(Time.now.utc).or(s[:begins_at].eq(nil)), | |
s[:ends_at].gt(Time.now.utc).or(s[:ends_at]).eq(nil)) | |
) | |
end | |
def self.active | |
s = arel_table.where( | |
s[:begins_at].lteq(Time.now.utc).or(s[:begins_at].eq(nil)), |
This file contains hidden or 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
# Permissions | |
permission = [] | |
[ | |
{ action: "create", resource: "User", access: "none" }, | |
{ action: "read", resource: "User", access: "individual" }, | |
{ action: "update", resource: "User", access: "individual" }, | |
{ action: "destroy", resource: "User", access: "individual" }, | |
{ action: "create", resource: "Shift", access: "none" }, | |
{ action: "read", resource: "Shift", access: "individual" }, | |
{ action: "update", resource: "Shift", access: "individual" }, |
This file contains hidden or 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
class Locator | |
@queue = :location_queue | |
def self.perform | |
begin | |
location = get_location | |
# do something useful with location | |
rescue LocationError => error | |
# do something useful with location error |
This file contains hidden or 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
<html><head><title>502 Bad Gateway</title></head><body><h1>Bad Gateway</h1>An upstream server returned an invalid response.</body></html> |