Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Rails MVC: How to write models

thin views, thin controllers, fat models How to deal with fat models?
by

Andrzej Krzywda

on 11 May 2010

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Rails MVC: How to write models

Andrzej Krzywda

Rails since 2004
Arkency, CEO

Logic in views is bad

LOGIC in CONTROLLERS IS BAD

FAT MODELS USER objects

Guest
User
Admin
SuperAdmin
Partner default_scope

no nice way to disable it.
it's better to use
user.products
admin.products avoid static methods

easy permissions mistakes
not good OOP
user.items.find(id) vs
Item.find(id, :conditions => {:user => self}) IF statements

to me it's always a possible smell
instance_of?

polymorphism smell CODE SMELLS if current_user == nil

else

end

bad code DON'T ASK, TELL Custom exceptions controller calls only one model
method in one action modules
concerned_with
AOP - aquarium
Full transcript