Class: Lesli::Items::DiscussionsController
Instance Attribute Summary
#engine_path, #query
Instance Method Summary
collapse
#log
#set_customizer
#respond_with_action, #respond_with_http, #respond_with_json, #respond_with_json_not_found, #respond_with_json_unauthorized, #respond_with_lesli, #respond_with_not_found, #respond_with_pagination, #respond_with_unauthorized, #stream_redirection
#set_locale, #set_requester
#initialize
Instance Method Details
#create ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'app/controllers/lesli/items/discussions_controller.rb', line 49
def create
discussion = discussion_class.new(discussion_params)
discussion.user = current_user
discussion.account = current_user.account
discussion.discussable = @discussable if @discussable
if discussion.save
respond_with_lesli(:turbo => [
stream_notification_success("Discussion created"),
turbo_stream.prepend("#{scope_key}-lesli-items-discussions-list") do
LesliView::Items::Discussion.new(discussion).render_in(view_context)
end
])
else
respond_with_lesli(
:turbo => stream_notification_danger(discussion.errors.full_messages)
)
end
end
|
#index ⇒ Object
39
40
41
42
43
44
|
# File 'app/controllers/lesli/items/discussions_controller.rb', line 39
def index
@discussions = discussion_class
.where(account: current_user.account)
.order(created_at: :desc)
respond_with_lesli(json: @discussions)
end
|
#show ⇒ Object
46
47
|
# File 'app/controllers/lesli/items/discussions_controller.rb', line 46
def show
end
|
#update ⇒ Object
70
71
72
73
74
75
76
77
78
79
|
# File 'app/controllers/lesli/items/discussions_controller.rb', line 70
def update
@discussion.done = true
@discussion.save
respond_with_lesli(:turbo => [
stream_notification_success("Discussion updated #{@discussable}"),
turbo_stream.replace(helpers.dom_id(@discussion, scope_key)) do
LesliView::Items::Discussion.new(@discussion, scope_key).render_in(view_context)
end
])
end
|