Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

app

commit 606f4b3064fb1e370d2a0eae26cba7dd11231294 1 parent 456b02d
@trevorturk authored
View
4 .gitignore
@@ -0,0 +1,4 @@
+.bundle
+db/*.sqlite3
+log/*.log
+tmp/**/*
View
6 Gemfile
@@ -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
92 Gemfile.lock
@@ -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
4 Rakefile
@@ -0,0 +1,4 @@
+require File.expand_path('../config/application', __FILE__)
+require 'rake'
+
+CarrierwaveHeroku::Application.load_tasks
View
2  app/controllers/application_controller.rb
@@ -0,0 +1,2 @@
+class ApplicationController < ActionController::Base
+end
View
20 app/controllers/users_controller.rb
@@ -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
View
2  app/helpers/application_helper.rb
@@ -0,0 +1,2 @@
+module ApplicationHelper
+end
View
4 app/models/user.rb
@@ -0,0 +1,4 @@
+class User < ActiveRecord::Base
+ validates_presence_of :name
+ mount_uploader :avatar, AvatarUploader
+end
View
15 app/uploaders/avatar_uploader.rb
@@ -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
View
9 app/views/layouts/application.html.erb
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>CarrierwaveHeroku</title>
+ </head>
+ <body>
+ <%= yield %>
+ </body>
+</html>
View
18 app/views/users/index.html.erb
@@ -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>
View
26 app/views/users/new.html.erb
@@ -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
3  config.ru
@@ -0,0 +1,3 @@
+require ::File.expand_path('../config/environment', __FILE__)
+use Rack::Static, :urls => ['/carrierwave'], :root => 'tmp'
+run CarrierwaveHeroku::Application
View
8 config/application.rb
@@ -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
13 config/boot.rb
@@ -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
5 config/database.yml
@@ -0,0 +1,5 @@
+development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 5
+ timeout: 5000
View
2  config/environment.rb
@@ -0,0 +1,2 @@
+require File.expand_path('../application', __FILE__)
+CarrierwaveHeroku::Application.initialize!
View
8 config/initializers/carrierwave.rb
@@ -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
View
1  config/initializers/secret_token.rb
@@ -0,0 +1 @@
+CarrierwaveHeroku::Application.config.secret_token = '62eb340b1749f18f1d7f4733753ff87'
View
4 config/routes.rb
@@ -0,0 +1,4 @@
+CarrierwaveHeroku::Application.routes.draw do
+ resources :users
+ root :to => "users#index"
+end
View
10 db/schema.rb
@@ -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
6 script/rails
@@ -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'
Please sign in to comment.
Something went wrong with that request. Please try again.