Class: Messaged::MessagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Messaged::MessagesController
- Defined in:
- app/controllers/messaged/messages_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/controllers/messaged/messages_controller.rb', line 21 def create @message = Message.new() if @message.save if && .class != Messaged::NullUser @new_message = ..build else @new_message = Message.new end respond_to do |format| format.turbo_stream do render turbo_stream: turbo_stream.append(:messages, partial: "messaged/messages/message", locals: { message: @message }) end format.html { redirect_to } end else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
51 52 53 54 55 56 57 |
# File 'app/controllers/messaged/messages_controller.rb', line 51 def destroy @message.destroy respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(@message) } format.html { redirect_to } end end |
#edit ⇒ Object
41 |
# File 'app/controllers/messaged/messages_controller.rb', line 41 def edit; end |
#index ⇒ Object
6 7 8 9 10 11 |
# File 'app/controllers/messaged/messages_controller.rb', line 6 def index @messages = Message.all @new_message = Message.new return unless && .class != Messaged::NullUser @new_message = ..build end |
#new ⇒ Object
15 16 17 18 19 |
# File 'app/controllers/messaged/messages_controller.rb', line 15 def new @message = Message.new return unless && .class != Messaged::NullUser @message = ..build end |
#show ⇒ Object
13 |
# File 'app/controllers/messaged/messages_controller.rb', line 13 def show; end |
#update ⇒ Object
43 44 45 46 47 48 49 |
# File 'app/controllers/messaged/messages_controller.rb', line 43 def update if @message.update() render @message else render :edit, status: :unprocessable_entity end end |