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-7.11.1 app/controllers/messages_controller.rb
mumuki-laboratory-7.11.0 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.5 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.4 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.3 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.2 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.1 app/controllers/messages_controller.rb
mumuki-laboratory-7.10.0 app/controllers/messages_controller.rb
mumuki-laboratory-7.9.2 app/controllers/messages_controller.rb
mumuki-laboratory-7.9.1 app/controllers/messages_controller.rb
mumuki-laboratory-7.9.0 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.6 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.5 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.4 app/controllers/messages_controller.rb
mumuki-laboratory-7.8.0 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.3 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.2 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.1 app/controllers/messages_controller.rb
mumuki-laboratory-7.7.0 app/controllers/messages_controller.rb
mumuki-laboratory-7.6.2 app/controllers/messages_controller.rb