Class: SimplePrivateMessages::Generators::ScaffoldGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/simple_private_messages/scaffold/scaffold_generator.rb

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Instance Attribute Details

- (Object) plural_camel_case_name (readonly)

Returns the value of attribute plural_camel_case_name



11
12
13
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 11

def plural_camel_case_name
  @plural_camel_case_name
end

- (Object) plural_camel_case_parent (readonly)

Returns the value of attribute plural_camel_case_parent



12
13
14
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 12

def plural_camel_case_parent
  @plural_camel_case_parent
end

- (Object) plural_lower_case_name (readonly)

Returns the value of attribute plural_lower_case_name



11
12
13
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 11

def plural_lower_case_name
  @plural_lower_case_name
end

- (Object) plural_lower_case_parent (readonly)

Returns the value of attribute plural_lower_case_parent



12
13
14
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 12

def plural_lower_case_parent
  @plural_lower_case_parent
end

- (Object) singular_camel_case_name (readonly)

Returns the value of attribute singular_camel_case_name



11
12
13
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 11

def singular_camel_case_name
  @singular_camel_case_name
end

- (Object) singular_camel_case_parent (readonly)

Returns the value of attribute singular_camel_case_parent



12
13
14
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 12

def singular_camel_case_parent
  @singular_camel_case_parent
end

- (Object) singular_lower_case_name (readonly)

Returns the value of attribute singular_lower_case_name



11
12
13
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 11

def singular_lower_case_name
  @singular_lower_case_name
end

- (Object) singular_lower_case_parent (readonly)

Returns the value of attribute singular_lower_case_parent



12
13
14
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 12

def singular_lower_case_parent
  @singular_lower_case_parent
end

Class Method Details

+ (Object) source_root



14
15
16
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 14

def self.source_root
   	File.join(File.dirname(__FILE__), 'templates')
end

Instance Method Details

- (Object) go



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/generators/simple_private_messages/scaffold/scaffold_generator.rb', line 18

def go
  @singular_camel_case_name = message_model_name.singularize.camelize
  @plural_camel_case_name = message_model_name.pluralize.camelize
  @singular_lower_case_name = message_model_name.singularize.underscore
  @plural_lower_case_name = message_model_name.pluralize.underscore

  @singular_camel_case_parent = user_model_name.singularize.camelize
  @plural_camel_case_parent = user_model_name.pluralize.camelize
  @singular_lower_case_parent = user_model_name.singularize.underscore
  @plural_lower_case_parent = user_model_name.pluralize.underscore    

  route("resources :#{@plural_lower_case_parent} do
           resources :#{@plural_lower_case_name} do
             collection do
               post :delete_selected
             end
           end
         end")

    #directory "app/controllers"
    template "controller.rb", "app/controllers/#{@plural_lower_case_name}_controller.rb"

    #directory "app/views"
    #directory "app/views/#{@plural_lower_case_name}"
    template "view_index.html.erb", "app/views/#{@plural_lower_case_name}/index.html.erb"
    template "view_index_inbox.html.erb", "app/views/#{@plural_lower_case_name}/_inbox.html.erb"
    template "view_index_sent.html.erb", "app/views/#{@plural_lower_case_name}/_sent.html.erb"
    template "view_show.html.erb", "app/views/#{@plural_lower_case_name}/show.html.erb"
    template "view_new.html.erb", "app/views/#{@plural_lower_case_name}/new.html.erb"
end