I m trying to return both a active record model and a string value in json but not able to do so
Here is my controller/action
def index
@accounts = Account.search(params[:search_login])
respond_to do |format|
format.html # index.html.erb
format.json { render json: @accounts, :miles => "23"}
end
end
And here is Ajax Call
function GetMiles()
{
$.ajax({url: "/accounts?" + "search_login=" + $('#account_number').val(),
dataType: "json",
success: function( data ) {
alert(data.miles)
response($.map(data.acc, function( item1 ) {
alert(item.account_number)
}
});
}
But not able to get miles value as well any model property value, please help
ok i have found the solution here
responding with multiple JSON renders. (Ruby/Rails)
thanks Stack Overflow