Rails 3.1, ActiveRecord, JQuery
I am using Carrierwave to upload an image to a model using AWS S3. Very simple just one image per model. I want to use Uploadify with it.
It works fine without Uploadify, but with it I get the error:
NoMethodError (undefined method `has_key?' for #<ImageUploader:0x00000103c7f2f0>):
The code for the uploader works on its own and I've followed this post to try to get Uploadify to work. And then I used this code to get the CSRF issue taken care of.
The code to set up Uploadify in the edit.html.erb is:
<% content_for :head do %>
<%= javascript_include_tag 'jquery.uploadify.v2.1.4.min' %>
<%= javascript_include_tag 'swfobject' %>
<% end %>
<%= content_for :scripts do %>
<script type="text/javascript">
<% session_key_name = Rails.application.config.session_options[:key] %>
jQuery('input#facility_image').uploadify({
'uploader' : '/assets/uploadify.swf',
'script' : '<%=facilities_path%>',
'fileDataName' : 'facility[image]',
'fileExt' : '*.png;*.jpg;*.gif',
'cancelImg' : '/assets/cancel.png',
'multi' : false,
'scriptData' : {
'_http_accept': 'application/javascript',
'<%= session_key_name %>' : encodeURIComponent('<%= u cookies[session_key_name] %>'),
'authenticity_token': encodeURIComponent('<%= u form_authenticity_token %>'),
},
'auto' : true,
'buttonText' : 'Upload Image',
'onComplete' : function(e, id, obj, response, data) {
$('#images').append(response);
}
});
</script>
<% end%>
Anyone know why this error is happening and/or how to fix it?
If you are using devise, this is a better fix http://ariejan.net/2011/03/27/rails-3-devise-uploadify-no-flash-session-hacks