Commit 1f0795fc by Corinne Kelly Committed by Sid Raval

Updated the Readme (#2417)

* Updated the Readme, added a submit button to the form and made some notes to make instructions more clear
parent 69056cd9
...@@ -206,6 +206,8 @@ end ...@@ -206,6 +206,8 @@ end
### Migrations ### Migrations
Assuming you have a `users` table, add an `avatar` column to the `users` table:
```ruby ```ruby
class AddAvatarColumnsToUsers < ActiveRecord::Migration class AddAvatarColumnsToUsers < ActiveRecord::Migration
def up def up
...@@ -221,10 +223,11 @@ end ...@@ -221,10 +223,11 @@ end
(Or you can use the Rails migration generator: `rails generate paperclip user avatar`) (Or you can use the Rails migration generator: `rails generate paperclip user avatar`)
### Edit and New Views ### Edit and New Views
Make sure you have corresponding methods in your controller:
```erb ```erb
<%= form_for @user, url: users_path, html: { multipart: true } do |form| %> <%= form_for @user, url: users_path, html: { multipart: true } do |form| %>
<%= form.file_field :avatar %> <%= form.file_field :avatar %>
<%= form.submit %>
<% end %> <% end %>
``` ```
...@@ -233,6 +236,7 @@ end ...@@ -233,6 +236,7 @@ end
```erb ```erb
<%= simple_form_for @user, url: users_path do |form| %> <%= simple_form_for @user, url: users_path do |form| %>
<%= form.input :avatar, as: :file %> <%= form.input :avatar, as: :file %>
<%= form.submit %>
<% end %> <% end %>
``` ```
...@@ -254,7 +258,7 @@ end ...@@ -254,7 +258,7 @@ end
``` ```
### View Helpers ### View Helpers
Add these to the view where you want your images displayed:
```erb ```erb
<%= image_tag @user.avatar.url %> <%= image_tag @user.avatar.url %>
<%= image_tag @user.avatar.url(:medium) %> <%= image_tag @user.avatar.url(:medium) %>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment