Good afternoon Stack Overflow,
def show
# Translating ID to event
@event = Event.find(params[:id])
respond_to do |format|
format.html
format.json { render :json => @event }
end
end
This code should (according to what I read online) generate an html response when the Accept
header is set to text/html
, and JSON whenever the header is set to application/json
. Yet whenever I test this with Postman I always end up getting the representation of the resource that is set first.
In the above code that would be html, even when the accept header is set solely to Json. If I switch them around, I get a json representation, indifferent of what I set the header.
Side question: I'm kinda new to Ruby, and would like to fully understand what the do |x| do_a() do_b()
syntax/stanza is. Is this like a Switch statement or more a lambda?
Solution found
My brain just gave out for 2 days, because apparently I was sending Content-Type headers in a GET request, instead of the appropriate Accept Header.
Thx @yoones for trying to help me :)
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments