Uploading profile pic using photofy gem

Hi fellas,

Photofy gem is to provide simple method to do fileupload of pictures and provides getter setter methods of it and save on model object commit we are used of using paperclip and other gems.

But it saves your effort from active record and other kind of stuffs.

Include gem photofy in your Gem file.
gem 'photofy'
bundle install
define photofy with the config in the model for which you want the file upload
photofy(:avatar_image, {image_processor: Proc.new {|img| img.scale(200,200)}})
here after that you need to define your file upload attribute as:
<%= f.file_field :avatar_image %>
in the form where you want to upload the file after that in your action please whitelist your avatar_image attribute as:
params.require(:users).permit(:name, :avatar_image)
 Please be assure you have rmagick gem and imagemagick installed in your system.

After uploading pic and submitting the form you will see a photofy folder will be created in app directory but it will not show the images in your app because image needs to be in public folder for that you need to symlink the photofy directory in public directory.
ln -nfs $PWD/photofy/ public/

Comments

Popular posts from this blog

Installing Wowza Streaming Engine on ubuntu

Highcharts with grouped categories

Completely Uninstall and Install Rubymine on ubuntu