From b830e683b0b1f4fdf70afdbe614ee2c33d63c2d8 Mon Sep 17 00:00:00 2001 From: Shanil Puri Date: Sat, 20 Sep 2014 19:43:52 -0400 Subject: [PATCH 1/3] Updated the initializeers and routes file to make app compatible with Rails 4. Updated Rails version to 4.1.6 and added corresponding dependencies to Gemfile. --- .gitignore | 5 ++++- Gemfile | 12 +++++++----- config/application.rb | 2 +- config/environments/development.rb | 5 +++-- config/routes.rb | 4 ++-- 5 files changed, 17 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 0a85564..ca05a53 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,9 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp +# Ignore all Gemgile.lock +Gemfile.lock - +# Ignore the .idea folder generated by RubyMine +.idea/ # Add non-default ignores below diff --git a/Gemfile b/Gemfile index a7a17bd..0022841 100644 --- a/Gemfile +++ b/Gemfile @@ -1,19 +1,21 @@ source 'https://rubygems.org' -gem 'rails', '3.2.13' +gem 'rails', '4.1.6' gem 'execjs' gem 'therubyracer' gem 'bootstrap-sass', '2.0.0' +gem 'activeresource' +gem 'activerecord' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' -gem 'mysql2', '0.3.11' +gem 'mysql2' gem 'devise' # 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' + gem 'sass-rails', github: 'rails/sass-rails' + gem 'coffee-rails' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', :platforms => :ruby @@ -21,7 +23,7 @@ group :assets do gem 'uglifier', '>= 1.0.3' end -gem 'jquery-rails', '1.0.19' +gem 'jquery-rails' # To use ActiveModel has_secure_password # gem 'bcrypt-ruby', '~> 3.0.0' diff --git a/config/application.rb b/config/application.rb index 90caef1..8254520 100644 --- a/config/application.rb +++ b/config/application.rb @@ -57,7 +57,7 @@ class Application < Rails::Application # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. - config.active_record.whitelist_attributes = false + # config.active_record.whitelist_attributes = false # Enable the asset pipeline config.assets.enabled = true diff --git a/config/environments/development.rb b/config/environments/development.rb index 396eba0..cd7a793 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -4,6 +4,7 @@ # 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.eager_load = false config.cache_classes = false # Log error messages when you accidentally call methods on nil. @@ -23,11 +24,11 @@ config.action_dispatch.best_standards_support = :builtin # Raise exception on mass assignment protection for Active Record models - config.active_record.mass_assignment_sanitizer = :strict + # config.active_record.mass_assignment_sanitizer = :strict # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) - config.active_record.auto_explain_threshold_in_seconds = 0.5 + # config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false diff --git a/config/routes.rb b/config/routes.rb index 84a895e..542fed1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,8 +10,8 @@ resources :user - match "posts/published", :to => "post#published" - match "posts/drafts", :to => "post#drafts" + get "posts/published", :to => "post#published" + get "posts/drafts", :to => "post#drafts" resources :post do get :show_post_body get :publish_draft From 89dda7a14b6106116f20f7463e15c308dbe53170 Mon Sep 17 00:00:00 2001 From: Shanil Puri Date: Sat, 20 Sep 2014 22:39:01 -0400 Subject: [PATCH 2/3] Corrected the views to be generated correctly. --- app/assets/stylesheets/application.css.scss | 2 +- config/application.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 62d5b77..ede9da5 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -7,7 +7,7 @@ * * You're free to add application-wide styles to this file and they'll appear at the top of the * compiled file, but it's generally better to create a new file per style scope. - * + *= require bootstrap *= require_self *= require_tree . */ diff --git a/config/application.rb b/config/application.rb index 8254520..388cf54 100644 --- a/config/application.rb +++ b/config/application.rb @@ -64,5 +64,21 @@ class Application < Rails::Application # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' + + # config.assets.compile = true + # config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif*.js, *.css, *.css.erb, *.sass) + initializer 'setup_asset_pipeline', :group => :all do |app| + # We don't want the default of everything that isn't js or css, because it pulls too many things in + app.config.assets.precompile.shift + + # Explicitly register the extensions we are interested in compiling + app.config.assets.precompile.push(Proc.new do |path| + File.extname(path).in? [ + '.html', '.erb', '.haml', # Templates + '.png', '.gif', '.jpg', '.jpeg', # Images + '.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts + ] + end) + end end end From 9b31f9f60bd4a8c1afb91f95b9875e11e5561d71 Mon Sep 17 00:00:00 2001 From: Shanil Puri Date: Sat, 20 Sep 2014 22:43:42 -0400 Subject: [PATCH 3/3] Updated gemfile --- Gemfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index 0022841..37e85ab 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ source 'https://rubygems.org' gem 'rails', '4.1.6' gem 'execjs' gem 'therubyracer' -gem 'bootstrap-sass', '2.0.0' +gem 'bootstrap-sass', "~> 2.3.2" gem 'activeresource' gem 'activerecord' # Bundle edge Rails instead: @@ -14,7 +14,7 @@ gem 'devise' # Gems used only for assets and not required # in production environments by default. group :assets do - gem 'sass-rails', github: 'rails/sass-rails' + gem 'sass-rails', '~> 4.0.3' gem 'coffee-rails' # See https://github.com/sstephenson/execjs#readme for more supported runtimes