Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Pull gemset changes, resolve merging conflict.

  • Loading branch information...
commit 882964d4266b7532e3daf2fbccb183015842eb03 2 parents c5583e1 + 01cfc83
@denispeplin authored
View
3  .gitignore
@@ -21,3 +21,6 @@ doc
/nbproject
coverage
+.elasticbeanstalk/
+
+public/system
View
6 Gemfile
@@ -5,7 +5,7 @@ gem 'rails'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-gem 'sqlite3'
+#gem 'mysql2'
gem 'simple_form'
@@ -15,6 +15,7 @@ gem 'pjax_rails'
gem 'therubyracer'
gem 'less-rails'
+gem "paperclip", "~> 3.0"
# Gems used only for assets and not required
# in production environments by default.
@@ -36,6 +37,7 @@ group :development, :test do
gem 'capybara'
gem 'simplecov'
gem 'factory_girl_rails'
+ gem 'sqlite3'
end
# To use ActiveModel has_secure_password
@@ -51,4 +53,4 @@ end
# gem 'capistrano'
# To use debugger
-# gem 'ruby-debug19', :require => 'ruby-debug'
+gem 'debugger'
View
20 Gemfile.lock
@@ -36,6 +36,10 @@ GEM
rack (>= 1.0.0)
rack-test (>= 0.5.4)
xpath (~> 2.0)
+ climate_control (0.0.3)
+ activesupport (>= 3.0)
+ cocaine (0.5.1)
+ climate_control (>= 0.0.3, < 1.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -43,7 +47,15 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.6.2)
+ columnize (0.3.6)
commonjs (0.2.6)
+ debugger (1.4.0)
+ columnize (>= 0.3.1)
+ debugger-linecache (~> 1.1.1)
+ debugger-ruby_core_source (~> 1.2.0)
+ debugger-linecache (1.1.2)
+ debugger-ruby_core_source (>= 1.1.1)
+ debugger-ruby_core_source (1.2.0)
diff-lcs (1.2.3)
erubis (2.7.0)
execjs (1.4.0)
@@ -73,6 +85,12 @@ GEM
mime-types (1.22)
multi_json (1.7.2)
nokogiri (1.5.9)
+ paperclip (3.4.1)
+ activemodel (>= 3.0.0)
+ activerecord (>= 3.0.0)
+ activesupport (>= 3.0.0)
+ cocaine (~> 0.5.0)
+ mime-types
pjax_rails (0.3.4)
jquery-rails
polyglot (0.3.3)
@@ -157,9 +175,11 @@ PLATFORMS
DEPENDENCIES
capybara
coffee-rails
+ debugger
factory_girl_rails
jquery-rails
less-rails
+ paperclip (~> 3.0)
pjax_rails
rails
rspec-rails
View
4 app/models/product.rb
@@ -7,4 +7,8 @@ class Product < ActiveRecord::Base
validates_presence_of :name, :price, :brand_id, :category_id
validates :price, numericality: {greater_than_or_equal_to: 0.01}
+
+ attr_accessible :photo, :photo2, :name, :price, :category_id, :brand_id
+ has_attached_file :photo
+ has_attached_file :photo2
end
View
2  app/views/products/_form.html.erb
@@ -6,6 +6,8 @@
<%= f.input :price %>
<%= f.association :category %>
<%= f.association :brand %>
+ <%= f.file_field :photo %>
+ <%= f.file_field :photo2 %>
<div class="form-actions">
<%= f.button :submit %>
<%= link_to 'Cancel', products_path, :class => 'btn' %>
View
3  app/views/products/show.html.erb
@@ -7,6 +7,9 @@
<%= p.attribute :brand_name %>
<% end %>
+<%= image_tag @product.photo.url %>
+<%= image_tag @product.photo2.url %>
+
<div class="form-actions">
<%= link_to 'Back', products_path, :class => 'btn' %>
<%= link_to 'Edit', edit_product_path(@product), :class => 'btn' %>
View
11 db/migrate/20121219172905_add_attachment_photo_to_products.rb
@@ -0,0 +1,11 @@
+class AddAttachmentPhotoToProducts < ActiveRecord::Migration
+ def self.up
+ change_table :products do |t|
+ t.has_attached_file :photo
+ end
+ end
+
+ def self.down
+ drop_attached_file :products, :photo
+ end
+end
View
11 db/migrate/20121219174959_add_attachment_photo2_to_products.rb
@@ -0,0 +1,11 @@
+class AddAttachmentPhoto2ToProducts < ActiveRecord::Migration
+ def self.up
+ change_table :products do |t|
+ t.has_attached_file :photo2
+ end
+ end
+
+ def self.down
+ drop_attached_file :products, :photo2
+ end
+end
View
14 db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120224194905) do
+ActiveRecord::Schema.define(:version => 20121219174959) do
create_table "brands", :force => true do |t|
t.string "name"
@@ -35,8 +35,16 @@
t.decimal "price"
t.integer "category_id"
t.integer "brand_id"
- 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 "photo_file_name"
+ t.string "photo_content_type"
+ t.integer "photo_file_size"
+ t.datetime "photo_updated_at"
+ t.string "photo2_file_name"
+ t.string "photo2_content_type"
+ t.integer "photo2_file_size"
+ t.datetime "photo2_updated_at"
end
add_index "products", ["brand_id"], :name => "index_products_on_brand_id"
View
13 spec/controllers/products_controller_spec.rb
@@ -85,6 +85,19 @@ def valid_session
end
end
+ describe "with photo" do
+ before :each do
+ @filename = 'image.jpg'
+ @file = fixture_file_upload("/#{@filename}", 'image/jpg')
+ @attributes = valid_attributes.merge({:photo => @file})
+ end
+
+ it "creates a new Product" do
+ post :create, {product: @attributes}, valid_session
+ Product.last.photo_file_name.should == @filename
+ end
+ end
+
describe "with invalid params" do
it "assigns a newly created but unsaved product as @product" do
# Trigger the behavior that occurs when invalid params are submitted
View
BIN  spec/fixtures/image.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.