Skip to content

Instantly share code, notes, and snippets.

@hannesstruss
Created May 30, 2017 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannesstruss/06793350b554cfee5b25d0789edb85ef to your computer and use it in GitHub Desktop.
Save hannesstruss/06793350b554cfee5b25d0789edb85ef to your computer and use it in GitHub Desktop.
diff -ru api/myapp/Gemfile noapi/myapp/Gemfile
--- api/myapp/Gemfile 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/Gemfile 2017-05-30 16:09:43.000000000 +0200
@@ -12,21 +12,8 @@
gem 'sqlite3'
# Use Puma as the app server
gem 'puma', '~> 3.0'
-# 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.2'
-# 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 navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
-gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
-gem 'jbuilder', '~> 2.5'
+# gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
@@ -35,14 +22,15 @@
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
+# Use Rack CORS for handling Cross-Origin Resource Sharing (CORS), making cross-origin AJAX possible
+# gem 'rack-cors'
+
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platform: :mri
end
group :development do
- # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
- gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.0.5'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
diff -ru api/myapp/Gemfile.lock noapi/myapp/Gemfile.lock
--- api/myapp/Gemfile.lock 2017-05-30 16:10:04.000000000 +0200
+++ noapi/myapp/Gemfile.lock 2017-05-30 16:09:46.000000000 +0200
@@ -39,30 +39,14 @@
minitest (~> 5.1)
tzinfo (~> 1.1)
arel (7.1.4)
- bindex (0.5.0)
builder (3.2.3)
byebug (9.0.6)
- coffee-rails (4.2.2)
- coffee-script (>= 2.2.0)
- railties (>= 4.0.0)
- coffee-script (2.4.1)
- coffee-script-source
- execjs
- coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
erubis (2.7.0)
- execjs (2.7.0)
ffi (1.9.18)
globalid (0.4.0)
activesupport (>= 4.2.0)
i18n (0.8.1)
- jbuilder (2.6.4)
- activesupport (>= 3.0.0)
- multi_json (>= 1.2)
- jquery-rails (4.3.1)
- rails-dom-testing (>= 1, < 3)
- railties (>= 4.2.0)
- thor (>= 0.14, < 2.0)
listen (3.0.8)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@@ -76,7 +60,6 @@
mime-types-data (3.2016.0521)
mini_portile2 (2.1.0)
minitest (5.10.2)
- multi_json (1.12.1)
nio4r (2.1.0)
nokogiri (1.7.2)
mini_portile2 (~> 2.1.0)
@@ -111,13 +94,6 @@
rb-fsevent (0.9.8)
rb-inotify (0.9.8)
ffi (>= 0.5.0)
- sass (3.4.24)
- sass-rails (5.0.6)
- railties (>= 4.0.0, < 6)
- sass (~> 3.1)
- sprockets (>= 2.8, < 4.0)
- sprockets-rails (>= 2.0, < 4.0)
- tilt (>= 1.1, < 3)
spring (2.0.2)
activesupport (>= 4.2)
spring-watcher-listen (2.0.1)
@@ -133,19 +109,8 @@
sqlite3 (1.3.13)
thor (0.19.4)
thread_safe (0.3.6)
- tilt (2.0.7)
- turbolinks (5.0.1)
- turbolinks-source (~> 5)
- turbolinks-source (5.0.3)
tzinfo (1.2.3)
thread_safe (~> 0.1)
- uglifier (3.2.0)
- execjs (>= 0.3.0, < 3)
- web-console (3.5.1)
- actionview (>= 5.0)
- activemodel (>= 5.0)
- bindex (>= 0.4.0)
- railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
@@ -155,20 +120,13 @@
DEPENDENCIES
byebug
- coffee-rails (~> 4.2)
- jbuilder (~> 2.5)
- jquery-rails
listen (~> 3.0.5)
puma (~> 3.0)
rails (~> 5.0.3)
- sass-rails (~> 5.0)
spring
spring-watcher-listen (~> 2.0.0)
sqlite3
- turbolinks (~> 5)
tzinfo-data
- uglifier (>= 1.3.0)
- web-console (>= 3.3.0)
BUNDLED WITH
1.14.6
Only in api/myapp/app: assets
diff -ru api/myapp/app/controllers/application_controller.rb noapi/myapp/app/controllers/application_controller.rb
--- api/myapp/app/controllers/application_controller.rb 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/app/controllers/application_controller.rb 2017-05-30 16:09:43.000000000 +0200
@@ -1,3 +1,2 @@
-class ApplicationController < ActionController::Base
- protect_from_forgery with: :exception
+class ApplicationController < ActionController::API
end
Only in api/myapp/app: helpers
Only in api/myapp/app/views/layouts: application.html.erb
diff -ru api/myapp/config/application.rb noapi/myapp/config/application.rb
--- api/myapp/config/application.rb 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/config/application.rb 2017-05-30 16:09:43.000000000 +0200
@@ -1,6 +1,16 @@
require_relative 'boot'
-require 'rails/all'
+require "rails"
+# Pick the frameworks you want:
+require "active_model/railtie"
+require "active_job/railtie"
+require "active_record/railtie"
+require "action_controller/railtie"
+require "action_mailer/railtie"
+require "action_view/railtie"
+require "action_cable/engine"
+# require "sprockets/railtie"
+require "rails/test_unit/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
@@ -11,5 +21,10 @@
# 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.
+
+ # Only loads a smaller set of middleware suitable for API only apps.
+ # Middleware like session, flash, cookies can be added back manually.
+ # Skip views, helpers and assets when generating a new resource.
+ config.api_only = true
end
end
diff -ru api/myapp/config/environments/development.rb noapi/myapp/config/environments/development.rb
--- api/myapp/config/environments/development.rb 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/config/environments/development.rb 2017-05-30 16:09:43.000000000 +0200
@@ -37,13 +37,6 @@
# 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
-
- # Suppress logger output for asset requests.
- config.assets.quiet = true
# Raises error for missing translations
# config.action_view.raise_on_missing_translations = true
diff -ru api/myapp/config/environments/production.rb noapi/myapp/config/environments/production.rb
--- api/myapp/config/environments/production.rb 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/config/environments/production.rb 2017-05-30 16:09:43.000000000 +0200
@@ -18,14 +18,6 @@
# Apache or NGINX already handles this.
config.public_file_server.enabled = 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
-
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
Only in api/myapp/config/initializers: assets.rb
Only in api/myapp/config/initializers: cookies_serializer.rb
Only in noapi/myapp/config/initializers: cors.rb
diff -ru api/myapp/config/initializers/new_framework_defaults.rb noapi/myapp/config/initializers/new_framework_defaults.rb
--- api/myapp/config/initializers/new_framework_defaults.rb 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/config/initializers/new_framework_defaults.rb 2017-05-30 16:09:43.000000000 +0200
@@ -6,12 +6,6 @@
Rails.application.config.raise_on_unfiltered_parameters = true
-# Enable per-form CSRF tokens. Previous versions had false.
-Rails.application.config.action_controller.per_form_csrf_tokens = true
-
-# Enable origin-checking CSRF mitigation. Previous versions had false.
-Rails.application.config.action_controller.forgery_protection_origin_check = true
-
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
# Previous versions had false.
ActiveSupport.to_time_preserves_timezone = true
Only in api/myapp/config/initializers: session_store.rb
diff -ru api/myapp/config/secrets.yml noapi/myapp/config/secrets.yml
--- api/myapp/config/secrets.yml 2017-05-30 16:10:00.000000000 +0200
+++ noapi/myapp/config/secrets.yml 2017-05-30 16:09:43.000000000 +0200
@@ -11,10 +11,10 @@
# if you're sharing your code publicly.
development:
- secret_key_base: 23bb922f60177b5708e335731a07b3c6fa172f35132ff842ae83c8d04e1c6ef21062420f786323f114a4873df2919a03a83ed410e62e1639a6a4051a0789422c
+ secret_key_base: 345030a49a0473b4f3befd8a93df9121bd612e7bd6429f407832b2f78789646f5cd45001d9c220e8e551ed953de7fd79c00d10df8e1081a0c8bc403821d364e3
test:
- secret_key_base: 0cd26e5d52154e434184abac245d2ff7296ae42539296ed83a49977596131f17ad13bd2bb8cd769e79795ce117d9857606c19d8876e91b114c0446ccf6a27525
+ secret_key_base: e8970aad06c74f085ac9130b99733f5a3cd484121525bcb4f20e507e2f64f6d91b326253a3cff59a9ca04f1878a62597e1afd1479d3b0afb897792a19d620e1e
# Do not keep production secrets in the repository,
# instead read values from the environment.
Only in api/myapp/lib: assets
Only in api/myapp/public: 404.html
Only in api/myapp/public: 422.html
Only in api/myapp/public: 500.html
Only in api/myapp/public: apple-touch-icon-precomposed.png
Only in api/myapp/public: apple-touch-icon.png
Only in api/myapp/public: favicon.ico
Only in api/myapp/test: helpers
Only in api/myapp/tmp/cache: assets
Only in api/myapp/vendor: assets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment