0

I added the simple_captcha gem and I'm receiving an error in the server when I load up the form that it's located on. I'm not sure how to go about fixing this. Judging my the research I've done on google it appears to be an ImageMagick issue but I'm not entirely sure.

SimpleCaptcha::SimpleCaptchaData Load (0.2ms)  SELECT "simple_captcha_data".* FROM "simple_captcha_data" WHERE "simple_captcha_data"."key" = '406a6bd66e520eef7f24a13c2cc8c5b23d3749e8' LIMIT 1
  CACHE (0.0ms)  SELECT "simple_captcha_data".* FROM "simple_captcha_data" WHERE "simple_captcha_data"."key" = '406a6bd66e520eef7f24a13c2cc8c5b23d3749e8' LIMIT 1

StandardError (Error while running convert: convert: unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' @ error/annotate.c/RenderFreetype/1125.
convert: Postscript delegate failed `/var/tmp/magick-4563zAoZ5QYyFe6C': No such file or directory @ error/ps.c/ReadPSImage/833.
convert: no images defined `/var/folders/6b/tq59gs0d1f7bp_zg41cf6fqm0000gn/T/simple_captcha20130626-4555-1yk8sq1.jpg' @ error/convert.c/ConvertImageCommand/3078.
):

simple_capthca.rb

SimpleCaptcha.setup do |sc|
  # default: 100x28
  sc.image_size = '120x40'

  # default: 5
  sc.length = 6

  # default: simply_blue
  # possible values:
  # 'embosed_silver',
  # 'simply_red',
  # 'simply_green',
  # 'simply_blue',
  # 'distorted_black',
  # 'all_black',
  # 'charcoal_grey',
  # 'almost_invisible'
  # 'random'
  sc.image_style = 'simply_green'

  # default: low
  # possible values: 'low', 'medium', 'high', 'random'
  sc.distortion = 'medium'

  sc.image_magick_path = '/usr/local/bin/' # you can check this from console by running: which convert'

end

reservations_controller.rb

  def create
    @restaurant = Restaurant.find(params[:restaurant_id])
    @reservation = @restaurant.reservations.build(date: DateTime.new(params[:date]["date(1i)"].to_i, params[:date]["date(2i)"].to_i, params[:date]["date(3i)"].to_i), time: (params[:time][:hour]).to_i)
    if @reservation.valid_with_captcha?
      @reservation.save
      @restaurant.owner.send_reservation_notification(@reservation)
      redirect_to restaurant_path(Restaurant.find(params[:restaurant_id]))
    else
      flash[:error] = "Captcha incorrect. You enterd the wrong digits." 
      redirect_to :back
    end
  end

new.html.erb

<h1>Reserve your table.</h1>
<br/>

<div class="reservation-form">
<%= form_for([@restaurant, @reservation]) do |f| %>
    <%= date_select :date, "date"  %><br/>
    <%= select_hour Time.now, :ampm => true, :prefix => :time %><br/><br/>
    <%= f.simple_captcha :label => "Prove that you're not a robot." %><br/>
    <%= f.submit "Make reservation", class: "btn btn-primary" %>
<% end %>
</div>

Reservation.rb

class Reservation < ActiveRecord::Base
  attr_accessible :restaurant_id, :date, :time
  belongs_to :restaurant
  apply_simple_captcha
end
Smooth
  • 956
  • 1
  • 15
  • 37
  • possible answer is here http://stackoverflow.com/questions/13936256/imagemagick-error-while-running-convert-convert-unable-to-read-font – gayavat Sep 04 '13 at 06:53

1 Answers1

0

Probably, you need to install ghostscript after you have imagemagic installed.

fengd
  • 7,551
  • 3
  • 41
  • 44