14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/generators/scaffold_plus/force_ssl/force_ssl_generator.rb', line 14
def update_controller
file = "app/controllers/#{table_name}_controller.rb"
inject_into_file file, after: /^class.*ApplicationController$/ do
text = "\n force_ssl if: :ssl_configured?"
text << ", only: [#{only_list}]" if options.only_for.present?
text << ", except: [#{except_list}]" if options.except_for.present?
text
end
inject_into_file file, after: /private$/ do
[
"",
" # When to enforce SSL for this controller",
" def ssl_configured?",
" Rails.env.production?",
" end",
"",
""
].join("\n")
end
end
|