Ruby on rails 未经允许的参数错误-设计+;回形针&x2B;赫罗库+;S3
我真的需要一些帮助,通过我使用Desive for users和回形针构建的应用程序将个人资料图像正确上传到S3 我的其他模型都能很好地使用回形针,从Heroku到S3,我唯一不能使用的模型是Desive的用户模型。我读过100篇关于为Desive设置配置的允许参数的不同文章,但似乎没有变量起作用。我已经阅读了关于这个问题的所有堆栈溢出问答,似乎没有一个与我的相关 我在用户模型中添加了其他属性(profile name、dob等),所有这些属性都工作得很好。只有图像不工作 我在下面包含了完整的日志文件,其中显示了错误消息-“未经许可的参数:宝丽来” 回形针“图像”文件名称为“宝丽来” 有什么想法吗??谢谢 应用程序控制器.rbRuby on rails 未经允许的参数错误-设计+;回形针&x2B;赫罗库+;S3,ruby-on-rails,heroku,amazon-s3,devise,paperclip,Ruby On Rails,Heroku,Amazon S3,Devise,Paperclip,我真的需要一些帮助,通过我使用Desive for users和回形针构建的应用程序将个人资料图像正确上传到S3 我的其他模型都能很好地使用回形针,从Heroku到S3,我唯一不能使用的模型是Desive的用户模型。我读过100篇关于为Desive设置配置的允许参数的不同文章,但似乎没有变量起作用。我已经阅读了关于这个问题的所有堆栈溢出问答,似乎没有一个与我的相关 我在用户模型中添加了其他属性(profile name、dob等),所有这些属性都工作得很好。只有图像不工作 我在下面包含了完整的日
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update).push(:email, :password, :current_password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
devise_parameter_sanitizer.for(:sign_up).push(:email, :password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
end
end
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
private
def user_params
params.require(:user).permit(:email, :password, :current_password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
end
end
class ApplicationController
用户控制器.rb
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
before_filter :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update).push(:email, :password, :current_password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
devise_parameter_sanitizer.for(:sign_up).push(:email, :password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
end
end
class UsersController < ApplicationController
def index
@users = User.all
end
def show
@user = User.find(params[:id])
end
private
def user_params
params.require(:user).permit(:email, :password, :current_password, :password_confirmation, :profile_name, :profile_dob, :profile_zipcode, :profile_country, :profile_timezone, :profile_datejoined, :profile_occupation, :profile_school, :profile_biography, :filter_dateyesno, :filter_distancefrom, :filter_organizerage_min, :filter_organizerage_max, :filter_groupsize_min, :filter_groupsize_max, :profile_gender, :polaroid)
end
end
class UsersController
设计注册中的Edit.html.erb
<h2>Update Profile Information</h2>
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= f.error_notification %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
<div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div>
<% end %>
<% if current_user.polaroid.exists? %>
<%= image_tag (current_user.polaroid.url(:small)) %><br/>
<%= f.file_field :polaroid, multiple: true %>
<% else %>
<div class="field">
<%= f.label :profile_photo %>
<%= f.file_field :polaroid, multiple: true %>
</div>
<% end %>
<div class="field">
<%= f.label :first_name %><br />
<%= f.text_field :profile_name, autofocus: true %>
</div>
<div class="field">
<%= f.label :birthday %><br />
<%= f.date_field :profile_dob, autofocus: true %>
</div>
<div class="field">
<%= f.label :gender %><br />
<%= f.text_field :profile_gender, autofocus: true %>
</div>
<div class="field">
<%= f.label :zipcode %><br />
<%= f.text_field :profile_zipcode, autofocus: true %>
</div>
<div class="field">
<%= f.label :country %><br />
<%= f.text_field :profile_country, autofocus: true %>
</div>
<div class="field">
<%= f.label :timezone %><br />
<%= f.text_field :profile_timezone, autofocus: true %>
</div>
<div class="field">
<%= f.label :occupation %><br />
<%= f.text_field :profile_occupation, autofocus: true %>
</div>
<div class="field">
<%= f.label :university_attended %><br />
<%= f.text_field :profile_school, autofocus: true %>
</div>
<div class="field">
<%= f.label :biography %><br />
<%= f.text_field :profile_biography, autofocus: true %>
</div>
<br />
<%= f.input :filter_dateyesno, label: "Are you single and looking for dates?", as: :radio_buttons %>
<br />
<div class="field">
<%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
<%= f.password_field :current_password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :new_password %> <i>(leave blank if you don't want to change it)</i><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :new_password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<br />
<h4>Make sure to type in your password before updating</h4>
<%= f.button :submit, "Update" %>
<% end %>
<h3>Cancel my account</h3>
<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p>
<%= link_to "Back", :back %>
更新配置文件信息
目前正在等待确认:
(我们需要您当前的密码来确认您的更改)
(如果不想更改,请留空)
请确保在更新之前键入密码
取消我的帐户
不开心
正在使用的其他回形针型号:
Started POST "/outings" for ::1 at 2016-06-25 20:47:39 -0400
Processing by OutingsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"/eflxdhQ1vPTnTE1YnCOes0k6iggGE64oSI6LDhyRepODp3FZ6FDIaxBVZEZCPge2gHQaHZjjLPhHsUh1IWY6g==",
"outing"=>{"image"=>#<ActionDispatch::Http::UploadedFile:0x007fc792c98bf8
@tempfile=#<Tempfile:/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/RackMultipart20160625-38562-t3pccn.png>,
@original_filename="Beer.png",
@content_type="image/png",
@headers="Content-Disposition: form-data; name=\"outing[image]\";
filename=\"Beer.png\"\r\nContent-Type: image/png\r\n">,
"date_date(1i)"=>"2016", "date_date(2i)"=>"6", "date_date(3i)"=>"28", "date_time(1i)"=>"2016", "date_time(2i)"=>"6", "date_time(3i)"=>"26", "date_time(4i)"=>"00", "date_time(5i)"=>"47", "date_duration"=>"2", "date_title"=>"Beer Garden", "date_category"=>"Drinking", "date_description"=>"Beer Garden", "date_location"=>"New York", "date_city"=>"", "date_state"=>"", "date_zip"=>""}, "commit"=>"Create New Date"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 20]]
Command :: file -b --mime '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-40htqc.png'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
Command :: convert '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' -auto-orient -resize "x600" -crop "600x600+11+0" +repage '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/4331dbefbe38c7e67b6851de8064954e20160625-38562-1ljzx69'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
Command :: convert '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' -auto-orient -resize "x300" -crop "300x300+5+0" +repage '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/4331dbefbe38c7e67b6851de8064954e20160625-38562-1pw6qi3'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
Command :: convert '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' -auto-orient -resize "x150" -crop "150x150+2+0" +repage '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/4331dbefbe38c7e67b6851de8064954e20160625-38562-16rm0mr'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' 2>/dev/null
Command :: identify -format %m '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
Command :: convert '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]' -auto-orient -resize "x50" -crop "50x50+0+0" +repage '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/4331dbefbe38c7e67b6851de8064954e20160625-38562-ge9nrr'
(0.3ms) BEGIN
Command :: file -b --mime '/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-we9bgq.png'
SQL (0.5ms) INSERT INTO "outings" ("date_title", "date_description", "date_duration", "date_category", "date_location", "date_city", "date_state", "image_file_name", "image_content_type", "image_file_size", "image_updated_at", "date_date", "date_time", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16) RETURNING "id" [["date_title", "Beer Garden"], ["date_description", "Beer Garden"], ["date_duration", 2], ["date_category", "Drinking"], ["date_location", "New York"], ["date_city", ""], ["date_state", ""], ["image_file_name", "Beer.png"], ["image_content_type", "image/png"], ["image_file_size", 520764], ["image_updated_at", "2016-06-25 20:47:39.380829"], ["date_date", "2016-06-28"], ["date_time", "2016-06-26 00:47:00.000000"], ["user_id", 20], ["created_at", "2016-06-25 20:47:39.961401"], ["updated_at", "2016-06-25 20:47:39.961401"]]
[paperclip] saving /outings/images/000/000/017/original/Beer.png
[paperclip] saving /outings/images/000/000/017/large/Beer.png
[paperclip] saving /outings/images/000/000/017/medium/Beer.png
[paperclip] saving /outings/images/000/000/017/small/Beer.png
[paperclip] saving /outings/images/000/000/017/thumb/Beer.png
(6.4ms) COMMIT
Redirected to http://localhost:3000/outings/17
Completed 302 Found in 2514ms (ActiveRecord: 7.5ms)
于2016-06-25 20:47:39-0400开始为::1发布“/外出”
OutingsController处理#创建为HTML
参数:{“utf8”=>“✓", "真实性令牌“=>”/EFLXDHQ1VPTNTE1YNCOES0K6IGGGE64OSI6DHYREPODP3FZ6FDIAXBVZEZCPGE2GHQAHZJJLPHHSUH1YWY6G==”,
“外出”=>{“图像”=>#,
“日期时间(1i)”=>“2016”,“日期时间(2i)”=>“6”,“日期时间(3i)”=>“28”,“日期时间(1i)”=>“2016”,“日期时间(2i)”=>“6”,“日期时间(3i)”=>“26”,“日期时间(4i)”=>“00”,“日期时间(5i)”=>“47”,“日期持续时间”=>“2”,“日期标题”=>“啤酒花园”,“日期类别”=>“饮酒”,“日期描述”=>“啤酒花园”,“日期”=>“纽约市”=>“日期”=>,“日期\状态”=>,“日期\压缩”=>,“提交”=>“创建新日期”}
用户加载(0.3ms)选择“用户”。*从“用户”中选择“用户”。“id”=用户订购的$1。“id”ASC限制1[[“id”,20]]
命令::file-b--mime'/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1dedede867c96aafb12010625-38562-40htqc.png'
命令::标识-格式“%wx%h,%[exif:orientation]”/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c684357e49fd6b1dededee867c96aafb120160625-38562-1ep7wo7.png[0]”2>/dev/null
命令::identify-格式%m'/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
命令::convert'/var/folders/00/CVFS5P4964Q3LQ115SVTF00000GN/T/C6884357E49FD6B1FDE867C96AAFB120160625-38562-1ep7wo7.png[0]-自动定向-调整“x600”大小-裁剪“600x600+11+0”+重新分页/var/folders/00/CVFS5P496Q3LQ115SVTF00000GN/T/T/4331DBEFBE38C7B6851DE8064954E201625-38562-1LZX69'
命令::标识-格式“%wx%h,%[exif:orientation]”/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c684357e49fd6b1dededee867c96aafb120160625-38562-1ep7wo7.png[0]”2>/dev/null
命令::identify-格式%m'/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]'
命令::转换“/var/folders/00/cvfs5p4964q5q3lq115svtf00000gn/T/c6884357e49fd6b1fdede867c96aafb120160625-38562-1ep7wo7.png[0]”-自动定向-调整大小