Loading…
Transcript

Logic in views is bad

LOGIC in CONTROLLERS IS BAD

FAT MODELS

CODE SMELLS

DON'T ASK, TELL

controller calls only one model

method in one action

Custom exceptions

if current_user == nil

else

end

bad code

IF statements

to me it's always a possible smell

instance_of?

polymorphism smell

avoid static methods

easy permissions mistakes

not good OOP

user.items.find(id) vs

Item.find(id, :conditions => {:user => self})

default_scope

no nice way to disable it.

it's better to use

user.products

admin.products

USER objects

Guest

User

Admin

SuperAdmin

Partner

modules

concerned_with

AOP - aquarium

Andrzej Krzywda

  • Rails since 2004
  • Arkency, CEO