Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multiple_files_by_pete

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multiple_files_by_pete

  • 0.3.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Ruby On Rails multiple files by Pete

An agile way to implement multiple files uploads in a Ruby On Rails scaffold without the need to create additional tables

Installation

Add this line to your application's Gemfile:

gem 'multiple_files_by_pete'

And then execute:

$ bundle install

Support

Ruby On Rails: 5, 6, 7

This gem does not work with SQLite database

Usage

Let's create a example for a Place scaffold:

  1. Let's create a new rails app:
rails new myapp --database=postgresql
  1. Create the database:
bundle exec rake db:create
  1. Go to your application's directory in Terminal and run the command:
bundle exec rails g scaffold Place name:string description:text
  1. Add this line to your application's Gemfile:
gem 'multiple_files_by_pete'
  1. Go to your application's directory in Terminal and run:
bundle install
    1. Go to the application directory in Terminal and run the following command to install the necessary code and files from the gem:
bundle exec rake 'multiple_files_by_pete[place]'
  1. Add jQuery to your layout file:
<script src='/multiple_files_by_pete/jquery-3.6.0.min.js'></script>
  1. Add bootstrap.min.css to your layout file:
<link rel="stylesheet" href="/multiple_files_by_pete/bootstrap.min.css">
  1. Copy and paste this code to get all the object files. For this example paste it in the edit action of the places_controller.rb file
@files = PeteFile.get_object_files(@place)
  1. Copy paste this code for each file field you need, you can add as many as you want by changing the section variable. For this example paste it into the /places/_form.html.erb file:

<%= render partial: 'shared/files_by_pete', locals: {model: @place, files: @files, section: 'legal_files' ,label: 'Upload legal files'}  %>

<%= render partial: 'shared/files_by_pete', locals: {model: @place, files: @files, section: 'extra_files' ,label: 'Upload extra files'}  %>

  1. Copy and paste this code at the end of the form where you have added the file fields. The size limit is in MB. For this example paste it in the file /places/_form.html.erb:
<%= render 'shared/files_by_pete_js', model: @place, size_limit: 50%>

Video Tutorial

Watch this video to see how it works

IMAGE ALT TEXT HERE

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/peterconsuegra/multiple_files_by_pete. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

Code of Conduct

Everyone interacting in the MultipleFilesByPete project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

FAQs

Package last updated on 04 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc