27. UUID Usage
class Contact < ActiveRecord::Base
belongs_to :team
before_create :create_uuid
def to_param
uuid
end
private
def create_uuid
begin
self.uuid = SecureRandom.uuid
end while self.class.exists?(:uuid => uuid)
end
end
28. current_user
# GET /contacts/new
def new
@contact = current_user.contacts.new
end
# GET /contacts/1/edit
def edit
end
# POST /contacts
# POST /contacts.json
def create
@contact =
current_user.contacts.new(contact_params)
29. current_user with Team
# GET /contacts/new
def new
@contact = current_user.team.contacts.new
end
# GET /contacts/1/edit
def edit
end
# POST /contacts
# POST /contacts.json
def create
@contact =
current_user.team.contacts.new(contact_params)
30. RailsConf 2015
• The World of Rails Security
• Metasecurity: Beyond Patching Vulnerabilities