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/20100807132246_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/data/code/e1/views/db/migrate/*pictures.rb db/migrate/*pictures.rb
`/home/rubys/git/awdwr/data/code/e1/views/db/migrate/003_create_pictures.rb' -> `db/migrate/20100807132246_create_pictures.rb'
cp -v /home/rubys/git/awdwr/data/code/e1/views/app/models/picture.rb app/models
`/home/rubys/git/awdwr/data/code/e1/views/app/models/picture.rb' -> `app/models/picture.rb'
rake db:migrate
mv 20100807132246_create_pictures.rb 20100301000004_create_pictures.rb
(in /home/rubys/git/awdwr/work-188/view)
== CreatePictures: migrating =================================================
-- create_table(:pictures)
-> 0.0017s
== CreatePictures: migrated (0.0018s) ========================================
cp -vr /home/rubys/git/awdwr/data/code/e1/views/app/views/upload app/views
`/home/rubys/git/awdwr/data/code/e1/views/app/views/upload' -> `app/views/upload'
`/home/rubys/git/awdwr/data/code/e1/views/app/views/upload/show.html.erb' -> `app/views/upload/show.html.erb'
`/home/rubys/git/awdwr/data/code/e1/views/app/views/upload/get.html.erb' -> `app/views/upload/get.html.erb'
`/home/rubys/git/awdwr/data/code/e1/views/app/views/upload/save.html.erb' -> `app/views/upload/save.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