-
-
Notifications
You must be signed in to change notification settings - Fork 512
/
Copy path5-2.rb
109 lines (87 loc) · 2.49 KB
/
5-2.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
ActiveRecord::Schema.define do
create_table "active_storage_attachments", force: :cascade do |t|
t.string "name", null: false
t.string "record_type", null: false
t.integer "record_id", null: false
t.integer "blob_id", null: false
t.datetime "created_at", null: false
t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id"
t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true
end
create_table "active_storage_blobs", force: :cascade do |t|
t.string "key", null: false
t.string "filename", null: false
t.string "content_type"
t.text "metadata"
t.string "service_name"
t.bigint "byte_size", null: false
t.string "checksum", null: false
t.datetime "created_at", null: false
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
end
create_table "active_storage_variant_records", force: :cascade do |t|
t.integer "blob_id", null: false
t.string "variation_digest", null: false
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
end
create_table :posts, force: true do |t|
end
create_table :comments, force: true do |t|
t.integer :post_id
end
end
class Post < ActiveRecord::Base
has_many :comments
has_one_attached :cover
end
class Comment < ActiveRecord::Base
belongs_to :post
end
class PostsController < ActionController::Base
def index
Post.all.to_a
raise "foo"
end
def show
p = Post.find(params[:id])
render plain: p.id
end
def attach
p = Post.find(params[:id])
attach_params = {
io: File.open(File.join(Rails.root, 'public', 'sentry-logo.png')),
filename: 'sentry-logo.png'
}
p.cover.attach(attach_params)
render plain: p.id
end
end
class HelloController < ActionController::Base
def exception
raise "An unhandled exception!"
end
def reporting
render plain: Sentry.last_event_id
end
def view_exception
render inline: "<%= foo %>"
end
def view
render template: "test_template"
end
def world
render plain: "Hello World!"
end
def with_custom_instrumentation
custom_event = "custom.instrument"
ActiveSupport::Notifications.subscribe(custom_event) do |*args|
data = args[-1]
data += 1
end
ActiveSupport::Notifications.instrument(custom_event, 1)
head :ok
end
def not_found
raise ActionController::BadRequest
end
end