I'm trying to upload images through carrier wave, and using rails.
using minimagick.
Actually, the uploads working properly I think, but images are not shown up.
Also it shows nil
value in database.
here's my code.
- app/models/user.rb
class User < ActiveRecord::Base
mount_uploader :image, ImageUploader
end
- mypage.html.erb (form action to "edit_complete")
<input type="file" name='image'>
- users_controller.rb
def edit_complete
user = User.find(session[:user_id])
user.image = params[:image]
user.save
redirect_to :back
end
- app/uploaders/image_uploader.rb
class ImageUploader < CarrierWave::Uploader::Base
include CarrierWave::MiniMagick
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
No errors appeared, but nothing saved in database.
I expect image files should be saved in public/upload
folder, and image file should be shown in database in rails c
User.all
.
However, when I upload 1.png file,
there are nothing saved, and public/upload folder is not generated.
Also in database shows nil
value.
Is there any solution for this?