added this in my projects_controller:
def index
@projects = Project.all
projects = @projects.to_json
respond_to do |format|
format.json {render :json => projects, :callback => params[:callback]}
end
end
and on the client/ajax side:
$(document).ready(function() {
$.ajax({
type: "GET",
url: "heroku_url/projects.json",
cache: false,
dataType: "json",
success: function(data) {
alert(data);
$.each(data, function(index, value) {
$("<article id='project'><label id='name'>"+data[index].name+"</label>
<pid='tech'>"+data[index].tech+"</p><p id='description'>"+data[index].description+"
</p></article><br />").appendTo($("#projects"));
});
}
});
});