image path save in mysql database

Hi have doing one ruby project i can upload image in mysql database save in binary

if u have any idea help me

Hi!

Usually, people save only the path for the image in the database and stores the binary file in the filesystem.

Take a look in some gems, like paperclip, that do this job - https://github.com/thoughtbot/paperclip

Best Regards,

Everaldo

Hi

Already i used for paper-clip plugins and i need in file upload add multiple images and store database , if i retrieve images from database all images display in singal page ,

Regards,

John Paul.D

Hi,

I am newbie in RoR and I don’t know how to help you accomplish this (multiple images).

I suggest that you take a look at www.railscasts.com or http://ruby-toolbox.com/

Best Regards,

Everaldo

Look closely at the Creating Complex Forms Railscast (2 parter). While that covers making a quiz, you can follow the same logic to create a way to upload multiple images to a single parent object (using accepts_nested_attributes_for) so there's no limit to the number of images each object can have. The key here is that you need a separate model to hold the images, and then you need to set up a has_many/belongs_to relationship between your parent model and the image model. That way you can have 0 .. N images in each parent object.

Walter

Hi

  i got the path from image file but can't do save database pls help for that code

Hi sir,

I got the file path from image file name , i need how to save tha path in database pls help me because am i newpep

Hi!

You should save the image path in the database (create a column for your model - do a migration for this) and then, when you load your model, you could retrieve your image using the path information stored in the database (use File.read or something like this to load your image).

http://railscasts.com/episodes/134-paperclip

https://github.com/thoughtbot/paperclip

http://jimneath.org/2008/04/17/paperclip-attaching-files-in-rails/

Best regards,

Everaldo