ok, rails 3 new developer here.
I want my jquery to be able to get a json object from the rails 3 application for projects. Here is my controller.
def yourprojects
@projects = Projects.all(current_user)
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @projects }
end
end
I added the format.json line... in jquery i have:
$.ajax({url: '/projects/yourprojects', dataType: 'json'});
So that should work i thought. Instead the server is returning: "Template is missing" "Missing template ,,,, with {:locale=>[:en, :en], :handlers=>[:rjs, :rhtml, :builder, :rxml, :erb], :formats=>[:html]} in view paths"
do you need a template for a jsOn return? shouldn't the rails 3 app know how to format the json?
Routes File:
resources :projects do
collection do
get 'yourprojects'
end
end