Class: Chatty::ChatsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Chatty::ChatsController
- Defined in:
- app/controllers/chatty/chats_controller.rb
Instance Method Summary collapse
- #close ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #handle ⇒ Object
- #index ⇒ Object
- #messages ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#close ⇒ Object
60 61 62 63 64 |
# File 'app/controllers/chatty/chats_controller.rb', line 60 def close @chat.close @chat.create_activity :key => "chatty/chat.closed", :owner => current_user redirect_to chat_path(@chat) end |
#create ⇒ Object
26 27 28 29 30 31 32 33 34 |
# File 'app/controllers/chatty/chats_controller.rb', line 26 def create @chat = Chatty::Chat.new(chat_params) if @chat.save redirect_to @chat, notice: 'Chat was successfully created.' else render action: 'new' end end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/chatty/chats_controller.rb', line 44 def destroy @chat.destroy redirect_to chats_url, notice: 'Chat was successfully destroyed.' end |
#edit ⇒ Object
23 24 |
# File 'app/controllers/chatty/chats_controller.rb', line 23 def edit end |
#handle ⇒ Object
54 55 56 57 58 |
# File 'app/controllers/chatty/chats_controller.rb', line 54 def handle @chat.handle! @chat.create_activity :key => "chatty/chat.handled", :owner => current_user redirect_to chat_path(@chat) end |
#index ⇒ Object
6 7 8 9 10 |
# File 'app/controllers/chatty/chats_controller.rb', line 6 def index @ransack_params = params[:q] || {} @ransack = Chatty::Chat.ransack(@ransack_params.clone) @chats = @ransack.result.order(:id).reverse_order end |
#messages ⇒ Object
49 50 51 52 |
# File 'app/controllers/chatty/chats_controller.rb', line 49 def @messages = @chat. render :partial => "messages", :layout => false end |
#new ⇒ Object
19 20 21 |
# File 'app/controllers/chatty/chats_controller.rb', line 19 def new @chat = Chatty::Chat.new end |
#show ⇒ Object
12 13 14 15 16 17 |
# File 'app/controllers/chatty/chats_controller.rb', line 12 def show respond_to do |format| format.json { render(:json => {:chat => @chat.json}) } format.html { render :show } end end |
#update ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/controllers/chatty/chats_controller.rb', line 36 def update if @chat.update(chat_params) redirect_to @chat, notice: 'Chat was successfully updated.' else render action: 'edit' end end |