Homework:
- implement the missing stuff from presentation:
- flash messages
- before filters
- simple_form
- Create a cat model:
- name (string) - required
- bio (text) - optional
- gender (string) - Male or Female
# If you want url_for(CoolProject) to give you 'cool_projects/1' but still go to ProjectsController then: | |
resources :cool_projects, :controller => :projects | |
# If you want url_for(CoolProject) to give you 'projects/1' and also go to ProjectsController then: | |
resources :cool_projects, :controller => :projects, :as => :projects | |
# If you want to reuse stuff inside resources: | |
projects_inner = lambda do | |
member do | |
resources :submodels |
module SecretMethods | |
def secret_def(name, &block) | |
klass = self | |
define_method name do | |
if self.class != klass | |
raise NoMethodError | |
else | |
yield | |
end | |
end |
# Improve / Fix as many things in the code below | |
# Answers should be sent to [email protected] | |
# Good luck | |
class User < ActiveRecord::Base | |
validates_presence_of :name, :email, :date_of_birth, :age_category | |
before_save do | |
age = (Time.now - date_of_birth).year | |
if age < 10 age_category = 'child' |
Homework:
var MyCtrl = (function () { | |
var myDependency; | |
function MyCtrl(_myDependency_){ | |
myDependency = _myDependency_; | |
} | |
MyCtrl.prototype.myFunction = function () { | |
return myDependency.aFunction(); | |
} | |
return MyCtrl; | |
})() |
input { | |
overflow:hidden; | |
width:32px; | |
height:30px; | |
border-color:grey; | |
transition:width 0.4s linear, border-color 0.4s linear; | |
&.hover { | |
width:236px; | |
} | |
} |
function DashboardCtrl(DashboardFilter, pubsub) { | |
var self = this; | |
function init() { | |
// Bindable filter, updates automatically | |
self.filter = DashboardFilter.getFilter(); | |
// Listen to filter change: | |
pubsub.on(DASHBOARD_FILTER_CHANGE, function(oldFilter, newFilter) { | |
// Example handling of filter change: | |
if (oldFilter.dashboardName != newFilter.dashboardName) { | |
self.initPanes(); |
function getAllUsers() { | |
let promise = $http.get('/settings') | |
.then((settings) => { | |
if(settings.defaultUsers) { | |
return getDefaultUsers(); | |
} | |
else { | |
// get some more data | |
return $http.get('/users') | |
.then((users) => { |