Hey guys I’m completely lost at this point I’m trying to make a simple app that takes an input in the form of a string (“City, State”) and sends that string to the google_places gem to do spot_by_query(“gas station near #{enter value from input}”)
Then I need the 1st 10 results and be able to print out their names. I have become completely lost in my attempts and was looking for some advice.
Here is my controller class LocationsController < ApplicationController
before_action :set_location, only: [:show, :edit, :update, :destroy]
GET /locations
GET /locations.json
def index
@location = Location.new
end
GET /locations/1
GET /locations/1.json
def show
end
GET /locations/new
def new
end
POST /locations
POST /locations.json
def create
@client = GooglePlaces::Client.new('################')
@shops = @client.spots_by_query('coffee near #{@location(params[:address])}')
@result = JSON.parse(@shops[1])
# @location.find_closest_shops(@location.params[:address])
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def location_params
params.require(:location).permit(:address)
end
end
``
Here is the input form
<%= form_for @location do |f| %>
<%= f.label :address %>
<%= f.text_field :address, :placeholder => “City State” %>
<%= f.submit “Find Coffee!” %>
<% end %>
``
Here is the output form (this is where I’m lost) <%= print “#{@result[‘name’]}” %>
``