raport 0.1.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/images/raport/ajax-loader.gif +0 -0
  6. data/app/controllers/module Raport/nraport/application_controller.rb" +4 -0
  7. data/app/helpers/raport/application_helper.rb +9 -0
  8. data/app/jobs/raport/reports_job.rb +10 -0
  9. data/app/models/raport/report.rb +248 -0
  10. data/app/models/raport.rb +5 -0
  11. data/app/services/raport/report/renderer.rb +64 -0
  12. data/app/uploaders/raport/file_uploader.rb +27 -0
  13. data/config/locales/de.yml +27 -0
  14. data/config/routes.rb +2 -0
  15. data/db/migrate/20151022084502_create_raport_reports.rb +18 -0
  16. data/lib/raport/concerns/controllers/reportify.rb +62 -0
  17. data/lib/raport/engine.rb +19 -0
  18. data/lib/raport/gem_version.rb +14 -0
  19. data/lib/raport/version.rb +7 -0
  20. data/lib/raport.rb +4 -0
  21. data/lib/tasks/raport_tasks.rake +4 -0
  22. data/test/dummy/README.rdoc +28 -0
  23. data/test/dummy/Rakefile +6 -0
  24. data/test/dummy/app/assets/javascripts/application.js +13 -0
  25. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  26. data/test/dummy/app/controllers/application_controller.rb +5 -0
  27. data/test/dummy/app/helpers/application_helper.rb +2 -0
  28. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/test/dummy/bin/bundle +3 -0
  30. data/test/dummy/bin/rails +4 -0
  31. data/test/dummy/bin/rake +4 -0
  32. data/test/dummy/bin/setup +29 -0
  33. data/test/dummy/config/application.rb +26 -0
  34. data/test/dummy/config/boot.rb +5 -0
  35. data/test/dummy/config/database.yml +25 -0
  36. data/test/dummy/config/environment.rb +5 -0
  37. data/test/dummy/config/environments/development.rb +41 -0
  38. data/test/dummy/config/environments/production.rb +79 -0
  39. data/test/dummy/config/environments/test.rb +42 -0
  40. data/test/dummy/config/initializers/assets.rb +11 -0
  41. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  42. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  43. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  44. data/test/dummy/config/initializers/inflections.rb +16 -0
  45. data/test/dummy/config/initializers/mime_types.rb +4 -0
  46. data/test/dummy/config/initializers/session_store.rb +3 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +23 -0
  49. data/test/dummy/config/routes.rb +56 -0
  50. data/test/dummy/config/secrets.yml +22 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/db/schema.rb +34 -0
  53. data/test/dummy/public/404.html +67 -0
  54. data/test/dummy/public/422.html +67 -0
  55. data/test/dummy/public/500.html +66 -0
  56. data/test/dummy/public/favicon.ico +0 -0
  57. data/test/fixtures/raport/reports.yml +11 -0
  58. data/test/integration/navigation_test.rb +10 -0
  59. data/test/models/raport/report_test.rb +7 -0
  60. data/test/raport_test.rb +7 -0
  61. data/test/test_helper.rb +19 -0
  62. metadata +247 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c2924d1fab1b2f7bacc642f5c9fa2c80fa8e2f2a
