Permalink
Browse files

Iteration 4

  • Loading branch information...
1 parent ff4ce48 commit 6d164a9012524b12ddf9df87228bbc8c113f3203 @steveklabnik steveklabnik committed Apr 15, 2012
View
27 Gemfile
@@ -1,38 +1,17 @@
source 'https://rubygems.org'
gem 'rails', '3.2.2'
-
-# Bundle edge Rails instead:
-# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
gem 'sqlite3'
+gem 'jquery-rails'
+gem 'paperclip'
+gem 'haml'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
- # See https://github.com/sstephenson/execjs#readme for more supported runtimes
- # gem 'therubyracer'
-
gem 'uglifier', '>= 1.0.3'
end
-
-gem 'jquery-rails'
-
-# To use ActiveModel has_secure_password
-# gem 'bcrypt-ruby', '~> 3.0.0'
-
-# To use Jbuilder templates for JSON
-# gem 'jbuilder'
-
-# Use unicorn as the app server
-# gem 'unicorn'
-
-# Deploy with Capistrano
-# gem 'capistrano'
-
-# To use debugger
-# gem 'ruby-debug19', :require => 'ruby-debug'
View
@@ -30,6 +30,7 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.0)
+ cocaine (0.2.1)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -40,6 +41,7 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
+ haml (3.1.4)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.3)
@@ -53,6 +55,12 @@ GEM
treetop (~> 1.4.8)
mime-types (1.18)
multi_json (1.2.0)
+ paperclip (3.0.2)
+ activemodel (>= 3.0.0)
+ activerecord (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ cocaine (>= 0.0.2)
+ mime-types
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
@@ -104,7 +112,9 @@ PLATFORMS
DEPENDENCIES
coffee-rails (~> 3.2.1)
+ haml
jquery-rails
+ paperclip
rails (= 3.2.2)
sass-rails (~> 3.2.3)
sqlite3
@@ -0,0 +1,29 @@
+$primary_color: #AAA
+
+body
+ :background-color $primary_color
+ :font
+ :family Verdana, Helvetica, Arial
+ :size 14px
+
+a
+ :color #0000FF
+ img
+ :border none
+
+.clear
+ :clear both
+ :height 0
+ :overflow hidden
+
+#container
+ :width 75%
+ :margin 0 auto
+ :background #fff
+ :padding 20px 40px
+ :border solid 1px black
+ :margin-top 20px
+
+#content
+ :clear both
+ :padding-top 20px
View
@@ -1,10 +1,12 @@
class Article < ActiveRecord::Base
- attr_accessible :title, :body, :tag_list
+ attr_accessible :title, :body, :tag_list, :image
has_many :comments
has_many :taggings
has_many :tags, :through => :taggings
+ has_attached_file :image
+
def tag_list
return self.tags.join(", ")
end
@@ -1,4 +1,4 @@
-<%= form_for(@article) do |f| %>
+<%= form_for(@article, :html => {:multipart => true}) do |f| %>
<ul>
<% @article.errors.full_messages.each do |error| %>
<li><%= error %></li>
@@ -17,6 +17,13 @@
<%= f.label :body %><br />
<%= f.text_area :body %>
</p>
+ <p>
+ <% if @article.image_file_name %>
+ <%= image_tag @article.image.url %><br/>
+ <% end %>
+ <%= f.label :image, "Attach a New Image" %><br />
+ <%= f.file_field :image %>
+ </p>
<p>
<%= f.submit %>
</p>
@@ -3,6 +3,10 @@
<p><%= @article.body %></p>
+<% if @article.image_file_name %>
+ <p><%= image_tag @article.image.url %></p>
+<% end %>
+
<h3>Comments (<%= @article.comments.count %>)</h3>
<%= render :partial => 'comment', :collection => @article.comments %>
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
- <title>Blogger</title>
- <%= stylesheet_link_tag "application", :media => "all" %>
- <%= javascript_include_tag "application" %>
- <%= csrf_meta_tags %>
-</head>
-<body>
-
-<p class="flash"><%= flash[:message] %></p>
-
-<%= yield %>
-
-</body>
-</html>
@@ -0,0 +1,12 @@
+!!!
+%html
+ %head
+ %title Blogger
+ = stylesheet_link_tag "application", :media => "all"
+ = javascript_include_tag "application"
+ = csrf_meta_tags
+ %body
+ %p.flash
+ = flash[:message]
+ = yield
+
@@ -0,0 +1,8 @@
+class AddPaperclipFieldsToArticle < ActiveRecord::Migration
+ def change
+ add_column :articles, :image_file_name, :string
+ add_column :articles, :image_content_type, :string
+ add_column :articles, :image_file_size, :integer
+ add_column :articles, :image_updated_at, :datetime
+ end
+end
View
@@ -11,13 +11,17 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120413203003) do
+ActiveRecord::Schema.define(:version => 20120415163746) do
create_table "articles", :force => true do |t|
t.string "title"
t.text "body"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "image_file_name"
+ t.string "image_content_type"
+ t.integer "image_file_size"
+ t.datetime "image_updated_at"
end
create_table "comments", :force => true do |t|
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6d164a9

Please sign in to comment.