Ven
Ven

Reputation: 3

Simple question regarding Symbols in rails

I am new to rails and have a very simple question but couldnt find answer on the web, hope one of you could help me.

I have a form with following code

<p>
    <%= f.label :address_street %><br />
    <%= f.text_field :address_street %>
  </p>
<p>
<%= f.label :address_city %><br />
    <%= f.text_field :address_city %>
  </p>
  <p>
    <%= f.label :address_state %><br />
    <%= f.text_field :address_state %>
  </p>
  <p>
    <%= f.label :address_country %><br />
    <%= f.text_field :address_country %>
  </p>

what I want to do is use geocoder to get the value of latitude nad longitude.

the geocoder function is someting like this on _geocodeby :address

since I get :address as multiple symbols I want to add them before passing to geocoder. Since addition doesnt work on symbol, how could I accomplish.

Thanks, Venkatesh

Upvotes: 0

Views: 296

Answers (2)

Edward Castano
Edward Castano

Reputation: 617

Here is a great blog post explaining Ruby symbols: The Difference Between Ruby Symbols and Strings

And here is a detailed guide: The Ruby_Newbie Guide to Symbols

Upvotes: 1

Gerry
Gerry

Reputation: 5336

Just make an address method on your model like this

def address
  "#{address_street} #{address_city} #{address_state} #{address_country}"
end

and use geocoder to geocode :address

Upvotes: 2

Related Questions