I'm getting this error when I try to submit my form (PDF is supposed to be generated using Wicked PDF gem, on form submission) -
NameError in PostsController#create
uninitialized constant Mime::PDF
Rails.root: /Users/fkhalid2008/littlechits
Application Trace | Framework Trace | Full Trace
app/controllers/posts_controller.rb:42:in `create'
app/controllers/posts_controller.rb:39:in `create'
How do I fix this??? Relevant code is below.
POSTS CONTROLLER
def create
@post = Post.new(params[:post])
@post.user = current_user
respond_to do |format|
if verify_recaptcha && @post.save
format.html { redirect_to :action=> "index"}
format.pdf do
render :pdf => "file_name"
end
else
format.html { render :action => "new" }
format.json { render :json => @post.errors, :status => :unprocessable_entity }
end
end
end
CONFIG/INITIALIZERS/WICKED_PDF.RB
# config/initializers/wicked_pdf.rb
WickedPdf.config = {
:exe_path => '/usr/local/bin/wkhtmltopdf'
}
Thanks,
Faisal