Permalink
Browse files

app

  • Loading branch information...
trevorturk committed Feb 17, 2011
1 parent 456b02d commit 606f4b3064fb1e370d2a0eae26cba7dd11231294
View
@@ -0,0 +1,4 @@
.bundle
db/*.sqlite3
log/*.log
tmp/**/*
View
@@ -0,0 +1,6 @@
source 'http://rubygems.org'
gem 'rails', '3.0.4'
gem 'sqlite3', '1.3.3', :require => 'sqlite3'
gem 'carrierwave', '0.5.1'
gem 'fog', '0.5.3'
View
@@ -0,0 +1,92 @@
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.4)
actionpack (= 3.0.4)
mail (~> 2.2.15)
actionpack (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.4)
rack (~> 1.2.1)
rack-mount (~> 0.6.13)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.4)
activesupport (= 3.0.4)
builder (~> 2.1.2)
i18n (~> 0.4)
activerecord (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.4)
activemodel (= 3.0.4)
activesupport (= 3.0.4)
activesupport (3.0.4)
arel (2.0.8)
builder (2.1.2)
carrierwave (0.5.1)
activesupport (~> 3.0)
erubis (2.6.6)
abstract (>= 1.0.0)
excon (0.5.2)
fog (0.5.3)
builder
excon (>= 0.5.2)
formatador (>= 0.0.16)
json
mime-types
net-ssh (>= 2.0.23)
nokogiri (>= 1.4.4)
ruby-hmac
formatador (0.0.16)
i18n (0.5.0)
json (1.5.1)
mail (2.2.15)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
net-ssh (2.1.0)
nokogiri (1.4.4)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.4)
actionmailer (= 3.0.4)
actionpack (= 3.0.4)
activerecord (= 3.0.4)
activeresource (= 3.0.4)
activesupport (= 3.0.4)
bundler (~> 1.0)
railties (= 3.0.4)
railties (3.0.4)
actionpack (= 3.0.4)
activesupport (= 3.0.4)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.8.7)
ruby-hmac (0.4.0)
sqlite3 (1.3.3)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
tzinfo (0.3.24)
PLATFORMS
ruby
DEPENDENCIES
carrierwave (= 0.5.1)
fog (= 0.5.3)
rails (= 3.0.4)
sqlite3 (= 1.3.3)
View
@@ -0,0 +1,4 @@
require File.expand_path('../config/application', __FILE__)
require 'rake'
CarrierwaveHeroku::Application.load_tasks
@@ -0,0 +1,2 @@
class ApplicationController < ActionController::Base
end
@@ -0,0 +1,20 @@
class UsersController < ApplicationController
def index
@users = User.all
end
def new
@user = User.new
end
def create
@user = User.new(params[:user])
if @user.save
redirect_to root_path
else
render :action => "new"
end
end
end
@@ -0,0 +1,2 @@
module ApplicationHelper
end
View
@@ -0,0 +1,4 @@
class User < ActiveRecord::Base
validates_presence_of :name
mount_uploader :avatar, AvatarUploader
end
@@ -0,0 +1,15 @@
# encoding: utf-8
class AvatarUploader < CarrierWave::Uploader::Base
storage :s3
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
def extension_white_list
%w(jpg jpeg gif png)
end
end
@@ -0,0 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<title>CarrierwaveHeroku</title>
</head>
<body>
<%= yield %>
</body>
</html>
@@ -0,0 +1,18 @@
<h1>Users</h1>
<table>
<tr>
<th>id</th>
<th>Name</th>
<th>Avatar</th>
</tr>
<% @users.each do |user| %>
<tr>
<td><%= user.id %></td>
<td><%= user.name %></td>
<td><%= image_tag(user.avatar_url) if user.avatar_url %></td>
</tr>
<% end %>
</table>
<p><%= link_to 'New User', new_user_path %></p>
@@ -0,0 +1,26 @@
<h1>New user</h1>
<%= form_for @user, :html => {:multipart => true} do |f| %>
<p><%= @user.errors.full_messages.to_s %></p>
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.label :avatar %><br />
<%= f.file_field :avatar %>
</p>
<% if @user.avatar? %>
<%= image_tag(@user.avatar_url) %><br />
<%= f.hidden_field :avatar_cache %>
<% end %>
<p><%= f.submit %></p>
<% end %>
<p><%= link_to 'Back', users_path %></p>
View
@@ -0,0 +1,3 @@
require ::File.expand_path('../config/environment', __FILE__)
use Rack::Static, :urls => ['/carrierwave'], :root => 'tmp'
run CarrierwaveHeroku::Application
View
@@ -0,0 +1,8 @@
require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(:default, Rails.env) if defined?(Bundler)
module CarrierwaveHeroku
class Application < Rails::Application
end
end
View
@@ -0,0 +1,13 @@
require 'rubygems'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
begin
ENV['BUNDLE_GEMFILE'] = gemfile
require 'bundler'
Bundler.setup
rescue Bundler::GemNotFound => e
STDERR.puts e.message
STDERR.puts "Try running `bundle install`."
exit!
end if File.exist?(gemfile)
View
@@ -0,0 +1,5 @@
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
View
@@ -0,0 +1,2 @@
require File.expand_path('../application', __FILE__)
CarrierwaveHeroku::Application.initialize!
@@ -0,0 +1,8 @@
CarrierWave.configure do |config|
config.root = Rails.root.join('tmp')
config.cache_dir = 'carrierwave'
config.s3_access_key_id = ENV['s3_access_key_id']
config.s3_secret_access_key = ENV['s3_secret_access_key']
config.s3_bucket = ENV['s3_bucket']
end
@@ -0,0 +1 @@
CarrierwaveHeroku::Application.config.secret_token = '62eb340b1749f18f1d7f4733753ff87'
View
@@ -0,0 +1,4 @@
CarrierwaveHeroku::Application.routes.draw do
resources :users
root :to => "users#index"
end
View
@@ -0,0 +1,10 @@
ActiveRecord::Schema.define(:version => 20110217152339) do
create_table "users", :force => true do |t|
t.string "name"
t.string "avatar"
t.datetime "created_at"
t.datetime "updated_at"
end
end
View
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
require 'rails/commands'

0 comments on commit 606f4b3

Please sign in to comment.