N
N
nluparev2018-09-08 18:35:21
Ruby on Rails
nluparev, 2018-09-08 18:35:21

Where is the error in the code for loading avatars?

Need help.
I'm not very strong in Rails yet and there is a bug here that I can't find.

# frozen_string_literal: true

class AvatarUploader < ApplicationUploader
  include Piet::CarrierWaveExtension

  process :auto_orient,
          :strip,
          convert: 'jpg',
          resize_to_cover: [1125, 1125],
          optimize: [{ quality: 80, level: 0 }]

  version :s828px { process resize_to_cover: [828, 828] }
  version :s750px { process resize_to_cover: [750, 750] }
  version :s552px { process resize_to_cover: [552, 552] }
  version :s300px { process resize_to_cover: [300, 300] }
  version :s216px { process resize_to_cover: [216, 216] }
  version :s200px { process resize_to_cover: [200, 200] }
  version :s156px { process resize_to_cover: [156, 156] }
  version :s144px { process resize_to_cover: [144, 144] }
  version :s132px { process resize_to_cover: [132, 132] }
  version :s104px { process resize_to_cover: [104, 104] }
  version :s96px  { process resize_to_cover: [96,  96] }
  version :s88px  { process resize_to_cover: [88,  88] }
  version :s72px  { process resize_to_cover: [72,  72] }
  version :s64px  { process resize_to_cover: [64,  64] }
  version :s60px  { process resize_to_cover: [60,  60] }

  def default_filename
    ['avatar', model.gender || 'male', version_name].compact.join('_') + '.png'
  end
end

When deploying via Capistrano, I get the following error
app/uploaders/avatar_uploader.rb:14: syntax error, unexpected '}', expecting keyword_end
01 ...s resize_to_cover: [552, 552] }
Any help would be greatly appreciated

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
oh_shi, 2018-09-09
@nluparev

Inside there: Accordingly, the correct syntax would be:
or
This is because {} has a higher priority than do/end.

R
Roman Mirilaczvili, 2018-09-08
@2ord

There's a syntax error in the Ruby code. If it is already fixed, then you must also restart the web server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question