top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Building an rails app to manage media files?

+2 votes
412 views

I am trying to develop an app to manage media files I have a folder with pictures, audio and video files.

I am using Dir.glob to list the directory in my controller and in my views I am using match with regular expressions to test if the file ends in mp3 jpg mp4 3gp wav etc ... the code I wrote seems to almost work The variable @file is passed on from the controller and here is my view.

Is this a sensible way of trying to do this?

<% if @file.match("mp4") %>
 <video width="320" height="240" controls>
  <source src= <%= @file %> type="video/mp4">
 </video> 
<% elsif @file.match("mp3") %>
 <audio controls preload="auto">
  <source src = <%= @file %> >
 </audio>
<% elsif @file.match("jpg") %>
 <img src= "<%= @file %>">
<% end %>
posted Apr 17, 2016 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Do you have a File model? If so then provide either instance or class methods to do the file type testing rather than having code for them in the view. If you don't have a File model then create one (not ActiveRecord based) to manage the logic.

Similar Questions
0 votes

Our application has a bunch of help content(user guides) that is scattered and messy. Some is in PDFs, some is written directly in views, some is in table columns, etc.

I'm trying to find a good way to organize and manage it all from within the app, and wanted to ask the community what solutions are already out there.

My goal would be to accomplish the following:
* An easy way for editors to CRUD help content for each page of the app by browsing to that page and using and 'edit help' button.
* An easy way to organize all these pages into a cohesive and comprehensive help document for the entire site. So ideally the help content for each page would fit into a structure of chapters and sub-chapters, and the entire document could be printed as a guide.
* A way to manage tooltips (javascript popups) within this larger help context. So the help editor would also provide for some id reference that i can then pull for tooltip content for a certain widget.

0 votes

I am using Eclipse for my Ruby project. Is there a setting I can set to stop eclipse from building all the time? A typical build for my small project takes like 4 hours. so I cant even work when it kicks off a build.

+2 votes

I have found a html template where I some pages need specific css files and of course there are some common css files.

How can I best deal with it ?

+1 vote

I was working on a test app and everything was going great. However now when I run "rails server" and none of the changes to the controller files are reflected.

If I make changes to HTML files, those are reflected. And yes, I'm sure am in the right directory editing the correct files.

I can get rid of actions in the controller files and it still works fine. Do I have to do something after I change the ruby files? I thought I could just save them then run 'rails server'... It had seemed to be working doing just that previously.

0 votes

What is the best method to manage image uploads in Rails? Is there a tool that allows auto-resizing upon image upload based on predefined dimensions? Moreover, is there any tool available that makes it possible to render / regenerate the same originally uploaded image using alternative view based styles, e.g. thumbs, 320x200 or 640x480 etc..?

...