Skip to content

Commit

Permalink
Remove defensive programming
Browse files Browse the repository at this point in the history
These files are required in all Rails apps. If they are missing, it's
fine to explode.
  • Loading branch information
dhh committed Sep 2, 2024
1 parent d01f1ce commit a0d0047
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions lib/generators/solid_cache/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ class SolidCache::InstallGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)

def add_rails_cache
if (env_config = app_root.join("config/environments/production.rb")).exist?
gsub_file env_config, /(# )?config\.cache_store = (:.*)/, "config.cache_store = :solid_cache_store"
end
gsub_file app_root.join("config/environments/production.rb"),
/(# )?config\.cache_store = (:.*)/, "config.cache_store = :solid_cache_store"
end

def create_config_solid_cache_yml
template "config/solid_cache.yml"
end

def add_cache_db_to_database_yml
if app_root.join("config/database.yml").exist?
if app_is_using_sqlite?
gsub_file database_yml, /production:\s*<<: \*default.*/m, sqlite_database_config_with_cache
else
gsub_file database_yml, /production:\s*<<: \*default.*/m, generic_database_config_with_cache
end
if app_is_using_sqlite?
gsub_file database_yml, /production:\s*<<: \*default.*/m, sqlite_database_config_with_cache
else
gsub_file database_yml, /production:\s*<<: \*default.*/m, generic_database_config_with_cache
end
end

Expand Down

0 comments on commit a0d0047

Please sign in to comment.