خطأ RMAGIC في القضبان ، مع مخططات AM
-
24-09-2019 - |
سؤال
أنا أستخدم Amcharts و Rails. يستخدم Amcharts صورة Magic Lib لتصدير صورة للمخطط. في القضبان يتم ذلك مع الجوهرة ، rmagic.
في وحدة تحكم يتم تنفيذ هذا باستخدام طريقة وحدة التحكم التالية:
def export
width = params[:width].to_i
height = params[:height].to_i
data = {}
img = Magick::Image.new(width, height)
height.times do |y|
row = params["r#{y}"].split(',')
row.size.times do |r|
pixel = row[r].to_s.split(':')
pixel[0] = pixel[0].to_s.rjust(6, '0')
if pixel.size == 2
pixel[1].to_i.times do
(data[y] ||= []) << pixel[0]
end
else
(data[y] ||= []) << pixel[0]
end
end
width.times do |x|
img.pixel_color(x, y, "##{data[y][x]}")
end
end
img.format = "PNG"
send_data(img.to_blob , :disposition => 'inline', :type => 'image/png', :filename => "chart.png?#{rand(99999999).to_i}")
end
ومع ذلك ، عند الوصول إلى وحدة التحكم ، أتلقى هذا الخطأ في الصفحة:
The change you wanted was rejected.
Maybe you tried to change something you didn't have access to.
وهذا الخطأ في السجلات (تشغيله على Heroku -BTW):
ActionController::InvalidAuthenticityToken (ActionController::InvalidAuthenticityToken):
/home/heroku_rack/lib/static_assets.rb:9:in `call'
/home/heroku_rack/lib/last_access.rb:25:in `call'
/home/heroku_rack/lib/date_header.rb:14:in `call'
thin (1.0.1) lib/thin/connection.rb:80:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:78:in `catch'
thin (1.0.1) lib/thin/connection.rb:78:in `pre_process'
thin (1.0.1) lib/thin/connection.rb:57:in `process'
thin (1.0.1) lib/thin/connection.rb:42:in `receive_data'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run_machine'
eventmachine (0.12.6) lib/eventmachine.rb:240:in `run'
thin (1.0.1) lib/thin/backends/base.rb:57:in `start'
thin (1.0.1) lib/thin/server.rb:150:in `start'
thin (1.0.1) lib/thin/controllers/controller.rb:80:in `start'
thin (1.0.1) lib/thin/runner.rb:173:in `send'
thin (1.0.1) lib/thin/runner.rb:173:in `run_command'
thin (1.0.1) lib/thin/runner.rb:139:in `run!'
thin (1.0.1) bin/thin:6
/usr/local/bin/thin:20:in `load'
/usr/local/bin/thin:20
Rendering /disk1/home/slugs/149903_609c236_eb4f/mnt/public/422.html (422 Unprocessable Entity)
أي شخص لديه أي فكرة عما يحدث هنا؟
المحلول
لقد اكتشفت ذلك:
إضافة: طلب "rmagick"
&
skip_before_filter: Verify_Authenticity_token
إلى صفي
لا تنتمي إلى StackOverflow