Disclaimer: New to Ember (and by no means a seasoned Rails dev)
I am building a simple Ember app using a Rails backend to query a third party API. My controller is receiving the params from the GET request, but I get a 500 error telling me that I am calling a render/redirect multiple times in this action. I really want a JSON response sent back to my Ember controller.
// Ember controller
export default Ember.Controller.extend({
actions: {
getGif: function(){
$.getJSON("http://localhost:3000/gifs?q=cats", function(result){
var embedGif = result
$('#some-id').append(embedGif);
})
}
}
});
class PostController < ApplicationController
def gifs
searchterm = params[:q]
split_string = searchterm.split(" ")
if split_string.length > 1
slug = split.string.join("+")
else
slug = searchterm
end
response = HTTParty.get("http://ift.tt/1LSTq4y")
response["data"].each do |gif|
url = gif["images"]["fixed_height"]["url"]
respond_with(url) |format|
format.json
end
end
end
end
Aucun commentaire:
Enregistrer un commentaire