Class: Arpa::Generators::ControllersGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/arpa/controllers_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_controllersObject



27
28
29
30
31
# File 'lib/generators/arpa/controllers_generator.rb', line 27

def add_controllers
  copy_file 'controllers/resources_controller.rb', 'app/controllers/arpa/resources_controller.rb'
  copy_file 'controllers/roles_controller.rb', 'app/controllers/arpa/roles_controller.rb'
  copy_file 'controllers/profiles_controller.rb', 'app/controllers/arpa/profiles_controller.rb'
end

#add_routesObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/arpa/controllers_generator.rb', line 33

def add_routes
  route <<~RUBY
    scope module: :arpa do
        resources :resources do
          collection do
            get 'generate_resources_and_actions'
          end
        end

        resources :roles do
          collection do
            delete ':id', to: 'roles#remove'
          end
        end

        resources :profiles do
          collection do
            delete ':id', to: 'profiles#remove'
          end
        end
      end
  RUBY
end

#copy_resources_views_filesObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/arpa/controllers_generator.rb', line 6

def copy_resources_views_files
  copy_file 'views/resources/index.html.erb', 'app/views/arpa/resources/index.html.erb'
  copy_file 'views/resources/show.html.erb', 'app/views/arpa/resources/show.html.erb'

  copy_file 'views/roles/index.html.erb', 'app/views/arpa/roles/index.html.erb'
  copy_file 'views/roles/show.html.erb', 'app/views/arpa/roles/show.html.erb'
  copy_file 'views/roles/new.html.erb', 'app/views/arpa/roles/new.html.erb'
  copy_file 'views/roles/edit.html.erb', 'app/views/arpa/roles/edit.html.erb'
  copy_file 'views/roles/_form.html.erb', 'app/views/arpa/roles/_form.html.erb'

  copy_file 'views/profiles/index.html.erb', 'app/views/arpa/profiles/index.html.erb'
  copy_file 'views/profiles/show.html.erb', 'app/views/arpa/profiles/show.html.erb'
  copy_file 'views/profiles/new.html.erb', 'app/views/arpa/profiles/new.html.erb'
  copy_file 'views/profiles/edit.html.erb', 'app/views/arpa/profiles/edit.html.erb'
  copy_file 'views/profiles/_form.html.erb', 'app/views/arpa/profiles/_form.html.erb'
end

#copy_stylesheet_filesObject



23
24
25
# File 'lib/generators/arpa/controllers_generator.rb', line 23

def copy_stylesheet_files
  copy_file 'assets/stylesheets/arpa_accordion.scss', 'app/assets/stylesheets/arpa/arpa_accordion.scss'
end