I am using Railscasts 182 to crop the uploaded image. As per the video I implemented this:
I am uploading an image in profile page. Here is my profile controller:
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
As per the video my crop.html.erb
file is:
<% "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" %>
And I added these in my application.html.erb
:
<%= javascript_include_tag "jquery.min" %>
<%= yield(:head) %>
When I submit an image, it displays the plain image. It does not show the selection cursor and hence can't select an area on the image as it is shown in the video.
I guess Jcrop is not working. Can anybody tell what would be the issue?