Class: Chatty::MessagesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Chatty::MessagesController
- Defined in:
- app/controllers/chatty/messages_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/chatty/messages_controller.rb', line 7 def create if @message.save render :json => { :success => true } else render :json => { :success => false, :errors => @message.errors..join(". ") } end end |
#index ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/chatty/messages_controller.rb', line 22 def index @ransack_params = params[:q] || {} @ransack = Chatty::Message.ransack(@ransack_params) @messages = @ransack.result.order(:created_at, :id) respond_to do |format| format.json { render(:json => {:messages => (@messages)}) } end end |
#new ⇒ Object
2 3 4 5 |
# File 'app/controllers/chatty/messages_controller.rb', line 2 def new render :new, :layout => false end |