13 | Feel free to fork this and use it for your next spike, mvp, or entire application. If you'd like to take a look around to see how everything is working,
14 | I'd recommend checking out the following files:
15 |
16 |
17 |
app/frontend/pages/Dashboard.jsx
: The React component containing what you're reading now!
18 |
app/controllers/dashboard_controller.rb
: The controller that handled rendering this page
19 |
app/frontend/components/Layout.jsx
: The React component providing the "magic" layout similar to Rails's application layout
20 |
app/frontend/entrypoints/application.jsx
: The Vite entrypoint that handles initializing InertiaJS
If you are the application owner check the logs for more information.
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/config/puma.rb:
--------------------------------------------------------------------------------
1 | # Puma can serve each request in a thread from an internal thread pool.
2 | # The `threads` method setting takes two numbers: a minimum and maximum.
3 | # Any libraries that use thread pools should be configured to match
4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum
5 | # and maximum; this matches the default thread size of Active Record.
6 | #
7 | max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
8 | min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
9 | threads min_threads_count, max_threads_count
10 |
11 | # Specifies the `worker_timeout` threshold that Puma will use to wait before
12 | # terminating a worker in development environments.
13 | #
14 | worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
15 |
16 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
17 | #
18 | port ENV.fetch("PORT") { 3000 }
19 |
20 | # Specifies the `environment` that Puma will run in.
21 | #
22 | environment ENV.fetch("RAILS_ENV") { "development" }
23 |
24 | # Specifies the `pidfile` that Puma will use.
25 | pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
26 |
27 | # Specifies the number of `workers` to boot in clustered mode.
28 | # Workers are forked web server processes. If using threads and workers together
29 | # the concurrency of the application would be max `threads` * `workers`.
30 | # Workers do not work on JRuby or Windows (both of which do not support
31 | # processes).
32 | #
33 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
34 |
35 | # Use the `preload_app!` method when specifying a `workers` number.
36 | # This directive tells Puma to first boot the application and load code
37 | # before forking the application. This takes advantage of Copy On Write
38 | # process behavior so workers use less memory.
39 | #
40 | # preload_app!
41 |
42 | # Allow puma to be restarted by `bin/rails restart` command.
43 | plugin :tmp_restart
44 |
--------------------------------------------------------------------------------
/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The change you wanted was rejected.
62 |
Maybe you tried to change something you didn't have access to.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
6 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
The page you were looking for doesn't exist.
62 |
You may have mistyped the address or the page may have moved.
63 |
64 |
If you are the application owner check the logs for more information.
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/config/environments/test.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | # The test environment is used exclusively to run your application's
4 | # test suite. You never need to work with it otherwise. Remember that
5 | # your test database is "scratch space" for the test suite and is wiped
6 | # and recreated between test runs. Don't rely on the data there!
7 |
8 | Rails.application.configure do
9 | # Settings specified here will take precedence over those in config/application.rb.
10 |
11 | # Turn false under Spring and add config.action_view.cache_template_loading = true.
12 | config.cache_classes = true
13 |
14 | # Eager loading loads your whole application. When running a single test locally,
15 | # this probably isn't necessary. It's a good idea to do in a continuous integration
16 | # system, or in some way before deploying your code.
17 | config.eager_load = ENV["CI"].present?
18 |
19 | # Configure public file server for tests with Cache-Control for performance.
20 | config.public_file_server.enabled = true
21 | config.public_file_server.headers = {
22 | "Cache-Control" => "public, max-age=#{1.hour.to_i}"
23 | }
24 |
25 | # Show full error reports and disable caching.
26 | config.consider_all_requests_local = true
27 | config.action_controller.perform_caching = false
28 | config.cache_store = :null_store
29 |
30 | # Raise exceptions instead of rendering exception templates.
31 | config.action_dispatch.show_exceptions = false
32 |
33 | # Disable request forgery protection in test environment.
34 | config.action_controller.allow_forgery_protection = false
35 |
36 | # Print deprecation notices to the stderr.
37 | config.active_support.deprecation = :stderr
38 |
39 | # Raise exceptions for disallowed deprecations.
40 | config.active_support.disallowed_deprecation = :raise
41 |
42 | # Tell Active Support which deprecation messages to disallow.
43 | config.active_support.disallowed_deprecation_warnings = []
44 |
45 | # Raises error for missing translations.
46 | # config.i18n.raise_on_missing_translations = true
47 |
48 | # Annotate rendered view with file names.
49 | # config.action_view.annotate_rendered_view_with_filenames = true
50 | end
51 |
--------------------------------------------------------------------------------
/config/environments/development.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # In the development environment your application's code is reloaded any time
7 | # it changes. This slows down response time but is perfect for development
8 | # since you don't have to restart the web server when you make code changes.
9 | config.cache_classes = false
10 |
11 | # Do not eager load code on boot.
12 | config.eager_load = false
13 |
14 | # Show full error reports.
15 | config.consider_all_requests_local = true
16 |
17 | # Enable server timing
18 | config.server_timing = true
19 |
20 | # Enable/disable caching. By default caching is disabled.
21 | # Run rails dev:cache to toggle caching.
22 | if Rails.root.join("tmp/caching-dev.txt").exist?
23 | config.action_controller.perform_caching = true
24 | config.action_controller.enable_fragment_cache_logging = true
25 |
26 | config.cache_store = :memory_store
27 | config.public_file_server.headers = {
28 | "Cache-Control" => "public, max-age=#{2.days.to_i}"
29 | }
30 | else
31 | config.action_controller.perform_caching = false
32 |
33 | config.cache_store = :null_store
34 | end
35 |
36 | # Print deprecation notices to the Rails logger.
37 | config.active_support.deprecation = :log
38 |
39 | # Raise exceptions for disallowed deprecations.
40 | config.active_support.disallowed_deprecation = :raise
41 |
42 | # Tell Active Support which deprecation messages to disallow.
43 | config.active_support.disallowed_deprecation_warnings = []
44 |
45 | # Raise an error on page load if there are pending migrations.
46 | config.active_record.migration_error = :page_load
47 |
48 | # Highlight code that triggered database queries in logs.
49 | config.active_record.verbose_query_logs = true
50 |
51 | # Suppress logger output for asset requests.
52 | config.assets.quiet = true
53 |
54 | # Raises error for missing translations.
55 | # config.i18n.raise_on_missing_translations = true
56 |
57 | # Annotate rendered view with file names.
58 | # config.action_view.annotate_rendered_view_with_filenames = true
59 |
60 | # Uncomment if you wish to allow Action Cable access from any origin.
61 | # config.action_cable.disable_request_forgery_protection = true
62 | end
63 |
--------------------------------------------------------------------------------
/app/frontend/components/Layout.jsx:
--------------------------------------------------------------------------------
1 | import { InertiaLink } from "@inertiajs/inertia-react";
2 |
3 | const Layout = ({children}) => (
4 | <>
5 |
6 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | {children}
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | >
38 | )
39 |
40 |
41 |
42 | export default page => {page};
43 |
--------------------------------------------------------------------------------
/config/environments/production.rb:
--------------------------------------------------------------------------------
1 | require "active_support/core_ext/integer/time"
2 |
3 | Rails.application.configure do
4 | # Settings specified here will take precedence over those in config/application.rb.
5 |
6 | # Code is not reloaded between requests.
7 | config.cache_classes = true
8 |
9 | # Eager load code on boot. This eager loads most of Rails and
10 | # your application in memory, allowing both threaded web servers
11 | # and those relying on copy on write to perform better.
12 | # Rake tasks automatically ignore this option for performance.
13 | config.eager_load = true
14 |
15 | # Full error reports are disabled and caching is turned on.
16 | config.consider_all_requests_local = false
17 | config.action_controller.perform_caching = true
18 |
19 | # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
20 | # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
21 | # config.require_master_key = true
22 |
23 | # Disable serving static files from the `/public` folder by default since
24 | # Apache or NGINX already handles this.
25 | config.public_file_server.enabled = ENV["RAILS_SERVE_STATIC_FILES"].present?
26 |
27 | # Compress CSS using a preprocessor.
28 | # config.assets.css_compressor = :sass
29 |
30 | # Do not fallback to assets pipeline if a precompiled asset is missed.
31 | config.assets.compile = false
32 |
33 | # Enable serving of images, stylesheets, and JavaScripts from an asset server.
34 | # config.asset_host = "http://assets.example.com"
35 |
36 | # Specifies the header that your server uses for sending files.
37 | # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for Apache
38 | # config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" # for NGINX
39 |
40 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
41 | # config.force_ssl = true
42 |
43 | # Include generic and useful information about system operation, but avoid logging too much
44 | # information to avoid inadvertent exposure of personally identifiable information (PII).
45 | config.log_level = :info
46 |
47 | # Prepend all log lines with the following tags.
48 | config.log_tags = [ :request_id ]
49 |
50 | # Use a different cache store in production.
51 | # config.cache_store = :mem_cache_store
52 |
53 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
54 | # the I18n.default_locale when a translation cannot be found).
55 | config.i18n.fallbacks = true
56 |
57 | # Don't log any deprecations.
58 | config.active_support.report_deprecations = false
59 |
60 | # Use default logging formatter so that PID and timestamp are not suppressed.
61 | config.log_formatter = ::Logger::Formatter.new
62 |
63 | # Use a different logger for distributed setups.
64 | # require "syslog/logger"
65 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new "app-name")
66 |
67 | if ENV["RAILS_LOG_TO_STDOUT"].present?
68 | logger = ActiveSupport::Logger.new(STDOUT)
69 | logger.formatter = config.log_formatter
70 | config.logger = ActiveSupport::TaggedLogging.new(logger)
71 | end
72 |
73 | # Do not dump schema after migrations.
74 | config.active_record.dump_schema_after_migration = false
75 | end
76 |
--------------------------------------------------------------------------------
/bin/bundle:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'bundle' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | require "rubygems"
12 |
13 | m = Module.new do
14 | module_function
15 |
16 | def invoked_as_script?
17 | File.expand_path($0) == File.expand_path(__FILE__)
18 | end
19 |
20 | def env_var_version
21 | ENV["BUNDLER_VERSION"]
22 | end
23 |
24 | def cli_arg_version
25 | return unless invoked_as_script? # don't want to hijack other binstubs
26 | return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
27 | bundler_version = nil
28 | update_index = nil
29 | ARGV.each_with_index do |a, i|
30 | if update_index && update_index.succ == i && a =~ Gem::Version::ANCHORED_VERSION_PATTERN
31 | bundler_version = a
32 | end
33 | next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34 | bundler_version = $1
35 | update_index = i
36 | end
37 | bundler_version
38 | end
39 |
40 | def gemfile
41 | gemfile = ENV["BUNDLE_GEMFILE"]
42 | return gemfile if gemfile && !gemfile.empty?
43 |
44 | File.expand_path("../../Gemfile", __FILE__)
45 | end
46 |
47 | def lockfile
48 | lockfile =
49 | case File.basename(gemfile)
50 | when "gems.rb" then gemfile.sub(/\.rb$/, gemfile)
51 | else "#{gemfile}.lock"
52 | end
53 | File.expand_path(lockfile)
54 | end
55 |
56 | def lockfile_version
57 | return unless File.file?(lockfile)
58 | lockfile_contents = File.read(lockfile)
59 | return unless lockfile_contents =~ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/
60 | Regexp.last_match(1)
61 | end
62 |
63 | def bundler_requirement
64 | @bundler_requirement ||=
65 | env_var_version || cli_arg_version ||
66 | bundler_requirement_for(lockfile_version)
67 | end
68 |
69 | def bundler_requirement_for(version)
70 | return "#{Gem::Requirement.default}.a" unless version
71 |
72 | bundler_gem_version = Gem::Version.new(version)
73 |
74 | requirement = bundler_gem_version.approximate_recommendation
75 |
76 | return requirement unless Gem.rubygems_version < Gem::Version.new("2.7.0")
77 |
78 | requirement += ".a" if bundler_gem_version.prerelease?
79 |
80 | requirement
81 | end
82 |
83 | def load_bundler!
84 | ENV["BUNDLE_GEMFILE"] ||= gemfile
85 |
86 | activate_bundler
87 | end
88 |
89 | def activate_bundler
90 | gem_error = activation_error_handling do
91 | gem "bundler", bundler_requirement
92 | end
93 | return if gem_error.nil?
94 | require_error = activation_error_handling do
95 | require "bundler/version"
96 | end
97 | return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98 | warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
99 | exit 42
100 | end
101 |
102 | def activation_error_handling
103 | yield
104 | nil
105 | rescue StandardError, LoadError => e
106 | e
107 | end
108 | end
109 |
110 | m.load_bundler!
111 |
112 | if m.invoked_as_script?
113 | load Gem.bin_path("bundler", "bundle")
114 | end
115 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | actioncable (7.0.2.3)
5 | actionpack (= 7.0.2.3)
6 | activesupport (= 7.0.2.3)
7 | nio4r (~> 2.0)
8 | websocket-driver (>= 0.6.1)
9 | actionmailbox (7.0.2.3)
10 | actionpack (= 7.0.2.3)
11 | activejob (= 7.0.2.3)
12 | activerecord (= 7.0.2.3)
13 | activestorage (= 7.0.2.3)
14 | activesupport (= 7.0.2.3)
15 | mail (>= 2.7.1)
16 | net-imap
17 | net-pop
18 | net-smtp
19 | actionmailer (7.0.2.3)
20 | actionpack (= 7.0.2.3)
21 | actionview (= 7.0.2.3)
22 | activejob (= 7.0.2.3)
23 | activesupport (= 7.0.2.3)
24 | mail (~> 2.5, >= 2.5.4)
25 | net-imap
26 | net-pop
27 | net-smtp
28 | rails-dom-testing (~> 2.0)
29 | actionpack (7.0.2.3)
30 | actionview (= 7.0.2.3)
31 | activesupport (= 7.0.2.3)
32 | rack (~> 2.0, >= 2.2.0)
33 | rack-test (>= 0.6.3)
34 | rails-dom-testing (~> 2.0)
35 | rails-html-sanitizer (~> 1.0, >= 1.2.0)
36 | actiontext (7.0.2.3)
37 | actionpack (= 7.0.2.3)
38 | activerecord (= 7.0.2.3)
39 | activestorage (= 7.0.2.3)
40 | activesupport (= 7.0.2.3)
41 | globalid (>= 0.6.0)
42 | nokogiri (>= 1.8.5)
43 | actionview (7.0.2.3)
44 | activesupport (= 7.0.2.3)
45 | builder (~> 3.1)
46 | erubi (~> 1.4)
47 | rails-dom-testing (~> 2.0)
48 | rails-html-sanitizer (~> 1.1, >= 1.2.0)
49 | activejob (7.0.2.3)
50 | activesupport (= 7.0.2.3)
51 | globalid (>= 0.3.6)
52 | activemodel (7.0.2.3)
53 | activesupport (= 7.0.2.3)
54 | activerecord (7.0.2.3)
55 | activemodel (= 7.0.2.3)
56 | activesupport (= 7.0.2.3)
57 | activestorage (7.0.2.3)
58 | actionpack (= 7.0.2.3)
59 | activejob (= 7.0.2.3)
60 | activerecord (= 7.0.2.3)
61 | activesupport (= 7.0.2.3)
62 | marcel (~> 1.0)
63 | mini_mime (>= 1.1.0)
64 | activesupport (7.0.2.3)
65 | concurrent-ruby (~> 1.0, >= 1.0.2)
66 | i18n (>= 1.6, < 2)
67 | minitest (>= 5.1)
68 | tzinfo (~> 2.0)
69 | builder (3.2.4)
70 | concurrent-ruby (1.1.10)
71 | crass (1.0.6)
72 | debug (1.5.0)
73 | irb (>= 1.3.6)
74 | reline (>= 0.2.7)
75 | digest (3.1.0)
76 | dry-cli (0.7.0)
77 | erubi (1.10.0)
78 | globalid (1.0.0)
79 | activesupport (>= 5.0)
80 | i18n (1.10.0)
81 | concurrent-ruby (~> 1.0)
82 | inertia_rails (1.11.1)
83 | rails (>= 5)
84 | io-console (0.5.11)
85 | irb (1.4.1)
86 | reline (>= 0.3.0)
87 | loofah (2.16.0)
88 | crass (~> 1.0.2)
89 | nokogiri (>= 1.5.9)
90 | mail (2.7.1)
91 | mini_mime (>= 0.1.1)
92 | marcel (1.0.2)
93 | method_source (1.0.0)
94 | mini_mime (1.1.2)
95 | minitest (5.15.0)
96 | net-imap (0.2.3)
97 | digest
98 | net-protocol
99 | strscan
100 | net-pop (0.1.1)
101 | digest
102 | net-protocol
103 | timeout
104 | net-protocol (0.1.3)
105 | timeout
106 | net-smtp (0.3.1)
107 | digest
108 | net-protocol
109 | timeout
110 | nio4r (2.5.8)
111 | nokogiri (1.13.4-x86_64-darwin)
112 | racc (~> 1.4)
113 | puma (5.6.4)
114 | nio4r (~> 2.0)
115 | racc (1.6.0)
116 | rack (2.2.3)
117 | rack-proxy (0.7.2)
118 | rack
119 | rack-test (1.1.0)
120 | rack (>= 1.0, < 3)
121 | rails (7.0.2.3)
122 | actioncable (= 7.0.2.3)
123 | actionmailbox (= 7.0.2.3)
124 | actionmailer (= 7.0.2.3)
125 | actionpack (= 7.0.2.3)
126 | actiontext (= 7.0.2.3)
127 | actionview (= 7.0.2.3)
128 | activejob (= 7.0.2.3)
129 | activemodel (= 7.0.2.3)
130 | activerecord (= 7.0.2.3)
131 | activestorage (= 7.0.2.3)
132 | activesupport (= 7.0.2.3)
133 | bundler (>= 1.15.0)
134 | railties (= 7.0.2.3)
135 | rails-dom-testing (2.0.3)
136 | activesupport (>= 4.2.0)
137 | nokogiri (>= 1.6)
138 | rails-html-sanitizer (1.4.2)
139 | loofah (~> 2.3)
140 | railties (7.0.2.3)
141 | actionpack (= 7.0.2.3)
142 | activesupport (= 7.0.2.3)
143 | method_source
144 | rake (>= 12.2)
145 | thor (~> 1.0)
146 | zeitwerk (~> 2.5)
147 | rake (13.0.6)
148 | reline (0.3.1)
149 | io-console (~> 0.5)
150 | sprockets (4.0.3)
151 | concurrent-ruby (~> 1.0)
152 | rack (> 1, < 3)
153 | sprockets-rails (3.4.2)
154 | actionpack (>= 5.2)
155 | activesupport (>= 5.2)
156 | sprockets (>= 3.0.0)
157 | sqlite3 (1.4.2)
158 | strscan (3.0.1)
159 | thor (1.2.1)
160 | timeout (0.2.0)
161 | tzinfo (2.0.4)
162 | concurrent-ruby (~> 1.0)
163 | vite_rails (3.0.8)
164 | railties (>= 5.1, < 8)
165 | vite_ruby (~> 3.0)
166 | vite_ruby (3.1.1)
167 | dry-cli (~> 0.7.0)
168 | rack-proxy (~> 0.6, >= 0.6.1)
169 | zeitwerk (~> 2.2)
170 | websocket-driver (0.7.5)
171 | websocket-extensions (>= 0.1.0)
172 | websocket-extensions (0.1.5)
173 | zeitwerk (2.5.4)
174 |
175 | PLATFORMS
176 | x86_64-darwin-21
177 |
178 | DEPENDENCIES
179 | debug
180 | inertia_rails
181 | puma (~> 5.0)
182 | rails (~> 7.0.2, >= 7.0.2.3)
183 | sprockets-rails
184 | sqlite3 (~> 1.4)
185 | tzinfo-data
186 | vite_rails
187 |
188 | RUBY VERSION
189 | ruby 3.1.0p0
190 |
191 | BUNDLED WITH
192 | 2.3.7
193 |
--------------------------------------------------------------------------------