How to replace values in a block of text

I’m quite new to ruby and so have no idea to to approach this…please be kind.

I have a config file that I need to read and replace 2 values…

The block I need to update is:

rails_root = File.expand_path(’…/…’, FILE)
if %w(development test).include?(ENV[‘RAILS_ENV’])
worker_processes 2
worker_processes 100


I need to replace the values for “worker_processes” with new values…say 20 and 50 respectively…any help greatly appreciated. Thanks in advance!

The way to approach this depends too much on the details. Reading the file
in memory and applying some simple regexp could suffice. On the other
extreme you could redefine the problem by using environment variables in
each call to worker_processes and having the values set externally. And
there are surely other solutions in between.

Just some thoughts, the topic of this mailing list is Rails _core_
development, however. That is, things related to the development of Rails
itself. Please repost your question to the rubyonrails-talk mailing list,
IRC, or (gasp!) Stack Overflow. (This is a Ruby problem indeed, not Rails

Ah…thanks for the pointers. I’ll post in the more appropriate places.