Create a controller via a script .rb

Hello,

this should be a straightfoward question.
I was wondering how to do the equivalent of :
ruby script/generate controller MyNewController

from within a .rb file.
I would then want to call the .rb script from my rails application.
Thanks in advance

Hal

Solution :
#!/usr/bin/env ruby
class X
def test2
require File.dirname(FILE) + ‘/…/config/boot’

require “#{RAILS_ROOT}/config/environment”
require ‘rails_generator’
require ‘rails_generator/scripts/generate’

Rails::Generator::Scripts::Generate.new.run([‘controller’,‘dil’])

end
end

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs