Class: Rails::Generator::Commands::Create
- Inherits:
-
Object
- Object
- Rails::Generator::Commands::Create
- Defined in:
- lib/generators/content/content_generator.rb
Instance Method Summary collapse
Instance Method Details
#create_factory ⇒ Object
5 6 7 8 9 |
# File 'lib/generators/content/content_generator.rb', line 5 def create_factory template = File.read(source_path('factories.rb')) source_to_update = ERB.new(template, nil, '-').result(binding) File.open('test/factories.rb', 'a') { |file| file.write("\n\n#{source_to_update}") } end |
#route_namespaced_resources(resource) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/generators/content/content_generator.rb', line 10 def route_namespaced_resources(resource) sentinel = "cms.namespace :admin, :path_prefix => '' do |admin|" logger.route "admin.resources #{resource}" unless [:pretend] gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n\t\t\tadmin.resources :#{resource}, :collection => [:sort], :only => [:new, :create, :update, :edit, :destroy]" end end end |