4
+ data.tar.gz: f148c28cf17d07a2b44e23da21dd08ddc48b7ff9
5
+ SHA512:
6
+ metadata.gz: c834f1e09bd1a6f81d22f842d5321a0c7f45479b28a0a4d87acabdb31cf59a6438b0dc4f24c2426731de6ed0575bd57f568ae52d080edd74052d51da31acc440
7
+ data.tar.gz: 515453848901845411dc4a26ef0b52357ee5706e6b9c4277c67c136c5d53d0bb925ab5d4dedab8529338bea16588e1183f80e73b872afe055d88ec157392b478
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Dominic Breuker
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Raport
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'Raport'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,4 @@
1
+ module Raport
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Raport
2
+ module ApplicationHelper
3
+
4
+ def link_to_report(format = :csv, html_options = nil, &block)
5
+ html_options.kind_of?(Hash) ? html_options.deep_merge!(data: { report: true }) : html_options = { data: { report: true } }
6
+ link_to ['.', format].join, url_for(params.merge(format: format)), html_options, &block
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ module Raport
2
+ class ReportsJob < ActiveJob::Base
3
+
4
+ def perform(report)
5
+ I18n.with_locale(report.locale) do
6
+ Raport::Report::Renderer.new(report).render
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,248 @@
1
+ module Raport
2
+ class Report < ActiveRecord::Base
3
+
4
+ #
5
+ # Constants
6
+ # ---------------------------------------------------------------------------------------
7
+ #
8
+ #
9
+ #
10
+ #
11
+
12
+ #
13
+ # Attribute Settings
14
+ # ---------------------------------------------------------------------------------------
15
+ #
16
+ #
17
+ #
18
+ #
19
+
20
+ store :query, accessors: [:joins, :where, :select]
21
+
22
+ #
23
+ # Plugins
24
+ # ---------------------------------------------------------------------------------------
25
+ #
26
+ #
27
+ #
28
+ #
29
+
30
+ mount_uploader :file, FileUploader
31
+
32
+ #
33
+ # Concerns
34
+ # ---------------------------------------------------------------------------------------
35
+ #
36
+ #
37
+ #
38
+ #
39
+
40
+ #
41
+ # Scopes
42
+ # ---------------------------------------------------------------------------------------
43
+ #
44
+ #
45
+ #
46
+ #
47
+
48
+ #
49
+ # State Machine
50
+ # ---------------------------------------------------------------------------------------
51
+ #
52
+ #
53
+ #
54
+ #
55
+
56
+ state_machine :state, initial: :pending do
57
+ state :pending
58
+ state :active
59
+ state :finished do
60
+ validates :file, presence: true
61
+ end
62
+ state :failed
63
+
64
+ event :pend do
65
+ transition all => :pending
66
+ end
67
+
68
+ after_transition on: :pend do |report, transition|
69
+ report.enqueue!
70
+ end
71
+
72
+ event :activate do
73
+ transition pending: :active
74
+ end
75
+
76
+ event :finish do
77
+ transition [:active, :failed] => :finished
78
+ end
79
+
80
+ event :flop do
81
+ transition active: :failed
82
+ end
83
+ end
84
+
85
+ #
86
+ # Scopes
87
+ # ---------------------------------------------------------------------------------------
88
+ #
89
+ #
90
+ #
91
+ #
92
+
93
+ state_machine.states.each { |state| scope state.name, -> { where(state: state.name.to_s) } }
94
+
95
+ scope :by_name, -> (name) { where(name: name) }
96
+ scope :by_user, -> (user) { where(user_type: user.class.name, user_id: user.id) }
97
+ scope :active, -> { where(state: [:pending, :activated]) }
98
+ scope :pendable, -> { where(state: [:finished, :flop]) }
99
+ scope :daily, -> { by_name(:daily) }
100
+
101
+ #
102
+ # Associations
103
+ # ---------------------------------------------------------------------------------------
104
+ #
105
+ #
106
+ #
107
+ #
108
+
109
+ belongs_to :user, polymorphic: true, class_name: ::Admin
110
+
111
+ #
112
+ # Nested Attributes
113
+ # ---------------------------------------------------------------------------------------
114
+ #
115
+ #
116
+ #
117
+ #
118
+
119
+ #
120
+ # Validations
121
+ # ---------------------------------------------------------------------------------------
122
+ #
123
+ #
124
+ #
125
+ #
126
+
127
+ validates :name, :query, :resource_class_name, :template, :user_id, :action_name, presence: true
128
+
129
+ #
130
+ # Callbacks
131
+ # ---------------------------------------------------------------------------------------
132
+ #
133
+ #
134
+ #
135
+ #
136
+
137
+ before_validation :set_name, on: :create
138
+
139
+ after_create :enqueue!
140
+
141
+ #
142
+ # Delegates
143
+ # ---------------------------------------------------------------------------------------
144
+ #
145
+ #
146
+ #
147
+ #
148
+
149
+ delegate :email, to: :user, allow_nil: true
150
+
151
+ #
152
+ # Instance Methods
153
+ # ---------------------------------------------------------------------------------------
154
+ #
155
+ #
156
+ #
157
+ #
158
+
159
+ def perform!
160
+ ReportJob.new(id).perform
161
+ end
162
+
163
+ def enqueue!
164
+ ReportsJob.perform_later(self)
165
+ end
166
+
167
+ def template_path
168
+ @template_path ||= File.path(template).gsub('app/views', '').split('.').first
169
+ end
170
+
171
+ def format
172
+ @format ||= template.scan(/\.(.*?)\./).first.first.to_sym
173
+ end
174
+
175
+ def collection
176
+ @collection ||= begin
177
+ query = select.present? ? resource_class.select(*select) : resource_class
178
+ query = query.joins(*joins) if joins.any?
179
+ query = query.where(where) if where.present?
180
+ query.uniq
181
+ end
182
+ end
183
+
184
+ def resource_class
185
+ @resource_class ||= resource_class_name.constantize
186
+ end
187
+
188
+ def default_filename
189
+ [I18n.l(Time.zone.now, format: :dashed), action_name ? resource_class.human_attribute_name(action_name) : nil, resource_class.model_name.human(count: :other)].join('-')
190
+ end
191
+
192
+ def filename
193
+ @filename ||= [name || default_filename, format].join('.').gsub('.csv.csv', '.csv')
194
+ end
195
+
196
+ def tmp_filename
197
+ @tmp_filename ||= [filename, tmp_file_identifier].join('.')
198
+ end
199
+
200
+ def tmp_file_identifier
201
+ 'tempfile'
202
+ end
203
+
204
+ def permalink(format = nil)
205
+ [Rails.application.routes.url_helpers.admin_report_path(self.to_param, locale: I18n.locale), format].compact.join('.')
206
+ end
207
+
208
+ def status_css_classes
209
+ Admin::BaseController.helpers.status_css_class(state).join(' ')
210
+ end
211
+
212
+ def display_status_name
213
+ self.class.human_state_name(state)
214
+ end
215
+
216
+ #
217
+ # Class Methods
218
+ # ---------------------------------------------------------------------------------------
219
+ #
220
+ #
221
+ #
222
+ #
223
+
224
+ #
225
+ # Protected
226
+ # ---------------------------------------------------------------------------------------
227
+ #
228
+ #
229
+ #
230
+ #
231
+
232
+ protected
233
+
234
+ #
235
+ # Private
236
+ # ---------------------------------------------------------------------------------------
237
+ #
238
+ #
239
+ #
240
+ #
241
+
242
+ private
243
+
244
+ def set_name
245
+ self.name = filename unless name
246
+ end
247
+ end
248
+ end
@@ -0,0 +1,5 @@
1
+ module Raport
2
+ def self.table_name_prefix
3
+ 'raport_'
4
+ end
5
+ end
@@ -0,0 +1,64 @@
1
+ module Raport
2
+ class Report
3
+ class Renderer
4
+
5
+ attr_accessor :report
6
+
7
+ attr_reader :tmpfile, :view
8
+
9
+ def initialize(report)
10
+ @report = report
11
+ @view ||= begin
12
+ view = ActionView::Base.new
13
+ view.view_paths = ActionController::Base.view_paths
14
+ view.extend ApplicationHelper
15
+ view
16
+ end
17
+ @tmpfile ||= begin
18
+ tmpfile = Tempfile.new(report.tmp_filename)
19
+ tmpfile.write(render_view)
20
+ tmpfile
21
+ end
22
+ end
23
+
24
+ def render
25
+ begin
26
+ report.activate
27
+ report.file = tmpfile
28
+ report.finish
29
+ rescue => e
30
+ report.last_error = [e.message, e.backtrace.join("\n")].join("\n")
31
+ report.flop
32
+ raise
33
+ ensure
34
+ tmpfile.close
35
+
36
+ case tmpfile.class.name
37
+ when 'Tempfile' then tmpfile.unlink
38
+ when 'File' then File.unlink(tmpfile.path)
39
+ end
40
+ end
41
+ end
42
+
43
+ private
44
+
45
+ def view_attributes
46
+ view_attributes = {
47
+ layout: false,
48
+ formats: [report.format],
49
+ template: report.template_path,
50
+ locals: {
51
+ collection: report.collection,
52
+ resource_class: report.resource_class,
53
+ params: {}
54
+ }
55
+ }
56
+ end
57
+
58
+ def render_view
59
+ view.render(view_attributes)
60
+ end
61
+
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,27 @@
1
+ class Raport::FileUploader < CarrierWave::Uploader::Base
2
+
3
+ include CarrierWave::MiniMagick
4
+
5
+ storage Settings.carrierwave.storage
6
+
7
+ def store_dir
8
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
9
+ end
10
+
11
+ process :set_content_type
12
+
13
+ def set_content_type
14
+ new_content_type = 'binary/octet-stream'
15
+
16
+ if file.respond_to?(:content_type=)
17
+ file.content_type = new_content_type
18
+ else
19
+ file.instance_variable_set(:@content_type, new_content_type)
20
+ end
21
+ end
22
+
23
+ def filename
24
+ model.respond_to?(:filename) ? model.filename : super
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ raport/report:
5
+ one: Bericht
6
+ other: Berichte
7
+ attributes:
8
+ raport/report:
9
+ name: Name
10
+ state: Status
11
+ file: Datei
12
+ user_id: Besitzer
13
+ created_at: angelegt
14
+ state_machines:
15
+ states:
16
+ active: aktiv
17
+ pending: wartend
18
+ finished: fertig
19
+ failed: gescheitert
20
+ events:
21
+ pend: Starten
22
+ activate: Aktivieren
23
+ finish: Beenden
24
+ flop: Abbrechen
25
+ time:
26
+ formats:
27
+ dashed: "%d-%m-%Y-%H-%M-%S"
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Rails.application.routes.draw do
2
+ end
@@ -0,0 +1,18 @@
1
+ class CreateRaportReports < ActiveRecord::Migration
2
+ def change
3
+ create_table :raport_reports do |t|
4
+ t.string :name
5
+ t.string :state
6
+ t.string :resource_class_name
7
+ t.string :file
8
+ t.string :locale
9
+ t.text :query, limit: 16777215
10
+ t.string :template
11
+ t.string :action_name
12
+ t.references :user, polymorphic: true, index: true
13
+ t.datetime :invalid_at
14
+
15
+ t.timestamps null: true
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,62 @@
1
+ module Raport
2
+ module Reportify
3
+ extend ActiveSupport::Concern
4
+
5
+ # TODO move this to configuration
6
+ REPORTABLE_FORMATS = [:csv]
7
+
8
+ included do
9
+ helper_method :report_attributes
10
+
11
+ respond_to *REPORTABLE_FORMATS, :html
12
+
13
+ report only: :index
14
+ end
15
+
16
+ def create_report
17
+ if REPORTABLE_FORMATS.include?(request.format.to_sym)
18
+ @report = current_admin.reports.create(report_attributes)
19
+
20
+ respond_to do |format|
21
+ format.any do
22
+ if request.xhr?
23
+ render json: @report.errors.empty? ? @report.as_json(methods: :permalink) : { errors: @report.errors }.to_json
24
+ else
25
+ redirect_to polymorphic_path([current_namespace, @report])
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+
32
+ protected
33
+
34
+ def report_attributes
35
+ {
36
+ action_name: action_name,
37
+ select: collection.select_values,
38
+ joins: collection.joins_values,
39
+ where: formatted_sql_values(collection.where_values),
40
+ resource_class_name: resource_class.name,
41
+ template: current_template,
42
+ locale: I18n.locale
43
+ }
44
+ end
45
+
46
+ private
47
+
48
+ def formatted_sql_values(values)
49
+ values.kind_of?(Array) ? values.map { |value| value.respond_to?(:to_sql) ? value.to_sql : value }.join(' AND ') : nil
50
+ end
51
+
52
+ def current_template
53
+ lookup_context.find(action_name, lookup_context.prefixes, false, [], formats: [request.format.to_sym]).inspect
54
+ end
55
+
56
+ class_methods do
57
+ def report(options = {}, &block)
58
+ before_action :create_report, options, &block
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,19 @@
1
+ require 'raport/concerns/controllers/reportify'
2
+
3
+ module Raport
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace Raport
6
+
7
+ config.to_prepare do
8
+ ApplicationController.helper(Raport::ApplicationHelper)
9
+ end
10
+
11
+ initializer :append_migrations do |app|
12
+ unless app.root.to_s.match root.to_s
13
+ config.paths["db/migrate"].expanded.each do |expanded_path|
14
+ app.config.paths["db/migrate"] << expanded_path
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,14 @@
1
+ module Raport
2
+ def self.gem_version
3
+ Gem::Version.new VERSION::STRING
4
+ end
5
+
6
+ module VERSION
7
+ MAJOR = 0
8
+ MINOR = 1
9
+ TINY = 1
10
+ PRE = 'pre'
11
+
12
+ STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
13
+ end
14
+ end
@@ -0,0 +1,7 @@
1
+ require_relative 'gem_version'
2
+
3
+ module Raport
4
+ def self.version
5
+ gem_version
6
+ end
7
+ end
data/lib/raport.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "raport/engine"
2
+
3
+ module Raport
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :raport do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end