Rails Jcrop Синтаксическая Ошибка

Я добавляю функции обрезки в свое приложение Rails и использую Railscast в качестве своего руководства: http://railscasts.com/episodes/182-cropping-images-revised

Я дважды проверил вещи и все еще получаю странную ошибку при попытке загрузить любую страницу. Вот сообщение, которое я получаю:

SyntaxError in PeopleController#show
/app/uploaders/photo_uploader.rb:40: syntax error, unexpected '(', expecting keyword_end process :resize_to_limit(600, 600) ^ 
/app/uploaders/photo_uploader.rb:80: syntax error, unexpected end-of-input, expecting keyword_end

Extracted source (around line #4):

validates_presence_of :fname, :lname, :company, :department, :title, :work_phone, :mobile, :office, :address, :city, :state, :zipcode, :country, :suite, :column

mount_uploader :photo, PhotoUploader

after_update :crop_photo

Вот мой код модели лица:

class Person < ActiveRecord::Base
validates_presence_of :fname, :lname, :company, :department, :title, :work_phone, :mobile, :office, :address, :city, :state, :zipcode, :country, :suite, :column

mount_uploader :photo, PhotoUploader

after_update :crop_photo


  def crop_photo
    photo.recreate_versions! if crop_x.present?
  end
end

Вот мой код загрузки фото:

# encoding: utf-8

class PhotoUploader < CarrierWave::Uploader::Base

# Include RMagick or MiniMagick support:
include CarrierWave::RMagick
# include CarrierWave::MiniMagick

# Choose what kind of storage to use for this uploader:
# storage :file
 storage :fog

 include CarrierWave::MimeTypes
 process :set_content_type

# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
  "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end

# Provide a default URL as a default if there hasn't been a file uploaded:
def default_url
# For Rails 3.1+ asset pipeline compatibility:
ActionController::Base.helpers.asset_path("fallback/" + [version_name,     "default.png"].compact.join('_'))

# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
end

# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
#   # do something
# end

# Create different versions of your uploaded files:

version :large do
  process :resize_to_limit => [600, 600]
end

version :thumb do
  process :crop
  process :resize_to_limit => [200, 200]
end

def crop
  if model.crop_x.present?
    resize_to_limit(600, 600)
    manipulate! do |img|
      x = model.crop_x.to_i
      y = model.crop_y.to_i
      w = model.crop_w.to_i
      h = model.crop_h.to_i
      img.crop!(x, y, w, h)
    end
  end

after :store, :remove_original_file

def remove_original_file(p)
  if self.version_name.nil?
    self.file.delete if self.file.exists?
  end
end

# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
#   %w(jpg jpeg gif png)
# end

# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
#   "something.jpg" if original_filename
# end

end

Вот что я добавил для моего раздела Create моего контроллера:

if @person.save
  if params[:person][:photo].present?
    render :crop
  else
    redirect_to @user, notice: "Successfully created user."
  end
end

У меня есть аналогичный код в моем новом действии в моем контроллере.

Я полностью в тупике. Количество "Концов", кажется, совпадает с тем, что я видел.

Я на Rails 4, Ruby 2 и использую Bootstrap 2.

Вся помощь очень ценится.

1 ответ

Решение
version :large do
  process :resize_to_limit(600, 600)
end

должно быть:

version :large do
  process :resize_to_limit => [600, 600]
end
Другие вопросы по тегам