You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Following the documentation on AJAX/JQUERY functionality.
Received the following Error:
wrong number of arguments (given 2, expected 1)
It appeared Zipcode.find_by_code only takes one argument. The Zip Code. Also changed the line on finding counties to @counties = County.first(@zipcode.county_id)
Updated the code below as the following and it is returning the hash on the get call.
def get_zip_data
puts 'TEST'
puts params
@zipcode = Zipcode.find_by_code(params[:code])
if @zipcode
puts 'ZIPCODE---'
pp @zipcode
@counties = County.first(@zipcode.county_id)
data = {
'state' => @zipcode.state.abbr,
'county' => @zipcode.county.name,
'city' => @zipcode.city.titleize
}
render :text => data.to_json
else
if params[:code].blank?
return true
else
if params[:code].is_zipcode?
data = {
'err' => "Could not find Zipcode [#{params[:code]}]. If this is a valid zipcode please notify support <[email protected]>, so we can update our database."
}
else
data = {
'err' => "[#{params[:code]}] is not a valid Zipcode."
}
end
render :text => data.to_json
end
end
end
The text was updated successfully, but these errors were encountered:
Following the documentation on AJAX/JQUERY functionality.
Received the following Error:
wrong number of arguments (given 2, expected 1)
It appeared Zipcode.find_by_code only takes one argument. The Zip Code. Also changed the line on finding counties to @counties = County.first(@zipcode.county_id)
Updated the code below as the following and it is returning the hash on the get call.
The text was updated successfully, but these errors were encountered: