我正在关注RyanBates关于使用jCrop http://railscasts.com/episodes/253-carrierwave-file-uploads裁剪用户化身的屏幕。Ryan从零开始使用身份验证系统,但我为此使用了Devise。
为了将用户带到处理裁剪的crop.html.haml,我在应用程序/控制器中创建这个文件并指定
routes.rb
devise_for :users, path_names: { sign_in: "login", sign_out: "logout" },
controllers: { registrations: "registrations" }我在registration_controller.rb中的更新操作如下所示
def update
if resource.update_with_password(resource_params)
if params[:user][:avatar].present?
render 'crop'
else
expire_session_data_after_sign_in!
redirect_to users_path, notice: "User updated."
end
else
clean_up_passwords(resource)
flash[:notice] = flash[:notice].to_a.concat resource.errors.full_messages
session[:subscription] = resource
redirect_to root_path
end结束
当我单击导致以下错误的“裁剪”时:
ActiveModel::MassAssignmentSecurity::Error in UsersController#update
Can't mass-assign protected attributes: crop_x, crop_y, crop_w, crop_h在user.rb中
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h我也试着把它放进attar_accesible,但是它不起作用
发布于 2012-11-25 02:32:03
您似乎在"attar_accesible“中有两种类型的字体,尝试attr_accessible并查看它是否有效。
https://stackoverflow.com/questions/13547714
复制相似问题