Class: DiscussionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- DiscussionsController
- Defined in:
- app/controllers/discussions_controller.rb
Direct Known Subclasses
Instance Method Summary collapse
- #create ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #responsible ⇒ Object
- #show ⇒ Object
- #subscription ⇒ Object
- #update ⇒ Object
- #upvote ⇒ Object
Methods included from Mumuki::Laboratory::Controllers::Content
Methods inherited from ApplicationController
#current_immersive_organizations, #current_immersive_path, #current_immersive_path_for, #current_workspace, #immersive_context_wrong?, #login_button, #redirect_to_proper_context!, #redirect_to_usage, #should_choose_organization?, #validate_accessible!, #validate_active_organization!
Methods included from Mumuki::Laboratory::Controllers::ActionRedirector
#redirect_after!, #save_location_before!
Methods included from Mumuki::Laboratory::Controllers::IncognitoMode
#current_incognito_user?, #current_logged_user?, #current_user, #current_user?, #incognito_mode_enabled?
Methods included from Mumuki::Laboratory::Controllers::EmbeddedMode
#embedded_mode?, #enable_embedded_rendering, #standalone_mode?
Methods included from Mumuki::Laboratory::Controllers::DynamicErrors
#bad_record, #blocked_forum, #disabled, #disabled_organization, #forbidden, #gone, #internal_server_error, #not_found, #render_error, #unauthorized, #unprepared_organization
Methods included from Mumuki::Laboratory::Controllers::Notifications
#has_notifications?, #notifications_count, #user_notifications
Methods included from Mumuki::Laboratory::Controllers::Authorization
#authorization_slug, #authorize_if_private!
Methods included from Mumuki::Laboratory::Controllers::CurrentOrganization
#organization_name, #set_current_organization!, #visit_organization!
Instance Method Details
#create ⇒ Object
57 58 59 60 |
# File 'app/controllers/discussions_controller.rb', line 57 def create discussion = @debatable.discuss! current_user, discussion_params redirect_to [@debatable, discussion] end |
#index ⇒ Object
14 15 16 17 |
# File 'app/controllers/discussions_controller.rb', line 14 def index @discussions = current_content_discussions.for_user(current_user) @filtered_discussions = @discussions.scoped_query_by(discussion_filter_params) end |
#new ⇒ Object
19 20 21 |
# File 'app/controllers/discussions_controller.rb', line 19 def new @discussion = @debatable.new_discussion_for current_user end |
#responsible ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/discussions_controller.rb', line 41 def responsible subject.with_pg_lock proc { if subject.can_toggle_responsible? current_user subject.toggle_responsible! current_user set_flash_responsible_confirmation! status = :ok else set_flash_responsible_alert! status = :conflict end render :partial => 'layouts/toast', status: status } end |
#show ⇒ Object
23 24 |
# File 'app/controllers/discussions_controller.rb', line 23 def show end |
#subscription ⇒ Object
31 32 33 34 |
# File 'app/controllers/discussions_controller.rb', line 31 def subscription current_user&.toggle_subscription!(subject) head :ok end |
#update ⇒ Object
26 27 28 29 |
# File 'app/controllers/discussions_controller.rb', line 26 def update subject.update_status! params[:status], current_user redirect_to [@debatable, subject], notice: I18n.t(:discussion_updated) end |
#upvote ⇒ Object
36 37 38 39 |
# File 'app/controllers/discussions_controller.rb', line 36 def upvote current_user&.toggle_upvote!(subject) head :ok end |