Class: Plain::ConversationsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Plain::ConversationsController
- Defined in:
- app/controllers/plain/conversations_controller.rb
Constant Summary collapse
- PER_PAGE =
10
Instance Method Summary collapse
- #allow_iframe_requests ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #pin ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#allow_iframe_requests ⇒ Object
11 12 13 |
# File 'app/controllers/plain/conversations_controller.rb', line 11 def allow_iframe_requests response.headers.delete("X-Frame-Options") end |
#destroy ⇒ Object
47 48 49 50 |
# File 'app/controllers/plain/conversations_controller.rb', line 47 def destroy @conversation = Plain::Conversation.find(params[:id]) @conversation.destroy end |
#edit ⇒ Object
39 40 41 |
# File 'app/controllers/plain/conversations_controller.rb', line 39 def edit @conversation = Plain::Conversation.find(params[:id]) end |
#index ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/plain/conversations_controller.rb', line 15 def index @needs_back = true @conversations = Plain::Conversation.all if @conversations.empty? Plain::Conversation.create end @current_page = params[:page].to_i @next_page = @current_page + 1 @conversations = Plain::Conversation.limit(PER_PAGE) .offset(@current_page * PER_PAGE) .order(pinned: :desc, pinned_at: :asc, created_at: :desc) end |
#new ⇒ Object
34 35 36 37 |
# File 'app/controllers/plain/conversations_controller.rb', line 34 def new @conversation = Plain::Conversation.create redirect_to conversation_path(@conversation) end |
#pin ⇒ Object
52 53 54 55 56 |
# File 'app/controllers/plain/conversations_controller.rb', line 52 def pin @conversation = Plain::Conversation.find(params[:id]) new_state = !@conversation.pinned? @conversation.update(pinned: new_state, pinned_at: new_state ? Time.zone.now : nil ) end |
#show ⇒ Object
30 31 32 |
# File 'app/controllers/plain/conversations_controller.rb', line 30 def show @conversation = Plain::Conversation.find(params[:id]) end |
#update ⇒ Object
43 44 45 |
# File 'app/controllers/plain/conversations_controller.rb', line 43 def update @conversation = Plain::Conversation.find(params[:id]) end |