Class: Messaged::RoomsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Messaged::RoomsController
- Defined in:
- app/controllers/messaged/rooms_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
23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/messaged/rooms_controller.rb', line 23 def create @room = Room.new(room_params) if @room.save respond_to do |format| format.html { redirect_to @room } end else render :new, status: :unprocessable_entity end end |
#destroy ⇒ Object
44 45 46 47 48 49 50 |
# File 'app/controllers/messaged/rooms_controller.rb', line 44 def destroy @room.destroy respond_to do |format| format.turbo_stream { render turbo_stream: turbo_stream.remove(@room) } format.html { redirect_to rooms_url } end end |
#edit ⇒ Object
34 |
# File 'app/controllers/messaged/rooms_controller.rb', line 34 def edit; end |
#index ⇒ Object
6 7 8 |
# File 'app/controllers/messaged/rooms_controller.rb', line 6 def index @rooms = Room.all end |
#new ⇒ Object
16 17 18 19 20 21 |
# File 'app/controllers/messaged/rooms_controller.rb', line 16 def new @room = Room.new @recipient = Messaged.user_class.find(params[:recipient]) if params.dig(:recipient) return unless && .class != Messaged::NullUser @room = .rooms.build end |
#show ⇒ Object
10 11 12 13 14 |
# File 'app/controllers/messaged/rooms_controller.rb', line 10 def show @new_message = Message.new return unless && .class != Messaged::NullUser @new_message = ..build end |
#update ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/controllers/messaged/rooms_controller.rb', line 36 def update if @room.update(room_params) render @room else render :edit, status: :unprocessable_entity end end |