I am using paperclip, devise, aws and heroku to show my pictures on my Rails app. It was working fine until I changed my app/assets/application.js and my controllers/users/sessions_controller.rb
Note: I did not change a thing in my config/environments/production.rb
However I get an syntax error message, when I am using the heroku run rails console.
Running rails console on ⬢ immense-spire-90312... up, run.8450 (Free)
/app/vendor/bundle/ruby/2.2.0/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:293:in `require': /app/config/environments/production.rb:88: syntax error, unexpected '\n', expecting => (SyntaxError)
/app/config/environments/production.rb:92: syntax error, unexpected ':', expecting keyword_end
storage: :s3,
^
In my config/environments/production.rb
config.paperclip_defaults = {
Paperclip::Attachment.default_options[:url] = ':s3_domain_url'
Paperclip::Attachment.default_options[:path] = '/:class/:attachment/:id_partition/:style/:filename'
Paperclip::Attachment.default_options[:s3_host_name] = 's3-eu-central-1.amazonaws.com'
# The syntax error seems to be here:
storage: :s3,
s3_credentials: {
bucket: ENV.fetch('S3_BUCKET_NAME'),
access_key_id: ENV.fetch('AWS_ACCESS_KEY_ID'),
secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY'),
s3_region: ENV.fetch('AWS_REGION'),
}
}
What I've changed:
In javascripts/application.js I put the //= require bootstrap under the jquery_ujs (it was at the bottom at first)
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require turbolinks
//= require owl.carousel
//= require_tree .
And I've created a sessions_controller in devise, so that when a user logs in, I want to change something in the database
class Users::SessionsController < Devise::SessionsController
def create
super do |user|
user.randomized_fakeposts.delete_all
# Note: A fakeposts consists of an image_url which is taken from aws.
Fakepost.all.each do |fp|
user.randomized_fakeposts.new(fakepost: fp)
end
user.save
end
end
end
production.rb
is not valid Ruby: you can't use=
inside of a hash declaration unless it's part of a string or part of the value statement. – coreywardproduction.rb
. Nevertheless, thanks :). – OhDaeSuproduction.rb
had been made previously but unsaved (and/or uncommitted). This is one reason I always review a diff before I commit, and double check withgit status
as well, even if it's a single character being changed. #protip – coreyward