3. Agenda - Day 2
Discuss your current Applications.
Gems currently in use
Resolving problems.
ActiveResource
Rails Security
Data Caching
Performace monitoring and improvement
21. So, you know Ruby?
a[1] # What is the data type of a?
22. So, you know Ruby?
a[1] # What is the data type of a?
a = [‘a’, ‘b’] # Array
23. So, you know Ruby?
a[1] # What is the data type of a?
a = [‘a’, ‘b’] # Array
a = { 1 => ‘a’} # Hash
24. So, you know Ruby?
a[1] # What is the data type of a?
a = [‘a’, ‘b’] # Array
a = { 1 => ‘a’} # Hash
a = “abc” # String
25. So, you know Ruby?
a[1] # What is the data type of a?
a = [‘a’, ‘b’] # Array
a = { 1 => ‘a’} # Hash
a = “abc” # String
a = Proc.new { | x | p x } # proc
54. Open / Closed
Open for Extension
Closed for modification
ParseFeed
Atom RSS
ParseFeed
55. Liskov Substituion
Functionality should work for all
derived classes.
Let q(x) be a property provable about
objects x of type T. Then q(y) should
be true for objects y of type S where
S is subtype of T
63. Dependent Modules
module Foo
def self.included(base)
base.class_eval do
def self.foo_method
end
end
end
end
module Bar
def self.included(base)
base.foo_method
end
end
64. Dependent Modules
module Foo
def self.included(base)
base.class_eval do
def self.foo_method
end
end
end
end
module Bar
def self.included(base)
base.foo_method
end
end
class Base
include Foo
include Bar
end
65. Dependent Modules
module Foo
def self.included(base)
base.class_eval do
def self.foo_method
end
end
end
end
module Bar
def self.included(base)
base.foo_method
end
end
class Base
include Foo
include Bar
end
add module
dependency
#!!
84. Using Application
models in engines.
Add migration for owner_id
class Shuttle
belongs_to :owner, class: “Company”
end
NEVER hardcode associations directly
in engines. Use class option.
87. Inherit from App
# rocket/app/controller/rocket/application_controller.rb
class Rocket::ApplicationController <
ApplicationController
end
# shuttles_controller.rb
class ShuttleController < ApplicationControler
before_action :authenticate_user!
end
88. Checklist
Automatic namespace resolution.
Views that access models require to be fully
resolved.
rake <engine>:install:migrations
rake railties:install:migrations
Controllers permit parameters
No hardcoded associations from top-level app.