This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Mp3 < ActiveRecord::Base | |
# attach an mp3 via Paperclip, then validate it | |
has_attached_file :mp3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UploadsController < ApplicationController | |
def new | |
@mp3 = Mp3.new | |
end | |
def create | |
@mp3 = Mp3.new(params[:mp3]) | |
if @mp3.save | |
redirect_to upload_path(@mp3) | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.resources :uploads |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% form_for @mp3, :url => uploads_path, :html => { :multipart => true, :method => :post } do |f| %> | |
<%= error_messages_for :mp3 %> | |
<p> | |
<%= f.file_field :mp3 %> | |
</p> | |
<p> | |
<%= f.submit "Upload" %> | |
</p> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Upload < ActiveRecord::Base | |
has_attached_file :uploaded_file | |
validates_presence_of :uploaded_file | |
end | |
def self.list_all_files | |
find(:all, :order => "created_at DESC") | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.list_all_files | |
find(:all, :order => "created_at DESC") | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ListController < ApplicationController | |
def index | |
@upload = Upload.list_all_torrents | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Credit to: http://simonwillison.net/2006/Jan/20/escape/ | |
RegExp.escape = function(text) { | |
if (!arguments.callee.sRE) { | |
var specials = [ | |
'/', '.', '*', '+', '?', '|', | |
'(', ')', '[', ']', '{', '}', '\\' | |
]; | |
arguments.callee.sRE = new RegExp( | |
'(\\' + specials.join('|\\') + ')', 'g' | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ImageHelpers | |
def image_path(size) | |
case size | |
when "thumbnail" | |
File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "fixtures", "adam_mint.jpg")) | |
# NOTE: I created a sub dir of "support" called "fixtures" in which to place test files. | |
else | |
raise "don't know where to find a #{size} image" | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set up the Rails environment for Cucumber | |
ENV["RAILS_ENV"] ||= "test" | |
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') | |
require 'cucumber/rails/world' | |
# turn off transactions | |
Cucumber::Rails::World.use_transactional_fixtures = false | |
# configure webrat to use selenium | |
Webrat.configure do |config| |
OlderNewer