Skip to content

Commit 96bb411

Browse files
jelaniwoodsraghubetina
authored andcommitted
Adds AD1-friendly configuration
1 parent 7e1a012 commit 96bb411

File tree

9 files changed

+103
-6
lines changed

9 files changed

+103
-6
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ examples.txt
3636

3737
# Ignore dotenv files
3838
/.env*
39+
40+
# Un-ignore SQLite3 db
41+
!/db/*.sqlite3
42+
!/db/*.sqlite3-journal
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
class ApplicationController < ActionController::Base
2+
skip_forgery_protection
23
end

config/application.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,16 @@ class Application < Rails::Application
1818
#
1919
# config.time_zone = "Central Time (US & Canada)"
2020
# config.eager_load_paths << Rails.root.join("extras")
21+
config.generators do |g|
22+
g.test_framework nil
23+
g.factory_bot false
24+
g.scaffold_stylesheet false
25+
g.stylesheets false
26+
g.javascripts false
27+
g.helper false
28+
end
29+
30+
config.action_controller.default_protect_from_forgery = false
31+
config.generators.system_tests = nil
2132
end
2233
end

config/database.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ default: &default
2222
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
2323

2424
development:
25-
<<: *default
26-
database: rails_template_development
25+
adapter: sqlite3
26+
database: db/development.sqlite3
27+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
28+
timeout: 5000
2729

2830
# The specified database role being used to connect to postgres.
2931
# To create additional roles in postgres see `$ createuser --help`.
@@ -56,8 +58,10 @@ development:
5658
# re-generated from your development database when you run "rake".
5759
# Do not set this db to the same as development or production.
5860
test:
59-
<<: *default
60-
database: rails_template_test
61+
adapter: sqlite3
62+
database: db/test.sqlite3
63+
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
64+
timeout: 5000
6165

6266
# As with config/credentials.yml, you never want to store sensitive information,
6367
# like your database password, in your source code. If your source code is
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
AppdevSupport.config do |config|
2-
config.action_dispatch = false;
3-
config.active_record = false;
2+
config.action_dispatch = true
3+
config.active_record = true
4+
config.pryrc = :minimal
45
end
6+
57
AppdevSupport.init
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5+
6+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7+
# Rails.backtrace_cleaner.remove_silencers!
8+
9+
Rails.backtrace_cleaner.add_silencer { |line| line =~ /lib|gems/ }
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# Specify a serializer for the signed and encrypted cookie jars.
4+
# Valid options are :json, :marshal, and :hybrid.
5+
Rails.application.config.action_dispatch.cookies_serializer = :json
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
module ActionDispatch
3+
class ExceptionWrapper
4+
def framework_trace
5+
[]
6+
end
7+
end
8+
end
9+
10+
module ActionDispatch
11+
module Routing
12+
class RouteSet
13+
def draw(&block)
14+
clear! unless @disable_clear_and_finalize
15+
eval_block(block)
16+
finalize! unless @disable_clear_and_finalize
17+
nil
18+
rescue => e
19+
nicer_message = e.message
20+
nicer_message = nicer_message.sub(/for .+/,'.')
21+
nicer_message = nicer_message.sub('ApplicationController::','')
22+
nicer_message = nicer_message.sub('uninitialized constant','undefined class')
23+
nicer_message = nicer_message.sub('undefined local variable or method','unrecognized')
24+
nicer_message = nicer_message.sub(/ \(/,'')
25+
nicer_message = nicer_message.sub(/did you mean/, 'Did you mean')
26+
27+
route_line = e.backtrace.detect { |line| line !~ /\/gems/ }.sub(/^[^\/]+/,'')
28+
route_line.sub!(/:in .+/,'')
29+
route_line =~ /(.+):(.+)/
30+
31+
puts
32+
puts "ERROR: routes.rb"
33+
puts nicer_message
34+
puts route_line
35+
puts
36+
37+
rescue_route = proc do
38+
html = "<h2>There's a problem with your routes.rb file.</h2><p><code>#{nicer_message}</code></p><p><code>#{route_line}</code></p>"
39+
get '/' => proc {|env| [200, { "Content-Type" => 'text/html'}, [html]]}
40+
get '*path' => proc {|env| [200, { "Content-Type" => 'text/html'}, [html]]}
41+
end
42+
43+
eval_block(rescue_route)
44+
end
45+
end
46+
end
47+
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Be sure to restart your server when you modify this file.
2+
3+
# This file contains settings for ActionController::ParamsWrapper which
4+
# is enabled by default.
5+
6+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7+
ActiveSupport.on_load(:action_controller) do
8+
wrap_parameters format: [:json]
9+
end
10+
11+
# To enable root element in JSON for ActiveRecord objects.
12+
# ActiveSupport.on_load(:active_record) do
13+
# self.include_root_in_json = true
14+
# end

0 commit comments

Comments
 (0)