Consider this
if params['image'].nil?
-
In html’s case, I used the above and it checked the presence of file and
hence i changed the path accordingly. How can I check it in erb? -
I have a
<%= f.file_field :IMAGE %>in my code and when I click on
the submit button, I have to store my image in a database and use it
or i want to store the images in files and store the path in database
so i can display the image later.
How can I do this?
1) You can check wether
params['image']is nil or not, you just have to follow the best practice to store it in an instance that I’m going to call@image, although you can be a maverick and useparams['image']if you want.OR
2) You can use a gem to support you like Dragonfly or Paperclip. Check this Paperclip vs Carrierwave vs Dragonfly’s Question out!