Commit 8e6c19a9 by Tiffany Green Committed by Dan Collis-Puro

Update README.md

Added changes to instructions to work with Rails 4's strong parameters.
parent a01677f5
...@@ -104,6 +104,7 @@ class User < ActiveRecord::Base ...@@ -104,6 +104,7 @@ class User < ActiveRecord::Base
has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png" has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }, :default_url => "/images/:style/missing.png"
end end
``` ```
(Note: if you are using Rails 4, leave attr_accessible out to accommodate [strong parameters](https://github.com/rails/strong_parameters). Instead add the parameters in the controller (see below).)
In your migrations: In your migrations:
...@@ -136,6 +137,18 @@ def create ...@@ -136,6 +137,18 @@ def create
@user = User.create( params[:user] ) @user = User.create( params[:user] )
end end
``` ```
If you are using Rails 4, add this to your controller as well:
```ruby
private
# Use strong_parameters for attribute whitelisting
# Be sure to update your create() and update() controller methods.
def user_params
params.require(:user).permit(:avatar)
end
```
In your show view: In your show view:
......
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