README.md in rails-uploader-0.2.0 vs README.md in rails-uploader-0.2.1
- old
+ new
@@ -61,16 +61,17 @@
validates_integrity_of :data
validates_filesize_of :data, :maximum => 2.megabytes.to_i
# structure of returned json array of files. (used in Hash.to_json operation)
- def serializable_hash options=nil
+ def serializable_hash(options=nil)
{
- 'id' => id.to_s,
+ "id" => id.to_s,
"filename" => File.basename(data.path),
"url" => data.url,
- 'thumb_url' => data.url(:thumb)
+ "thumb_url" => data.url(:thumb),
+ "public_token" => public_token
}
end
end
```
@@ -127,54 +128,55 @@
has_one :picture, :as => :assetable
has_one :avatar, :as => :assetable
fileuploads :picture, :avatar
end
+```
### Include assets
Javascripts:
-``` ruby
+```
//= require uploader/application
```
Stylesheets:
-``` ruby
+```
*= require uploader/application
```
### Views
-``` ruby
+```erb
<%= uploader_field_tag :article, :photo %>
```
or FormBuilder:
-``` ruby
+```erb
<%= form.uploader_field :photo, :sortable => true %>
```
### Formtastic
-``` ruby
+```erb
<%= f.input :pictures, :as => :uploader %>
```
### SimpleForm
-``` ruby
+```erb
<%= f.input :pictures, :as => :uploader, :input_html => {:sortable => true} %>
```
#### Confirming deletions
This is only working in Formtastic and FormBuilder:
-``` ruby
+``` erb
# formtastic
<%= f.input :picture, :as => :uploader, :confirm_delete => true %>
# the i18n lookup key would be en.formtastic.delete_confirmations.picture
```