Commit 9b8cf531 by Tran Hoang Viet

Merge remote-tracking branch 'origin/release-1.0.0'

parents b932f98f 3b19a49d
...@@ -11,3 +11,5 @@ ...@@ -11,3 +11,5 @@
/log/* /log/*
!/log/.keep !/log/.keep
/tmp /tmp
/public/uploads/
/config/database.yml
--color
--require spec_helper
AllCops:
Exclude:
- 'vendor/**/*'
- 'spec/**/*'
RunRailsCops: true
DisplayCopNames: true
Style/AccessModifierIndentation:
Enabled: false
Style/AccessorMethodName:
Enabled: false
Style/Alias:
Enabled: false
Style/AlignArray:
Enabled: false
Style/AlignHash:
Enabled: false
Style/AlignParameters:
Enabled: false
Style/AndOr:
Enabled: true
Style/ArrayJoin:
Enabled: false
Style/AsciiComments:
Enabled: false
Style/AsciiIdentifiers:
Enabled: false
Style/Attr:
Enabled: false
Style/BeginBlock:
Enabled: false
Style/BarePercentLiterals:
Enabled: false
Style/BlockComments:
Enabled: false
Style/BlockEndNewline:
Enabled: false
Style/BlockDelimiters:
Enabled: false
Style/Blocks:
Enabled: false
Style/BracesAroundHashParameters:
Enabled: false
Style/CaseEquality:
Enabled: true
Style/CaseIndentation:
Enabled: false
Style/CharacterLiteral:
Enabled: false
Style/ClassAndModuleCamelCase:
Enabled: false
Style/ClassAndModuleChildren:
Enabled: false
Style/ClassCheck:
Enabled: false
Style/ClassMethods:
Enabled: false
Style/ClassVars:
Enabled: false
Style/ColonMethodCall:
Enabled: false
Style/CommentAnnotation:
Enabled: false
Style/CommentIndentation:
Enabled: false
Style/ConstantName:
Enabled: false
Style/DefWithParentheses:
Enabled: false
Style/DeprecatedHashMethods:
Enabled: false
Style/Documentation:
Enabled: false
Style/DotPosition:
Enabled: false
Style/DoubleNegation:
Enabled: false
Style/EachWithObject:
Enabled: false
Style/ElseAlignment:
Enabled: false
Style/EmptyElse:
Enabled: false
Style/EmptyLineBetweenDefs:
Enabled: false
Style/EmptyLines:
Enabled: false
Style/EmptyLinesAroundAccessModifier:
Enabled: false
Style/EmptyLinesAroundBlockBody:
Enabled: false
Style/EmptyLinesAroundClassBody:
Enabled: false
Style/EmptyLinesAroundModuleBody:
Enabled: false
Style/EmptyLinesAroundMethodBody:
Enabled: false
Style/EmptyLiteral:
Enabled: false
Style/EndBlock:
Enabled: false
Style/EndOfLine:
Enabled: false
Style/EvenOdd:
Enabled: false
Style/FileName:
Enabled: false
Style/FirstParameterIndentation:
Enabled: false
Style/FlipFlop:
Enabled: false
Style/For:
Enabled: false
Style/FormatString:
Enabled: false
Style/GlobalVars:
Enabled: true
Style/GuardClause:
Enabled: false
Style/HashSyntax:
Enabled: false
Style/IfUnlessModifier:
Enabled: false
Style/IfWithSemicolon:
Enabled: false
Style/IndentationConsistency:
Enabled: false
Style/IndentationWidth:
Enabled: false
Style/IndentArray:
Enabled: false
Style/IndentHash:
Enabled: false
Style/InfiniteLoop:
Enabled: false
Style/Lambda:
Enabled: false
Style/LambdaCall:
Enabled: false
Style/LeadingCommentSpace:
Enabled: false
Style/LineEndConcatenation:
Enabled: false
Style/MethodCallParentheses:
Enabled: false
Style/MethodDefParentheses:
Enabled: false
Style/MethodName:
Enabled: false
Style/ModuleFunction:
Enabled: false
Style/MultilineBlockChain:
Enabled: false
Style/MultilineBlockLayout:
Enabled: false
Style/MultilineIfThen:
Enabled: false
Style/MultilineOperationIndentation:
Enabled: false
Style/MultilineTernaryOperator:
Enabled: false
Style/NegatedIf:
Enabled: false
Style/NegatedWhile:
Enabled: false
Style/NestedTernaryOperator:
Enabled: false
Style/Next:
Enabled: false
Style/NilComparison:
Enabled: false
Style/NonNilCheck:
Enabled: false
Style/Not:
Enabled: false
Style/NumericLiterals:
Enabled: false
Style/OneLineConditional:
Enabled: false
Style/OpMethod:
Enabled: false
Style/ParenthesesAroundCondition:
Enabled: false
Style/PercentLiteralDelimiters:
Enabled: false
Style/PercentQLiterals:
Enabled: false
Style/PerlBackrefs:
Enabled: false
Style/PredicateName:
Enabled: false
Style/Proc:
Enabled: false
Style/RaiseArgs:
Enabled: false
Style/RedundantBegin:
Enabled: false
Style/RedundantException:
Enabled: false
Style/RedundantReturn:
Enabled: false
Style/RedundantSelf:
Enabled: false
Style/RegexpLiteral:
Enabled: false
Style/RescueModifier:
Enabled: false
Style/SelfAssignment:
Enabled: false
Style/Semicolon:
Enabled: false
Style/SignalException:
Enabled: false
Style/SingleLineBlockParams:
Enabled: false
Style/SingleLineMethods:
Enabled: false
Style/SingleSpaceBeforeFirstArg:
Enabled: false
Style/SpaceAfterColon:
Enabled: false
Style/SpaceAfterComma:
Enabled: false
Style/SpaceAfterControlKeyword:
Enabled: false
Style/SpaceAfterMethodName:
Enabled: false
Style/SpaceAfterNot:
Enabled: false
Style/SpaceAfterSemicolon:
Enabled: false
Style/SpaceBeforeBlockBraces:
Enabled: false
Style/SpaceBeforeComma:
Enabled: false
Style/SpaceBeforeComment:
Enabled: false
Style/SpaceBeforeSemicolon:
Enabled: false
Style/SpaceInsideBlockBraces:
Enabled: false
Style/SpaceAroundBlockParameters:
Enabled: false
Style/SpaceAroundEqualsInParameterDefault:
Enabled: false
Style/SpaceAroundOperators:
Enabled: false
Style/SpaceBeforeModifierKeyword:
Enabled: false
Style/SpaceInsideBrackets:
Enabled: false
Style/SpaceInsideHashLiteralBraces:
Enabled: false
Style/SpaceInsideParens:
Enabled: false
Style/SpaceInsideRangeLiteral:
Enabled: false
Style/SpecialGlobalVars:
Enabled: false
Style/StringLiterals:
Enabled: false
Style/StringLiteralsInInterpolation:
Enabled: false
Style/StructInheritance:
Enabled: false
Style/SymbolProc:
Enabled: false
Style/Tab:
Enabled: false
Style/TrailingBlankLines:
Enabled: false
Style/TrailingComma:
Enabled: false
Style/TrailingWhitespace:
Enabled: false
Style/TrivialAccessors:
Enabled: false
Style/UnlessElse:
Enabled: false
Style/UnneededCapitalW:
Enabled: false
Style/UnneededPercentQ:
Enabled: false
Style/UnneededPercentX:
Enabled: false
Style/VariableInterpolation:
Enabled: false
Style/VariableName:
Enabled: false
Style/WhenThen:
Enabled: false
Style/WhileUntilDo:
Enabled: false
Style/WhileUntilModifier:
Enabled: false
Style/WordArray:
Enabled: false
Lint/DeprecatedClassMethods:
Enabled: false
Lint/StringConversionInInterpolation:
Enabled: false
Metrics/AbcSize:
Enabled: false
Metrics/BlockNesting:
Enabled: false
Metrics/ClassLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/LineLength:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/ParameterLists:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false
\ No newline at end of file
require 'capistrano/setup'
require 'capistrano/deploy'
require 'capistrano/rvm'
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
require 'capistrano3/unicorn'
# Load custom tasks from `lib/capistrano/tasks' if you have any defined
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
\ No newline at end of file
source 'http://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3'
# Use mysql as the database for Active Record
gem 'mysql2'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'pry-rails', '~> 0.3.4'
gem 'letter_opener', '~> 1.4.1'
gem 'rspec-rails', '~> 3.3.2'
gem 'factory_girl_rails', '~> 4.5.0'
gem 'database_cleaner', '~> 1.4.1'
gem 'faker', '~> 1.4.3'
gem 'shoulda-matchers', '~> 2.8.0'
end
# template
gem "haml-rails", "~> 0.9"
gem 'twitter-bootstrap-rails', '~> 3.2.0'
gem 'font-awesome-sass'
gem 'quiet_assets'
# Amazon
gem 'vacuum', '~> 1.3.0'
gem 'figaro', '~> 1.1.1'
gem 'settingslogic', '~> 2.0.9'
gem 'draper', '~> 2.1.0'
gem 'devise', '~> 3.5.1'
gem 'carrierwave', '~> 0.10.0'
gem 'mini_magick', '~> 3.8.1'
# Background job
gem 'sidekiq', '~> 3.4.1'
# pagination
gem 'kaminari', '~> 0.16.3'
gem 'rsolr', '~> 1.0.12'
gem 'seed_migration', '~> 1.0.5'
gem 'rails_12factor', '~> 0.0.3'
group :development do
gem 'capistrano-rails'
gem 'capistrano-rvm'
gem 'capistrano3-unicorn'
gem 'capistrano-sidekiq', '~> 0.5.2'
end
gem 'rubocop', '~> 0.32.1'
\ No newline at end of file
GEM
remote: http://rubygems.org/
specs:
actionmailer (4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 1.0, >= 1.0.5)
actionpack (4.2.3)
actionview (= 4.2.3)
activesupport (= 4.2.3)
rack (~> 1.6)
rack-test (~> 0.6.2)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
actionview (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
erubis (~> 2.7.0)
rails-dom-testing (~> 1.0, >= 1.0.5)
rails-html-sanitizer (~> 1.0, >= 1.0.2)
activejob (4.2.3)
activesupport (= 4.2.3)
globalid (>= 0.3.0)
activemodel (4.2.3)
activesupport (= 4.2.3)
builder (~> 3.1)
activerecord (4.2.3)
activemodel (= 4.2.3)
activesupport (= 4.2.3)
arel (~> 6.0)
activesupport (4.2.3)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
addressable (2.3.8)
arel (6.0.0)
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
bcrypt (3.1.10)
binding_of_caller (0.7.2)
debug_inspector (>= 0.0.1)
builder (3.2.2)
byebug (5.0.0)
columnize (= 0.9.0)
capistrano (3.4.0)
i18n
rake (>= 10.0.0)
sshkit (~> 1.3)
capistrano-bundler (1.1.4)
capistrano (~> 3.1)
sshkit (~> 1.2)
capistrano-rails (1.1.3)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
capistrano-rvm (0.1.2)
capistrano (~> 3.0)
sshkit (~> 1.2)
capistrano-sidekiq (0.5.3)
capistrano
sidekiq
capistrano3-unicorn (0.2.1)
capistrano (~> 3.1, >= 3.1.0)
carrierwave (0.10.0)
activemodel (>= 3.2.0)
activesupport (>= 3.2.0)
json (>= 1.7)
mime-types (>= 1.16)
celluloid (0.16.0)
timers (~> 4.0.0)
coderay (1.1.0)
coffee-rails (4.1.0)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.4.1)
coffee-script-source
execjs
coffee-script-source (1.9.1.1)
colorize (0.7.7)
columnize (0.9.0)
connection_pool (2.2.0)
database_cleaner (1.4.1)
debug_inspector (0.0.2)
devise (3.5.1)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
draper (2.1.0)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
request_store (~> 1.0)
erubis (2.7.0)
excon (0.45.3)
execjs (2.5.2)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.5.0)
factory_girl (~> 4.5.0)
railties (>= 3.0.0)
faker (1.4.3)
i18n (~> 0.5)
figaro (1.1.1)
thor (~> 0.14)
font-awesome-sass (4.3.2.1)
sass (~> 3.2)
globalid (0.3.5)
activesupport (>= 4.1.0)
haml (4.0.6)
tilt
haml-rails (0.9.0)
actionpack (>= 4.0.1)
activesupport (>= 4.0.1)
haml (>= 4.0.6, < 5.0)
html2haml (>= 1.0.1)
railties (>= 4.0.1)
hitimes (1.2.2)
html2haml (2.0.0)
erubis (~> 2.7.0)
haml (~> 4.0.0)
nokogiri (~> 1.6.0)
ruby_parser (~> 3.5)
i18n (0.7.0)
jbuilder (2.3.1)
activesupport (>= 3.0.0, < 5)
multi_json (~> 1.2)
jeff (1.3.0)
excon (>= 0.22.1)
jquery-rails (4.0.4)
rails-dom-testing (~> 1.0)
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (1.8.3)
kaminari (0.16.3)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.9.3)
launchy (2.4.3)
addressable (~> 2.3)
letter_opener (1.4.1)
launchy (~> 2.2)
loofah (2.0.2)
nokogiri (>= 1.5.9)
mail (2.6.3)
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.6.1)
mini_magick (3.8.1)
subexec (~> 0.2.1)
mini_portile (0.6.2)
minitest (5.7.0)
multi_json (1.11.2)
multi_xml (0.5.5)
mysql2 (0.3.18)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (2.9.2)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
orm_adapter (0.5.0)
parser (2.2.2.6)
ast (>= 1.1, < 3.0)
powerpack (0.1.1)
pry (0.10.1)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
pry-rails (0.3.4)
pry (>= 0.9.10)
quiet_assets (1.1.0)
railties (>= 3.1, < 5.0)
rack (1.6.4)
rack-test (0.6.3)
rack (>= 1.0)
rails (4.2.3)
actionmailer (= 4.2.3)
actionpack (= 4.2.3)
actionview (= 4.2.3)
activejob (= 4.2.3)
activemodel (= 4.2.3)
activerecord (= 4.2.3)
activesupport (= 4.2.3)
bundler (>= 1.3.0, < 2.0)
railties (= 4.2.3)
sprockets-rails
rails-deprecated_sanitizer (1.0.3)
activesupport (>= 4.2.0.alpha)
rails-dom-testing (1.0.6)
activesupport (>= 4.2.0.beta, < 5.0)
nokogiri (~> 1.6.0)
rails-deprecated_sanitizer (>= 1.0.1)
rails-html-sanitizer (1.0.2)
loofah (~> 2.0)
rails_12factor (0.0.3)
rails_serve_static_assets
rails_stdout_logging
rails_serve_static_assets (0.0.4)
rails_stdout_logging (0.0.3)
railties (4.2.3)
actionpack (= 4.2.3)
activesupport (= 4.2.3)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (2.0.0)
raindrops (0.14.0)
rake (10.4.2)
rdoc (4.2.0)
json (~> 1.4)
redis (3.2.1)
redis-namespace (1.5.2)
redis (~> 3.0, >= 3.0.4)
request_store (1.1.0)
responders (2.1.0)
railties (>= 4.2.0, < 5)
rsolr (1.0.12)
builder (>= 2.1.2)
rspec-core (3.3.1)
rspec-support (~> 3.3.0)
rspec-expectations (3.3.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-mocks (3.3.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.3.0)
rspec-rails (3.3.2)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.3.0)
rspec-expectations (~> 3.3.0)
rspec-mocks (~> 3.3.0)
rspec-support (~> 3.3.0)
rspec-support (3.3.0)
rubocop (0.32.1)
astrolabe (~> 1.3)
parser (>= 2.2.2.5, < 3.0)
powerpack (~> 0.1)
rainbow (>= 1.99.1, < 3.0)
ruby-progressbar (~> 1.4)
ruby-progressbar (1.7.5)
ruby_parser (3.7.0)
sexp_processor (~> 4.1)
sass (3.4.15)
sass-rails (5.0.3)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
sprockets-rails (>= 2.0, < 4.0)
tilt (~> 1.1)
sdoc (0.4.1)
json (~> 1.7, >= 1.7.7)
rdoc (~> 4.0)
seed_migration (1.0.5)
settingslogic (2.0.9)
sexp_processor (4.6.0)
shoulda-matchers (2.8.0)
activesupport (>= 3.0.0)
sidekiq (3.4.1)
celluloid (~> 0.16.0)
connection_pool (>= 2.1.1)
json
redis (>= 3.0.6)
redis-namespace (>= 1.3.1)
slop (3.6.0)
spring (1.3.6)
sprockets (3.2.0)
rack (~> 1.0)
sprockets-rails (2.3.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (>= 2.8, < 4.0)
sshkit (1.7.1)
colorize (>= 0.7.0)
net-scp (>= 1.1.2)
net-ssh (>= 2.8.0)
subexec (0.2.3)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
timers (4.0.1)
hitimes
turbolinks (2.5.3)
coffee-rails
twitter-bootstrap-rails (3.2.0)
actionpack (~> 4.1)
execjs (~> 2.2)
rails (~> 4.1)
railties (~> 4.1)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.9.0)
kgio (~> 2.6)
rack
raindrops (~> 0.7)
vacuum (1.3.0)
jeff (~> 1.0)
multi_xml (~> 0.5.0)
warden (1.2.3)
rack (>= 1.0)
web-console (2.1.3)
activemodel (>= 4.0)
binding_of_caller (>= 0.7.2)
railties (>= 4.0)
sprockets-rails (>= 2.0, < 4.0)
PLATFORMS
ruby
DEPENDENCIES
byebug
capistrano-rails
capistrano-rvm
capistrano-sidekiq (~> 0.5.2)
capistrano3-unicorn
carrierwave (~> 0.10.0)
coffee-rails (~> 4.1.0)
database_cleaner (~> 1.4.1)
devise (~> 3.5.1)
draper (~> 2.1.0)
factory_girl_rails (~> 4.5.0)
faker (~> 1.4.3)
figaro (~> 1.1.1)
font-awesome-sass
haml-rails (~> 0.9)
jbuilder (~> 2.0)
jquery-rails
kaminari (~> 0.16.3)
letter_opener (~> 1.4.1)
mini_magick (~> 3.8.1)
mysql2
pry-rails (~> 0.3.4)
quiet_assets
rails (= 4.2.3)
rails_12factor (~> 0.0.3)
rsolr (~> 1.0.12)
rspec-rails (~> 3.3.2)
rubocop (~> 0.32.1)
sass-rails (~> 5.0)
sdoc (~> 0.4.0)
seed_migration (~> 1.0.5)
settingslogic (~> 2.0.9)
shoulda-matchers (~> 2.8.0)
sidekiq (~> 3.4.1)
spring
turbolinks
twitter-bootstrap-rails (~> 3.2.0)
uglifier (>= 1.3.0)
unicorn
vacuum (~> 1.3.0)
web-console (~> 2.0)
== README
This README would normally document whatever steps are necessary to get the
application up and running.
Things you may want to cover:
* Ruby version
* System dependencies
* Configuration
* Database creation
* Database initialization
* How to run the test suite
* Services (job queues, cache servers, search engines, etc.)
* Deployment instructions
* ...
Please feel free to use a different markup language if you do not plan to run
<tt>rake doc:app</tt>.
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
Rails.application.load_tasks
// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require jquery.validate.min
//= require twitter/bootstrap
//= require product
//= require ready
//= require additional-methods
@productLib = (->
@validateForm = ->
$('#form-product form').validate
rules:
'product[title]':
required: true
maxlength: 255
'product[price]':
number: true
'product[image]':
required: true
accept: "image/*"
return @
)()
\ No newline at end of file
$(document).ready ->
window.productLib.validateForm()
\ No newline at end of file
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any styles
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
* file per style scope.
*
*= require_self
*= require bootstrap_and_overrides
*= require layout
*= require product
*= require cart
*/
/*
=require twitter-bootstrap-static/bootstrap
Use Font Awesome icons (default)
To use Glyphicons sprites instead of Font Awesome, replace with "require twitter-bootstrap-static/sprites"
*/
@import "font-awesome-sprockets";
@import "font-awesome";
\ No newline at end of file
#cart-info{
margin-bottom: 30px;
}
\ No newline at end of file
.logo img{
height: 22px;
}
input, textarea, select{
&.error{
border-color: #FF4F4F;
}
}
label.error{
color: #FF4F4F;
}
#wrapper{
margin-top: 50px;
.search-wrapper{
margin: 10px 0;
.btn{
padding: 6px 12px 7px;
}
}
#message{
.alert{
margin-top: 20px;
}
}
#content{
.products-list-detail{
.product-item{
height: 70px;
.product-image img{
width: 51px;
height: 32px;
}
.product-title{
margin: 10px 0;
}
}
}
#recommend-items{
.product-item{
height: 130px;
.product-image img{
width: 71px;
height: 38px;
}
.product-title{
margin: 10px 0;
}
}
}
}
}
.nav-sidebar > .active{
background-color: #ccc;
}
h3.title {
background-color: #000;
padding: 6px;
color: white;
}
footer{
background-color: #ccc;
padding: 15px 0 0 0;
height: 45px;
}
\ No newline at end of file
#product-detail{
.product-image img{
width: 110px;
height: 86px;
float: left;
margin: 0 20px 20px 0;
}
.product-title{
font-size: 16px;
}
}
\ No newline at end of file
class ApplicationController < ActionController::Base
rescue_from ActiveRecord::RecordNotFound, :with => :record_not_found
layout Proc.new { |controller| controller.devise_controller? ? 'devise' : 'application' }
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
protected
def add_breadcrumb(title, url = nil)
@breadcrumbs = [] if @breadcrumbs.blank?
@breadcrumbs.push({title: title, url: url})
end
def add_breadcrumb_home
add_breadcrumb('Home', root_path)
end
def record_not_found
redirect_to(root_path, alert: "Resource not found")
end
end
\ No newline at end of file
class CategoriesController < ApplicationController
before_action :set_category, only: [:show]
def show
@products = @category.products.page(params[:page])
end
private
def set_category
@category = Category.find(params[:id])
end
end
\ No newline at end of file
module OrdersManagement extend ActiveSupport::Concern
included do
def add_to_cart product
order_item = {
'id' => product.id,
'title' => product.title,
'price' => product.price,
'quantity' => 1
}
unless session['cart_info']['items'].include?(order_item)
session['cart_info']['items'].push(order_item)
session['cart_info']['total'] += 1
end
end
def clear_cart
session['cart_info'] = nil
end
def session_cart
session['cart_info'].with_indifferent_access
end
end
end
\ No newline at end of file
class HomeController < ApplicationController
before_action :add_breadcrumb_home
def index
@recommended_items = Product.recommended
@newest_items = Product.newest
end
end
\ No newline at end of file
class OrdersController < ApplicationController
include OrdersManagement
before_action :authenticate_user!
def index
@order = Order.new
end
def create
if order_service.create(order_params)
clear_cart
redirect_to(root_path, notice: 'Checkout is successful.')
else
render :index
end
end
private
def order_params
params.require(:order).permit(:total, order_items_attributes: [:product_id, :quantity])
end
def order_service
@order_service ||= OrderService.new(current_user, params)
end
end
\ No newline at end of file
class ProductsController < ApplicationController
include OrdersManagement
before_action :set_product, only: [:show, :add_cart]
before_action :set_categories, only: [:new]
before_action :add_breadcrumb_home
before_action :authenticate_user!, only: [:new, :create]
def new
@product = Product.new
add_breadcrumb('New product')
end
def create
@product = Product.new(product_params)
if @product.save
redirect_to(root_path)
else
render(:new)
end
end
def show
add_breadcrumb(@product.category.decorate.title, category_path(@product.category))
add_breadcrumb(@product.title)
end
def add_cart
add_to_cart(@product)
redirect_to(@product, notice: 'Product is added to cart.')
end
def search
query = params[:query].present? ? {title: params[:query]} : '*'
@products = Product.search(query, page: params[:page])
end
private
def set_product
@product = Product.find(params[:id])
end
def set_categories
@categories = Category.all.limit(Settings.limit_category)
end
def product_params
params.require(:product).permit(:title, :price, :category_id, :image)
end
end
\ No newline at end of file
class CategoryDecorator < Draper::Decorator
delegate_all
def title
return object.title || 'Uncategory'
end
end
\ No newline at end of file
class ProductDecorator < Draper::Decorator
delegate_all
def price
return object.price || 'Contact'
end
def image_sm_url
object.amazon? ? object.image_sm_url : object.image.small.url
end
def image_md_url
object.amazon? ? object.image_md_url : object.image.medium.url
end
def image_lg_url
object.amazon? ? object.image_lg_url : object.image.large.url
end
end
\ No newline at end of file
module ApplicationHelper
def session_cart
(session[:cart_info] ||= {items: [], total: 0}).with_indifferent_access
end
end
class OrderMailer < ActionMailer::Base
default from: 'alicuche@gmail.com'
def send_checkout(email, order)
@order = order
@order_items = @order.order_items.includes(:product)
mail(to: email, subject: "Order number #{order.id}")
end
end
\ No newline at end of file
class Category < ActiveRecord::Base
default_scope { order(:title) }
JSON_DEFAULT = %i(id title)
has_many :products, dependent: :destroy
enum category_type: %i(system amazon)
end
module Solr extend ActiveSupport::Concern
included do
after_save :push_data_to_solr
after_destroy :remove_from_solr
# callbacks
def push_data_to_solr
self.class.rsolr.add(self.slice(*self.class.solr_fields))
self.class.rsolr.commit
end
def remove_from_solr
self.class.rsolr.delete_by_id(self[self.class.primary_key])
self.class.rsolr.commit
end
end
module ClassMethods
attr_accessor :solr_per_page, :solr_page, :solr_total_count, :solr_fields
def solr_options(fields = {})
@solr_per_page = fields[:per_page] || 5
@solr_fields = fields[:fields] || []
end
def search(query, options = {})
return unless query.is_a?(Hash)
@solr_page = options[:page] || 1
query = query.inject('') { |str, item| str << "#{item.first}:#{item.last}" << ' ' }
results = rsolr.paginate(
solr_page,
solr_per_page,
'select',
params: {q: query, fl: self.primary_key}
)
@solr_total_count = results['response']['numFound'].to_i
parse(results['response'])
end
def parse(results)
ids = results['docs'].map { |item| item[self.primary_key].to_i }
self.where(self.primary_key => ids)
end
def rsolr
@rsolr_service ||= RSolr.connect(url: Settings.solr_url)
end
def kaminari_paginate
Kaminari.paginate_array([], total_count: solr_total_count).page(solr_page).per(solr_per_page)
end
def clear_solr_index
rsolr.delete_by_query '*'
rsolr.commit
end
end
end
\ No newline at end of file
class Order < ActiveRecord::Base
belongs_to :user
has_many :order_items, dependent: :destroy
accepts_nested_attributes_for :order_items
end
class OrderItem < ActiveRecord::Base
belongs_to :order
belongs_to :product
end
class Product < ActiveRecord::Base
include Solr
# scopes
scope :recommended, ->{ self.offset(rand(self.count)).limit(Settings.limit_product_recommended) }
scope :newest, ->{ self.order(created_at: :desc).limit(Settings.limit_product_newest) }
# relations
belongs_to :category
belongs_to :user
# validates
validates :title, presence: true, length: {maximum: 255}
validates :category, presence: true
enum product_type: %i(system amazon)
mount_uploader :image, ImageUploader
solr_options per_page: 2, fields: [:id, :title]
end
class Settings < Settingslogic
source "#{Rails.root}/config/settings.yml"
namespace Rails.env
suppress_errors Rails.env.production?
end
\ No newline at end of file
class User < ActiveRecord::Base
with_options dependent: :nullify do |assoc|
assoc.has_many :orders
assoc.has_many :products
end
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
end
class BaseService
attr_accessor :current_user, :params
def initialize user = nil, params = {}
@current_user = user
@params = params
end
end
\ No newline at end of file
class OrderService < BaseService
def create(order_params)
order = current_user.orders.build(order_params)
product_ids = []
quantites = {}
order_params['order_items_attributes'].each do |item|
id = item.last['product_id']
product_ids << id
quantites[id] = item.last['quantity']
end
products = Product.where(id: [product_ids]).select(:id, :price)
total = products.inject(0) do |sum, product|
sum + (product.price.to_i * quantites[product.id.to_s].to_i)
end
order.total = total
if order.save
send_checkout_email(order)
{status: true}
else
{status: false}
end
end
private
def send_checkout_email(order)
OrderMailer.send_checkout(current_user.email, order).deliver_later
end
end
\ No newline at end of file
# encoding: utf-8
require 'carrierwave/processing/mini_magick'
class ImageUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
storage :file
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# # For Rails 3.1+ asset pipeline compatibility:
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
#
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
version :large do
process resize_to_fill: [110, 86]
end
version :medium do
process resize_to_fill: [71, 38]
end
version :small do
process resize_to_fill: [51, 32]
end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
def extension_white_list
%w(jpg jpeg gif png)
end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here, see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end
%li
= link_to category.decorate.title, category
\ No newline at end of file
= render products, show_price: true
- products.each do |product|
.product-item.col-md-4.text-center
.product-title
= link_to product.title, product
.product-image.img-thumbnail
= image_tag product.decorate.image_md_url
%h3.title
= @category.decorate.title
.module
#category-items.products-list-detail
= render @products
.pagination
= paginate @products
\ No newline at end of file
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true, value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %>
</div>
<div class="actions">
<%= f.submit "Resend confirmation instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<p>Welcome <%= @email %>!</p>
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Hello <%= @resource.email %>!</p>
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
<p>Click the link below to unlock your account:</p>
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
<h2>Change your password</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<%= f.hidden_field :reset_password_token %>
<div class="field">
<%= f.label :password, "New password" %><br />
<% if @minimum_password_length %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autofocus: true, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation, "Confirm new password" %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Change my password" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
<h2>Forgot your password?</h2>
<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Send me reset password instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
= form_for resource, as: resource_name, url: registration_path(resource_name), html: {method: :put, class: 'form-horizontal'} do |f|
= devise_error_messages!
.form-group
= f.label :email, class: 'col-sm-2 control-label'
.col-sm-4
= f.email_field :email, autofocus: true, class: 'form-control'
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
%div
Currently waiting confirmation for:
= resource.unconfirmed_email
.form-group
= f.label :password, class: 'col-sm-2 control-label'
%i (leave blank if you don't want to change it)
.col-sm-4
= f.password_field :password, autocomplete: "off", class: 'form-control'
.form-group
= f.label :password_confirmation, class: 'col-sm-2 control-label'
.col-sm-4
= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control'
.form-group
= f.label :current_password, class: 'col-sm-2 control-label'
%i (we need your current password to confirm your changes)
.col-sm-4
= f.password_field :current_password, autocomplete: "off", class: 'form-control'
.form-group
.col-sm-offset-2.col-sm-10
= f.submit "Update", class: 'btn btn-default'
= form_for resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-horizontal'} do |f|
= devise_error_messages!
.form-group
= f.label :email, class: 'col-sm-2 control-label'
.col-sm-4
= f.email_field :email, autofocus: true, class: 'form-control'
.form-group
= f.label :password, class: 'col-sm-2 control-label'
.col-sm-4
- if @minimum_password_length
%em= "(#{@minimum_password_length} characters minimum)"
= f.password_field :password, autocomplete: "off", class: 'form-control'
.form-group
= f.label :password_confirmation, class: 'col-sm-2 control-label'
.col-sm-4
= f.password_field :password_confirmation, autocomplete: "off", class: 'form-control'
.form-group
.col-sm-offset-2.col-sm-10
= f.submit "Sign up", class: 'btn btn-default'
= form_for resource, as: resource_name, url: session_path(resource_name), html: {class: 'form-horizontal'} do |f|
.form-group
= f.label :email, class: 'col-sm-2 control-label'
.col-sm-4
= f.email_field :email, autofocus: true, class: 'form-control'
.form-group
= f.label :password, class: 'col-sm-2 control-label'
.col-sm-4
= f.password_field :password, autocomplete: "off", class: 'form-control'
.form-group
.col-sm-offset-2.col-sm-10
= f.submit "Log in", class: 'btn btn-default'
<%- if controller_name != 'sessions' %>
<%= link_to "Log in", new_session_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.registerable? && controller_name != 'registrations' %>
<%= link_to "Sign up", new_registration_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %>
<%= link_to "Forgot your password?", new_password_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
<%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
<%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<%- resource_class.omniauth_providers.each do |provider| %>
<%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br />
<% end -%>
<% end -%>
<h2>Resend unlock instructions</h2>
<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="actions">
<%= f.submit "Resend unlock instructions" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
.module
%h3.title Recommended Items
.module
#recommend-items
= render 'categories/recommended', products: @recommended_items
.clearfix
.module
%h3.title Newest Items
.module
#newest-items.products-list-detail
= render 'categories/newest', products: @newest_items
\ No newline at end of file
- if @breadcrumbs.present?
%ul.breadcrumb
- @breadcrumbs.each do |breadcrumb|
%li= link_to_if breadcrumb[:url].present?, breadcrumb[:title], breadcrumb[:url]
\ No newline at end of file
#cart-info
%h3.title Category
= "Total: #{pluralize(session_cart[:total], 'item')}"
= link_to 'Checkout', orders_path, class: 'btn btn-default pull-right'
\ No newline at end of file
.navbar-header
%button.navbar-toggle.collapsed{"aria-controls" => "navbar", "aria-expanded" => "false", "data-target" => "#navbar", "data-toggle" => "collapse", :type => "button"}
%span.sr-only Toggle navigation
%span.icon-bar
%span.icon-bar
%span.icon-bar
%a.navbar-brand.logo{:href => "/"}
%img{src: 'http://zigexn.vn/assets/logo-main-e75d68f895f288e75637440f337c1687.png'}
#navbar.navbar-collapse.collapse
%ul.nav.navbar-nav.navbar-right
- if user_signed_in?
%li
= link_to 'Logout', destroy_user_session_path, method: :delete
%li
= link_to 'Change profile', edit_user_registration_path
%li
= link_to 'New product', new_product_path
- else
%li
= link_to('Login', new_user_session_path)
%li
= link_to 'Register', new_user_registration_path
#message
- if notice
.alert.alert-success
= notice
- if alert
.alert.alert-danger
= alert
\ No newline at end of file
= form_tag search_products_path, method: :get do
.input-group
= text_field_tag :query, params[:query], class: 'form-control', placeholder: 'Search for title...'
%span.input-group-btn
%button.btn.btn-default{type: "submit"} Go!
%h3.title Category
%ul.nav.nav-sidebar
= render Category.limit(Settings.limit_category).select(Category::JSON_DEFAULT)
\ No newline at end of file
!!!
%html{:lang => "en"}
%title Vendor
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
%nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
= render '/layouts/header'
#wrapper.container-fluid
= render '/layouts/message'
.row
.col-md-6.search-wrapper
= render 'layouts/search'
.row
.col-md-12
= render 'layouts/breadcrumb'
#content.row
.col-md-2.sidebar
.row
.col-md-12
= render 'layouts/sidebar'
.row
.col-md-12
= render 'layouts/cart'
.col-md-10
= yield
%footer.footer
.container
%p.text-muted Footer
\ No newline at end of file
!!!
%html{:lang => "en"}
%title Vendor
= stylesheet_link_tag 'application', media: 'all'
= javascript_include_tag 'application'
= csrf_meta_tags
%body
%nav.navbar.navbar-inverse.navbar-fixed-top
.container-fluid
= render '/layouts/header'
#wrapper.container-fluid
= render '/layouts/message'
.row
.col-md-6.search-wrapper
= render 'layouts/search'
#content.row
.container
.col-md-12
= yield
%p= "Order ##{@order.id}"
%p= "Total: #{@order.total}"
%table
%thead
%tr
%td.text-right #
%td Title
%td Price
%td Quantity
%tbody
- @order_items.each_with_index do |order_item, index|
%tr
%td.number.text-right
= index + 1
%td.title
= link_to order_item.product.title, product_url(order_item.product)
%td.price
= order_item.product.price
%td.quantity
= order_item.quantity
\ No newline at end of file
#checkout-cart
= form_for @order do |f|
%table.table
%thead
%tr
%td.text-right #
%td Title
%td Price
%td Quantity
%tbody
- session_cart[:items].each_with_index do |order_item, index|
%tr
%td.number.text-right
= index + 1
%td.title
= link_to order_item[:title], product_path(order_item[:id])
= hidden_field_tag "order[order_items_attributes][#{index}][product_id]", order_item[:id]
%td.price
= order_item[:price]
%td.quantity
= text_field_tag "order[order_items_attributes][#{index}][quantity]", order_item[:quantity]
%tfoot
%tr
%td.text-right{colspan: 4}
= f.submit 'Checkout', class: 'btn btn-primary'
.row.product-item
.col-md-1
.product-image.img-thumbnail
%img{src: product.decorate.image_sm_url}
.col-md-9
.product-title
= link_to product.title, product_path(product)
- if local_assigns.has_key?(:show_price) && show_price.present?
.col-md-2
.product-price
Price:
= product.decorate.price
\ No newline at end of file
#form-product
= form_for @product, html: {class: 'form-horizontal'} do |f|
.form-group
= f.label :title, 'Title*', class: 'col-sm-2 control-label'
.col-sm-4
= f.text_field :title, autofocus: true, class: 'form-control'
.form-group
= f.label :price, class: 'col-sm-2 control-label'
.col-sm-4
= f.text_field :price, class: 'form-control'
.form-group
= f.label :category, class: 'col-sm-2 control-label'
.col-sm-4
= f.collection_select :category_id, @categories.decorate, :id, :title, {}, class: 'form-control'
.form-group
= f.label :image, 'Image*', class: 'col-sm-2 control-label'
.col-sm-4
= f.file_field :image, class: 'form-control'
.form-group
.col-sm-offset-2.col-sm-10
= f.submit "Save", class: 'btn btn-default'
\ No newline at end of file
%h3.title
Search result for:
= params[:query]
.module
- if @products.present?
#category-items.products-list-detail
= render @products
.pagination
= paginate @products.kaminari_paginate
\ No newline at end of file
#product-detail
.product-title
%h4= @product.title
.product-image
= image_tag @product.decorate.image_lg_url, class: 'img-thumbnail'
.product-id
Item ID:
= @product.id
.product-price
Price:
= @product.decorate.price
.product-date
Date:
= l(@product.created_at)
.clearfix
.product-addto-cart
= link_to 'Buy', add_cart_product_path(@product), class: 'btn btn-primary'
\ No newline at end of file
#!/usr/bin/env ruby
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
load Gem.bin_path('bundler', 'bundle')
#!/usr/bin/env ruby
APP_PATH = File.expand_path('../../config/application', __FILE__)
require_relative '../config/boot'
require 'rails/commands'
#!/usr/bin/env ruby
require_relative '../config/boot'
require 'rake'
Rake.application.run
#!/usr/bin/env ruby
require 'pathname'
# path to your application root.
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
Dir.chdir APP_ROOT do
# This script is a starting point to setup your application.
# Add necessary setup steps to this file:
puts "== Installing dependencies =="
system "gem install bundler --conservative"
system "bundle check || bundle install"
# puts "\n== Copying sample files =="
# unless File.exist?("config/database.yml")
# system "cp config/database.yml.sample config/database.yml"
# end
puts "\n== Preparing database =="
system "bin/rake db:setup"
puts "\n== Removing old logs and tempfiles =="
system "rm -f log/*"
system "rm -rf tmp/cache"
puts "\n== Restarting application server =="
system "touch tmp/restart.txt"
end
# This file is used by Rack-based servers to start the application.
require ::File.expand_path('../config/environment', __FILE__)
run Rails.application
require File.expand_path('../boot', __FILE__)
require 'rails/all'
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module VenShop
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.active_job.queue_adapter = :sidekiq
config.autoload_paths += Dir["#{config.root}/app/services/**/*.rb"]
end
end
# Amazon
AWS_ACCESS: AKIAJ77C4CTZOP7TUVWQ
AWS_SECRET: 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
AWS_TAG: zigexn6400-22
SOLR_URL: http://localhost:8080/solr/venshop
\ No newline at end of file
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: 123456
#socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: venshop_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: venshop_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
production:
<<: *default
database: venshop_vietth
password: 123456
# MySQL. Versions 5.0+ are recommended.
#
# Install the MYSQL driver
# gem install mysql2
#
# Ensure the MySQL gem is defined in your Gemfile
# gem 'mysql2'
#
# And be sure to use new-style password hashing:
# http://dev.mysql.com/doc/refman/5.0/en/old-client.html
#
default: &default
adapter: mysql2
encoding: utf8
pool: 5
username: root
password: 123456
#socket: /var/run/mysqld/mysqld.sock
development:
<<: *default
database: venshop_development
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
<<: *default
database: venshop_test
# As with config/secrets.yml, you never want to store sensitive information,
# like your database password, in your source code. If your source code is
# ever seen by anyone, they now have access to your database.
#
# Instead, provide the password as a unix environment variable when you boot
# the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
# for a full rundown on how to provide these environment variables in a
# production deployment.
#
# On Heroku and other platform providers, you may have a full connection URL
# available as an environment variable. For example:
#
# DATABASE_URL="mysql2://myuser:mypass@localhost/somedatabase"
#
# You can use this database configuration with:
#
# production:
# url: <%= ENV['DATABASE_URL'] %>
#
staging:
<<: *default
database: venshop_staging
password: 123456
production:
<<: *default
database: venshop_vietth
password: <%= ENV['VENSHOP_DATABASE_PASSWORD'] %>
# config valid only for current version of Capistrano
lock '3.4.0'
set :application, 'vietth'
set :pty, false
# set :branch, 'master'
ask :branch, proc { `git rev-parse --abbrev-ref HEAD`.chomp }.call
set :use_sudo, false
set :bundle_binstubs, nil
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
set :linked_files, fetch(:linked_files, []).push('config/application.yml')
set :linked_dirs, fetch(:linked_dirs, []).push(
'log',
'tmp/pids',
'tmp/cache',
'tmp/sockets',
'vendor/bundle',
'public/system',
'public/uploads'
)
after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
task :restart do
on roles(:app) do
within current_path do
if test("[ -f #{fetch(:unicorn_pid)} ]")
execute :kill, capture(:cat, fetch(:unicorn_pid))
end
with rails_env: fetch(:rails_env), wait: 3 do
execute :bundle, "exec rake seed:migrate"
config_file = "#{current_path}/config/unicorn/#{fetch(:rails_env)}.rb"
execute :bundle, "exec unicorn -c #{config_file} -D"
end
end
invoke('sidekiq:restart')
end
end
end
after 'deploy:publishing', 'deploy:restart'
set :port, 22
set :user, 'ventura'
set :deploy_via, :remote_cache
set :use_sudo, false
set :repo_url, 'git@gitlab.zigexn.vn:vietth/VietTH-VenShop.git'
server '192.168.1.204',
roles: [:web, :app, :db],
port: fetch(:port),
user: fetch(:user),
primary: true
set :deploy_to, "/web/training/#{fetch(:application)}"
set :ssh_options, {
forward_agent: true,
auth_methods: %w(publickey),
user: fetch(:user)
}
set :rails_env, :production
set :conditionally_migrate, true
\ No newline at end of file
set :port, 22
set :user, 'alicuche'
set :deploy_via, :remote_cache
set :use_sudo, false
server 'alicuche.koding.io',
roles: [:web, :app, :db],
port: fetch(:port),
user: fetch(:user),
primary: true
set :deploy_to, "/home/alicuche/Web/venshop"
set :ssh_options, {
forward_agent: true,
auth_methods: %w(publickey),
user: fetch(:user)
}
set :rails_env, :staging
set :conditionally_migrate, true
\ No newline at end of file
# Load the Rails application.
require File.expand_path('../application', __FILE__)
# Initialize the Rails application.
Rails.application.initialize!
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# Adds additional error checking when serving assets at runtime.
# Checks for improperly declared sprockets dependencies.
# Raises helpful error messages.
config.assets.raise_runtime_errors = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
# config.action_mailer.delivery_method = :letter_opener
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:user_name => 'alicuche',
:password => 'alicuche1989'
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'localhost', port: 3000 }
config.action_mailer.delivery_method = :smtp
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = false
end
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "alicuche@gmail.com",
:password => "syghbwuxfzfkgmch",
:authentication => :login,
:enable_starttls_auto => true
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => '192.168.1.204', port: 3005 }
config.action_mailer.delivery_method = :smtp
end
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
# config.assets.css_compressor = :sass
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
config.action_mailer.smtp_settings = {
:address => "smtp.gmail.com",
:port => 587,
:domain => "gmail.com",
:user_name => "alicuche@gmail.com",
:password => "syghbwuxfzfkgmch",
:authentication => :login,
:enable_starttls_auto => true
}
# ActionMailer Config
config.action_mailer.default_url_options = { :host => 'uakk111d5a2e.alicuche.koding.io', port: 80 }
config.action_mailer.delivery_method = :smtp
end
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
# Do not eager load code on boot. This avoids loading your whole application
# just for the purpose of running a single test. If you are using a tool that
# preloads Rails for running tests, you may have to set it to true.
config.eager_load = false
# Configure static file server for tests with Cache-Control for performance.
config.serve_static_files = true
config.static_cache_control = 'public, max-age=3600'
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Raise exceptions instead of rendering exception templates.
config.action_dispatch.show_exceptions = false
# Disable request forgery protection in test environment.
config.action_controller.allow_forgery_protection = false
# Tell Action Mailer not to deliver emails to the real world.
# The :test delivery method accumulates sent emails in the
# ActionMailer::Base.deliveries array.
config.action_mailer.delivery_method = :test
# Randomize the order test cases are executed.
config.active_support.test_order = :random
# Print deprecation notices to the stderr.
config.active_support.deprecation = :stderr
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
end
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
# Rails.application.config.assets.precompile += %w( search.js )
# Be sure to restart your server when you modify this file.
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
# Rails.backtrace_cleaner.remove_silencers!
# Be sure to restart your server when you modify this file.
Rails.application.config.action_dispatch.cookies_serializer = :json
# Be sure to restart your server when you modify this file.
# Configure sensitive parameters which will be filtered from the log file.
Rails.application.config.filter_parameters += [:password]
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections(:en) do |inflect|
# inflect.acronym 'RESTful'
# end
Kaminari.configure do |config|
config.default_per_page = 5
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
# Be sure to restart your server when you modify this file.
# Add new mime types for use in respond_to blocks:
# Mime::Type.register "text/richtext", :rtf
# Be sure to restart your server when you modify this file.
Rails.application.config.session_store :cookie_store, key: '_venShop_session'
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment