Dissecting the Application
Dissecting the Photo Model
Our photo album app has one basic piece of data, represented in a Model called Photo. Let’s add some code to what’s already there and explore what it does. Edit
app/models/photo.rb to match the following:
class Photo < ActiveRecord::Base =begin explain Closely follows Object-Relational Model, each instance is also a record in the table called 'photos'. =end ❶ def next_id() return Photo.minimum(:id) if last_id? next_id = @attributes['id'].to_i.succ next_id.succ! until Photo.find(next_id) next_id.to_s end ❷ def ...