Ruby on Rails Tuesday, June 7, 2016

Hi I'm trying to write an api, but I'm having an issue with the controller not returning "hi"


Controller:

class ApisController < ApplicationController    before_action :set_api, only: [:show, :edit, :update, :destroy]      # GET /apis    # GET /apis.json      def alertdump        respond_to do |format|          format.html { render html: 'hi' }          format.json { render json: "hi" }      end    end


Routes:

  resources :apis do      collection do        post 'alertdump/:fullalert', :action=> 'alertdump'      end    end


I'm getting instead this (which is the first element of the model 'api')

{"id":1,"created_at":"2016-06-07T15:05:17.897Z","updated_at":"2016-06-07T15:05:17.897Z"}

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/54159c90-d348-401b-bda7-efe0514f5500%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment