class Tree::TreeGenerator
Public Instance Methods
add_acts_as_tree_to_model()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 15 def add_acts_as_tree_to_model if behavior.to_s == "invoke" inject_into_file "app/models/#{file_name}.rb", :after=>"ActiveRecord::Base\n" do <<-'TREE' acts_as_tree TREE end end end
add_resources_to_routes()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 37 def add_resources_to_routes if behavior.to_s == "invoke" inject_into_file "config/routes.rb", :after=>"Rails.application.routes.draw do\n" do " resources :#{file_name.pluralize} " end end end
controller_template()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 24 def controller_template template "controller.rb", "app/controllers/#{file_name.pluralize}_controller.rb" end
create_initializer()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 5 def create_initializer copy_file "init.rb", init_file unless File.file? init_file end
migration()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 9 def migration args.unshift('title:string') @args = args Rails::Generators.invoke('model', [file_name, args, '-s'], {:behavior=>behavior}) end
view_templates()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 28 def view_templates template "views/index.html.erb", "app/views/#{file_name.pluralize}/index.html.erb" template "views/show.html.erb", "app/views/#{file_name.pluralize}/show.html.erb" template "views/edit.html.erb", "app/views/#{file_name.pluralize}/edit.html.erb" template "views/new.html.erb", "app/views/#{file_name.pluralize}/new.html.erb" template "views/_list.html.erb", "app/views/#{file_name.pluralize}/_list.html.erb" template "views/_form.html.erb", "app/views/#{file_name.pluralize}/_form.html.erb" end
Private Instance Methods
init_file()
click to toggle source
# File lib/generators/tree/tree_generator.rb, line 47 def init_file "config/initializers/mpt_tree.rb" end