I need to add a field to a JSON response.
def index
if params[:competition_level]
@competition_level_id = params[:competition_level].to_i
end
@matchups = @weekly_scoreboards
# can I call @matchups[0].as_json to return a hash, and add a field?
# let's see...
@matchups[0].as_json.merge!({ 'disabled' => true} )
# this returns @matchups[0] looking the way I need it to,
# but it I look at @matchups[0].as_json again, the field I added is
# gone
respond_to do |format|
format.html { render }
format.mobile { render }
format.json {
render :json => @matchups.to_json
}
end
end
Not sure what's going on here. Been going over this for a few hours.