halvor
(halvor)
1
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
halvor
(halvor)
2
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