23.9 Layouts and Components 23.7 Working with Nonmodel Fields
rails generate model picture comment:string name:string content_type:string data:binary
invoke active_record
create db/migrate/20120629192405_create_pictures.rb
create app/models/picture.rb
invoke test_unit
create test/unit/picture_test.rb
create test/fixtures/pictures.yml
cp -v /home/rubys/git/awdwr/edition3/data/code/e1/views/db/migrate/*pictures.rb db/migrate/*pictures.rb
`/home/rubys/git/awdwr/edition3/data/code/e1/views/db/migrate/003_create_pictures.rb' -> `db/migrate/20120629192405_create_pictures.rb'
cp -v /home/rubys/git/awdwr/edition3/data/code/e1/views/app/models/picture.rb app/models
`/home/rubys/git/awdwr/edition3/data/code/e1/views/app/models/picture.rb' -> `app/models/picture.rb'
rake db:migrate
mv 20120629192405_create_pictures.rb 20110711000004_create_pictures.rb
== CreatePictures: migrating =================================================
-- create_table(:pictures)
-> 0.0018s
== CreatePictures: migrated (0.0019s) ========================================
cp -vr /home/rubys/git/awdwr/edition3/data/code/e1/views/app/views/upload app/views
`/home/rubys/git/awdwr/edition3/data/code/e1/views/app/views/upload' -> `app/views/upload'
`/home/rubys/git/awdwr/edition3/data/code/e1/views/app/views/upload/save.html.erb' -> `app/views/upload/save.html.erb'
`/home/rubys/git/awdwr/edition3/data/code/e1/views/app/views/upload/show.html.erb' -> `app/views/upload/show.html.erb'
`/home/rubys/git/awdwr/edition3/data/code/e1/views/app/views/upload/get.html.erb' -> `app/views/upload/get.html.erb'
edit app/views/upload/get.html.erb
<%= error_messages_for("picture") %>
<%= form_for(:picture,
:url => {:action => 'save'},
:html => { :multipart => true }) do |form| %>
Comment: <%= form.text_field("comment") %><br/>
Upload your picture: <%= form.file_field("uploaded_picture") %><br/>
<%= submit_tag("Upload file") %>
<% end %>
get /upload/get
23.9 Layouts and Components 23.7 Working with Nonmodel Fields