Create a controller via a script .rb


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


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’[‘controller’,‘dil’])


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