Skip to content

Commit

Permalink
Changed cropping_params synta
Browse files Browse the repository at this point in the history
- Updated Readme.md accordingly
- Fixes the bug in which prams.require.(:user) accidently got hardcoded
  • Loading branch information
ezuhaib committed May 8, 2014
1 parent 8a7377b commit 6fa46dc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@

provided that the attachment name is `avatar`.

1. If using **Rails 4** , add this:
1. If using **Rails 4** , `cropping_params(:avatar)` outputs a list of parameters being used by papercrop, where `:avatar` is the name of attachment as defined in your model. You can use this helper in two ways:

cropping_params(:avatar)

where `:avatar` is the name of attachment as defined in your model. You can use this helper in two ways:

@user.update_attributes(cropping_params(:avatar)
@user.update_attributes(params.require(:user).permit( cropping_params(:avatar) )

or

def user_params
params.require(:user).permit(:email,:password,:password_confirmation)
cropping_params(:avatar)
params.require(:user).permit(:email,:password,:password_confirmation,cropping_params(:avatar))
end

The difference is that the former only allows cropping paramters through, which is useful if you are using a seperate cropping page. The later is useful if the cropping box is somehow integrated with another form.
The difference is that the former only allows cropping paramters through, which is useful if you are using a seperate cropping page. The later is useful if the cropping form is somehow integrated with another form.

1. Includes minified resources. Saves an additional ~30kB.

Expand Down
2 changes: 1 addition & 1 deletion lib/papercrop/controller_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def cropping_params(attachment_name)
array = [ :crop_x, :crop_y, :crop_w, :crop_h, :original_w, :original_h, :box_w, :aspect,
:min_size, :max_size, :cropped_geometries]
array = array.collect {|a| "#{attachment_name}_#{a}"}
params.require(:user).permit(array)
return array
end

end
Expand Down

0 comments on commit 6fa46dc

Please sign in to comment.