Sha256: 227a61197446d41d7d861efe880f9f8db4f74a7da0cb74538aafd12f9d098954

Contents?: true

Size: 698 Bytes

Versions: 131

Compression:

Stored size: 698 Bytes

Contents

class MessagesController < AjaxController
  before_action :set_exercise!, only: [:create, :read_messages]

  def index
    render json: {has_messages: has_messages?, messages_count: messages_count}
  end

  def read_messages
    @exercise.messages_for(current_user).read_all!
    index
  end

  def create
    @exercise.submit_question! current_user, message_params
    redirect_to @exercise
  end

  def errors
    render 'messages/errors', layout: false
  end

  private

  def set_exercise!
    exercise_id = params.dig(:message, :exercise_id) || params[:exercise_id]
    @exercise = Exercise.find(exercise_id)
  end

  def message_params
    params.require(:message).permit(:content)
  end
end

Version data entries

131 entries across 131 versions & 1 rubygems

Version Path
mumuki-laboratory-9.8.2 app/controllers/messages_controller.rb
mumuki-laboratory-9.8.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.8.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.7.2 app/controllers/messages_controller.rb
mumuki-laboratory-9.7.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.7.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.6.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.5.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.5.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.4.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.4.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.3.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.3.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.2.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.1.3 app/controllers/messages_controller.rb
mumuki-laboratory-9.1.2 app/controllers/messages_controller.rb
mumuki-laboratory-9.1.1 app/controllers/messages_controller.rb
mumuki-laboratory-9.1.0 app/controllers/messages_controller.rb
mumuki-laboratory-9.0.6 app/controllers/messages_controller.rb
mumuki-laboratory-9.0.5 app/controllers/messages_controller.rb