Topic: Looking for help/info on Databases

I am building a project and need to implement a database that stores images / videos / text / audio files but don't want them tied to a certain user.

I would like the a form that will allow for an upload of either of these files.

Query the database and display the results on the page.

I have done with this MySQL and PHP in the past.  I had planned on creating a radio button to determine what type of file they wanted to upload and use javascript to hide/show the box used to upload that certain file.  So if text file was click it would show the box to upload a text file and keep the boxes for video/audio/image files hidden.

All the tutorials I have come across tie these files to a certain user and I don't have users set up yet for the site.  I also do not know if I will allow people to register to upload files.  I would like to start slow and then work my way up to users and their microposts / files.

Re: Looking for help/info on Databases

Check out Paperclip:

In your Gemfile:

gem "paperclip"

Create an Upload model:

$ rails g model Upload file:attachment

Add to app/models/upload.rb

class Upload < ActiveRecord::Base
  has_attached_file :file

In your view, e.g. app/views/uploads/new.html.erb:

<%= form_for @upload do |f| %>
  <%= f.file_field :file %>
  <%= f.submit %>
<% end %>

Heavily simplified,

Last edited by lbunk (2013-05-02 19:45:53)