From chapter 11 of Ruby on Rails for Dummies:
Contents of Migration
def self.up
Create_table :photos do |t|
t.column :picture, :blob
t.column :description, :text
end
end
def self.down
drop_table :photos
end
Contents of _form.rhtml
<%= error_messages_for ‘photo’ %>
The book has good explanations of what everything is doing. Even if you
don’t want to buy the book, you could run down to your local book store
and check it out.
Modify show.rhtml with this line (presumably this was scaffolded and
then he suggesting adding this one line):
<img src=“<%url_for( :action => “get_picture”, :id => @photo.id ) %>”
/>
which is shown just above this (likely scaffolded) line: <%=photo.description %>
There’s a tweak to the listing page too - looks like he replaced the
table cells that were scaffolded with this:
The book has good explanations of what everything is doing. Even if you
don’t want to buy the book, you could run down to your local book store
and check it out.
The book has good explanations of what everything is doing. Even if you
don’t want to buy the book, you could run down to your local book store
and check it out.