How to use wkhtmltoimage together with rails template without getting Double render error -
i trying use wkhtmltoimage respond png instead of html,
this png picture version of same html, respond png, need construct html src feed imgkit , , want use rails template html..
when following , double render error... how solve this?
respond_to |format| format.html { } format.png { generated_html = render :action => "datatable.png.erb" # ready generate png image html mime::type.register "image/png", :png imgkit.configure |config| config.default_options = { :quality => 1 } config.default_format = :png end kit = imgkit.new( generated_html ) send_data( kit.to_png, :type => "image/png", :disposition => 'inline') } end
render and/or redirect called multiple times in action. please note may call render or redirect, , @ once per action. note neither redirect nor render terminate execution of action, if want exit action after redirecting, need "redirect_to(...) , return".
alright, have figured out answer myself. use erb.
Comments
Post a Comment