Class: MailboxGem::MessagesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- MailboxGem::MessagesController
- Defined in:
- app/controllers/mailbox_gem/messages_controller.rb
Instance Method Summary collapse
- #clear ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
-
#table ⇒ Object
Polled by the auto-refresh Stimulus controller - same data as #index, rendered without the surrounding page so it can replace just the table.
Instance Method Details
#clear ⇒ Object
24 25 26 27 |
# File 'app/controllers/mailbox_gem/messages_controller.rb', line 24 def clear Store.clear redirect_to end |
#index ⇒ Object
3 4 5 6 |
# File 'app/controllers/mailbox_gem/messages_controller.rb', line 3 def index @query = params[:q].presence @messages = end |
#show ⇒ Object
17 18 19 20 21 22 |
# File 'app/controllers/mailbox_gem/messages_controller.rb', line 17 def show @message = Store.find(params[:id]) return head :not_found unless @message @view = params[:view].presence || (@message.html_body ? "html" : "text") end |
#table ⇒ Object
Polled by the auto-refresh Stimulus controller - same data as #index, rendered without the surrounding page so it can replace just the table. Takes the same q param so a poll mid-search stays scoped to it instead of silently reverting to the unfiltered list.
12 13 14 15 |
# File 'app/controllers/mailbox_gem/messages_controller.rb', line 12 def table @query = params[:q].presence render partial: "table", locals: { messages: , query: @query } end |