13. Model View Controller
• Interface to the database
• Business Logic goes here
• For the DataBase Admin
class User < ActiveRecord::Base
has_many :tasks
end
class Task < ActiveRecord::Base
belongs_to :user
end
14. Model View Controller
• Link between DB (model) and User (view)
• HTTP / Sessions / Cookies / Post / Get
• For the Developer
class TaskController < ApplicationController
def index
@tasks = User.find(session[:user_id]).tasks
end
end
15. Model View Controller
• Web Interface
• What the client sees
• For the Designer
...
<body>
<% @tasks.each do |task| %>
<div class=’task’>
<%= task.content %> is <%= task.status %>
</div>
<% end %>
</body>