Sometimes I run a command like rails g controller foo index
to generate skeletons for controller and template.
Because I don\'t want to have helpers and
As of Rails 4.2, it's possible to disable route generation with the following code in your application.rb:
config.generators do |g|
g.skip_routes true
end
Source: https://github.com/rails/rails/commit/4b173b8ed90cb409c1cdfb922914b41b5e212cb6
Looks like routes generation is hardcoded. Have a look at this method https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/controller/controller_generator.rb#L12
I think, the simplest way is to override with monkey-patch . Something like
module Rails
module Generators
class ControllerGenerator < NamedBase
def add_routes
#do nothing...
end
end
end
end
you can put it to initializer and try.
untested...
config.generators do |g|
g.resource_route false
end
https://github.com/rails/rails/blob/master/railties/lib/rails/generators.rb
Create your own generator! Following link will help:
http://guides.rubyonrails.org/generators.html
This is counter intuitive, but here it is what you're looking for:
config.generators do |g|
g.skip_routes true
end
Since you want this particular application to not generate routes.
You can deploy your gems to local/project folder and override them.
In your rails project folder
bundle install --path /my_rails_path/lib/
Now you can see all of you libraries ported to your project lib/
folder
Go to the below file (path changes depending upon your versions)
lib/ruby/1.9.1/gems/railties-3.2.15/lib/rails/generators/rails/controller/controller_generator.rb
and comment the function add_routes
def add_routes
#actions.reverse.each do |action|
# route %{get "#{file_name}/#{action}"}
#end
end
NOTE: This trick will not affect any other rails application in your system