【发布时间】:2013-02-22 10:27:52
【问题描述】:
我正在使用 Railscasts 182 裁剪上传的图像。根据我实现的视频:
我正在个人资料页面上传一张图片。这是我的个人资料控制器:
def edit
@profile = current_user.profile
if @profile.photo.nil?
redirect_to current_user.profile
else
render :action => "crop"
end
end
def update
@profile = current_user.profile
if @profile.update_attributes(params[:profile])
if @profile.photo.nil?
redirect_to current_user.profile
else
render :action => "crop"
end
else
render :edit
end
end
根据视频我的crop.html.erb 文件是:
<% "Crop avatar" %>
<% content_for(:head) do %>
<%= stylesheet_link_tag "jquery.Jcrop" %>
<%= javascript_include_tag "jquery.Jcrop.min" %>
<script type="text/javascript">
$(function(){
$("#cropbox").jCrop();
});
</script>
<% end %>
<%= image_tag @profile.photo.avatar.url(:big), :id => "cropbox" %>
我在我的application.html.erb 中添加了这些:
<%= javascript_include_tag "jquery.min" %>
<%= yield(:head) %>
当我提交图像时,它会显示普通图像。它不显示选择光标,因此无法像视频中显示的那样选择图像上的区域。
我猜 Jcrop 不工作。谁能告诉我会是什么问题?
【问题讨论】:
标签: jquery ruby-on-rails-3 jcrop railscasts