Class: Mastiff::ViewsGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/mastiff/views/views_generator.rb

Overview

class UploaderGenerator < Rails::Generators::NamedBase

Instance Method Summary collapse

Instance Method Details

#copy_viewsObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/generators/mastiff/views/views_generator.rb', line 39

def copy_views
  insert_into_file "app/assets/stylesheets/application.css.scss", :before => "*/" do
     "\n *= require 'emails'\n\n"
  end
  insert_into_file "app/assets/javascripts/application.js", :before => "*/" do
     "\n *= require 'emails'\n\n"
   end
  template "emails.js.coffee", "app/assets/javascripts/emails.js.coffee"
  template "emails.css.scss", "app/assets/stylesheets/emails.css.scss"
  template "emails_controller.rb", "app/controllers/emails_controller.rb"
  directory "emails", "app/views/emails"
end

#create_routesObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/generators/mastiff/views/views_generator.rb', line 17

def create_routes

route_text = "resource :mail, :controller => 'emails', only: [:index] do
     get '/', action: :index
     get 'msg_ids',  format: 'json'
     get 'validity',  format: 'json'
     get 'list', format: 'json'

     # These should be POSTs with no data, but get is easier to use
     get 'reload', format: 'json'
     get 'reset', format: 'json'
     get 'process_inbox', format: 'json'

     # These are posts with data
     post 'remove', format: 'json'
     post 'archive', format: 'json'
     post 'handle_mail', format: 'json'
end"
#TODO, check for existing routes for mail
route route_text
end