Skip to content

Commit

Permalink
Merge pull request #305 from leastbad/add_redis
Browse files Browse the repository at this point in the history
add redis to cable.yml in development mode
  • Loading branch information
leastbad authored Sep 13, 2020
2 parents 2d25e78 + 4375a95 commit 0278566
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/tasks/stimulus_reflex/install.rake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ namespace :stimulus_reflex do
File.open(filepath, "w") { |f| f.write lines.join }
end

filepath = Rails.root.join("config/cable.yml")
lines = File.open(filepath, "r") { |f| f.readlines }
if lines[1].include?("adapter: async")
lines.delete_at 1
lines.insert 1, " adapter: redis\n"
lines.insert 2, " url: <%= ENV.fetch(\"REDIS_URL\") { \"redis://localhost:6379/1\" } %>\n"
lines.insert 3, " channel_prefix: " + Rails.application.class.module_parent.to_s.underscore + "_development\n"
File.open(filepath, "w") { |f| f.write lines.join }
end

system "bundle exec rails generate stimulus_reflex example"
system "rails dev:cache" unless Rails.root.join("tmp", "caching-dev.txt").exist?
end
Expand Down

0 comments on commit 0278566

Please sign in to comment.