I read many links specially on stackoverflow but could not find the solution as there was some difference . so I want to make my point clear as explained below:
I have an ajax call pointing to my controller and it has only one parameter google_searched_locations , which is basically contains json string
google_searched_locations [{"geometry":{"location":{"J":31.482273,"M":74.33069999999998}},"icon":"https://maps.gstatic.com/mapfiles
/place_api/icons/restaurant-71.png","id":"b93a99a46343de01d0d928f99470f9b0f5f6f11d","name":"Dunkin' Donuts"
,"place_id":"ChIJSeoh6hkEGTkRsd0e1crAbHU","rating":4.3,"reference":"CnRhAAAA4x8yMjf9__CURWmYX6ojnpgu
-M1aL4Cvsmp6j2nKOLiqlBRlslTtPU8hUc6tJWAehCE967tW8Z623new_ivN8_PWbypr6ANDj_6AIxxGTQcwneyfHCigsHWhcdrUlcJAsQTycbHOTdmu6n8loZiU-hIQHNPqBNJRlho9fVjRfomU-BoUcdX_NGHhBFs_pxQiPZTlUD-W88o"
,"scope":"GOOGLE","types":["restaurant","food","point_of_interest","establishment"],"vicinity":"Lahore"
,"html_attributions":[]}]
my action contains the following code
def searchResults
@restaurant = GoogleSearchedLocation.new(params_google_searched_locations)
byebug
if @restaurant.save!
render json: { :status => :Ok }
else
render json: { :status => :failed }
end
end
And code in params_google_searched_locations
is as follows
def params_google_searched_locations
params.require(:google_searched_locations).permit(:place_id)
end
Now the whole ajax call fails throwing the following error in response
NoMethodError in GoogleSearchedLocationController#searchResults
undefined method `permit' for #< String:0x007f66ec5515b8 >
Solution with the reason will be more appreciated . Thanks in advance
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…