Permalink
Browse files

Pull gemset changes, resolve merging conflict.

  • Loading branch information...
2 parents c5583e1 + 01cfc83 commit 882964d4266b7532e3daf2fbccb183015842eb03 @denispeplin committed Apr 17, 2013
View
@@ -21,3 +21,6 @@ doc
/nbproject
coverage
+.elasticbeanstalk/
+
+public/system
View
@@ -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
@@ -36,14 +36,26 @@ 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)
coffee-script (2.2.0)
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
@@ -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
@@ -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' %>
@@ -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' %>
@@ -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
@@ -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
@@ -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"
@@ -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
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 882964d

Please sign in to comment.