Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Image upload in rails

How do I upload images and zip files in RoR? I am a newbie. So please help. Give me both the view and the controller code example.

Thanks in advance.

like image 313
Nave Avatar asked Jun 09 '09 09:06

Nave


People also ask

How to store image in Rails database?

Seeding Images in Your Rails Database Rails also enables users to seed the database with images if they want. To do so, you can use the 'attach' method, passing in a hash with two keys. The 'io' key calls the open method on the File class and takes the image's relative path as an argument.

What is ActiveStorage?

1 What is Active Storage? Active Storage facilitates uploading files to a cloud storage service like Amazon S3, Google Cloud Storage, or Microsoft Azure Storage and attaching those files to Active Record objects.

How does active storage work in Rails?

Active Storage uses two tables in your application's database named active_storage_blobs and active_storage_attachments . After creating a new application (or upgrading your application to Rails 5.2), run rails active_storage:install to generate a migration that creates these tables.


1 Answers

Nav,

Try the paperclip plugin, you can read about it here http://www.thoughtbot.com/projects/paperclip

like image 136
Lee Hambley Avatar answered Oct 16 '22 17:10

Lee Hambley