0

simple_captcha gem を追加しましたが、それが配置されているフォームをロードすると、サーバーでエラーが発生します。これを修正する方法がわかりません。私がGoogleで行った調査を判断すると、ImageMagickの問題のように見えますが、完全にはわかりません.

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

予約_コントローラー.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>

予約.rb

class Reservation < ActiveRecord::Base
  attr_accessible :restaurant_id, :date, :time
  belongs_to :restaurant
  apply_simple_captcha
end
4

1 に答える 1

0

ghostscriptおそらく、インストール後にインストールする必要がありますimagemagic

于 2013-09-06T05:45:00.367 に答える