0

I'm having trouble getting Cloudinary with Carrierwave to work in my app. I've found both Cloudinary and Heroku's documentation on this to be vague and unsatisfactory, after much searching I found this which has been very helpful but now my app crashes with this error:

 NameError in SiteController#index
uninitialized constant Cloudinary::Uploader::Base 

My photo_uploader.rb looks like this:

class PhotoUploader < CarrierWave::Uploader::Base
  include Cloudinary::Carrierwave


end

professor.rb

require 'elasticsearch/model'
class Professor < ActiveRecord::Base
  attr_accessor :photo
  mount_uploader :photo, PhotoUploader

The view looks like:

  <legend>Photo</legend>
  <%= f.file_field :photo %>

Gemfile:

source 'https://rubygems.org'

ruby '2.3.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.5.1'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
#bcrypt for for encrpytion
gem 'bcrypt', '~> 3.1', '>= 3.1.11'
#byebug
gem 'byebug', '~> 9.0', '>= 9.0.5'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
#paperclip for easy upload management
gem 'paperclip', '~> 4.3', '>= 4.3.6'
#bootstrap-sass
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.6'
#searchkick
gem 'searchkick', '~> 1.2', '>= 1.2.1'
#paginate
gem 'will_paginate', '~> 3.1'
#paginate for bootstrap
gem 'bootstrap-will_paginate', '~> 0.0.10'
#rmagick
gem 'rmagick', '~> 2.15', '>= 2.15.4'
#Carrierwave
gem 'carrierwave'
#Cloudinary
gem 'cloudinary'
#attachinary
gem 'attachinary', '~> 1.3', '>= 1.3.1'
#Paperclip forcloudinary
gem 'paperclip-cloudinary'
#elasticsearch stuff
gem 'elasticsearch-rails'
gem 'elasticsearch-model'
#bonsi
gem 'bonsai-elasticsearch-rails', '~> 0.0.4'

group :production do
  gem 'rails_12factor'
  gem 'puma', '~> 3.4'
  gem 'pg'
end


group :development do
  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'

  gem 'sqlite3'

end
tfantina
  • 788
  • 11
  • 37
  • Did you try installing the [Photo-album](https://github.com/cloudinary/cloudinary_gem/tree/master/samples) sample project provided by Cloudinary_gem repository? Did it work for you? Also, can you add your `gemfile` to the question? – Nadav Ofir Aug 18 '16 at 10:24
  • I haven't tried the photo album yet, I'll mess around with that now. Gemfile posted. – tfantina Aug 18 '16 at 10:39
  • What do you need Attachinary for? Usually you should be using either Cloudinary-Attachinary or Cloudinary-Carrierwave combination. UPDATE: paperclip-cloudinary seems redundant as well, isn't it? – Nadav Ofir Aug 18 '16 at 11:00
  • Attachinary and paperclip are redundant since I was messing around with this I just left them there while I was doing this does it hurt anything? Also I am having lots of problems getting the photo album to work I keep getting errors. – tfantina Aug 19 '16 at 14:27
  • I'd suggest removing them and running `bundle install` as it may cause some collisions. What are the errors with the sample project? If may also contact Cloudinary via support ticket to help you solve this. – Nadav Ofir Aug 21 '16 at 12:22
  • Thanks for your help, I've removed those and run a bundle install but I haven't had a chance to really test it out. With the sample project one of the errors I get is: NoMethodError in PhotosController#index undefined method `mass_assignment_sanitizer=' for ActiveRecord::Base:Class – tfantina Aug 22 '16 at 12:11
  • Also this is another error in the sample project: NoMethodError in PhotosController#index undefined method `mount_uploader' for Photo (call 'Photo.connection' to establish a connection):Class – tfantina Aug 22 '16 at 13:07
  • See: http://stackoverflow.com/questions/8647053/undefined-method-mass-assignment-sanitizer-for-activerecordbaseclass-nome?rq=1 – Nadav Ofir Aug 23 '16 at 15:04

0 Answers0