Reputation: 2497
I have an app running on Nitrous.io with a Ruby 2 and Rails 4.0 setup.
I have carrierwave and Mini_magick gems installed but still my images don't seem to be uploading.
I have the following setup:
profile_uploader.rb
class ProfileUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
Model - list.rb
class List < ActiveRecord::Base
mount_uploader :profile, ProfileUploader
end
New.html.haml
= form_for @list, :html => {:multipart => true} do |f|
.field
= f.label :name
= f.text_field :name
.field
= f.label :telephone
= f.text_field :telephone
.field
= f.label :Profile_image
= f.file_field :profile
= f.hidden_field :profile_cache
= f.submit
= link_to 'Back', lists_path
Really can't work out why this isn't working as I believe everything is setup correctly. Any help people can offer would be great!
Upvotes: 0
Views: 402
Reputation: 2497
So it turns out in my controller I had the following:
def create
@list = List.new(list_params)
if @list.save
redirect_to lists_path
else
render 'lists#new'
end
end
....
def list_params
params.require(:list).permit(:name, :telephone)
end
As soon as I added :profile
to the list_params definition it started working :)
Upvotes: 2