关于rails中的符号的简单问题
我是 Rails 新手,有一个非常简单的问题,但在网上找不到答案,希望你们中的一个人可以帮助我。
我有一个带有以下代码的表单,
<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>
我想要做的是使用地理编码器来获取纬度和经度的值。
地理编码器功能在 _geocodeby :address 上是这样的,
因为我得到 :address 作为多个符号,我想在传递给地理编码器之前添加它们。由于加法不适用于符号,我该如何完成。
谢谢, 文卡特什
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需在模型上创建一个
address
方法,如下所示,然后使用地理编码器对
:address
进行地理编码Just make an
address
method on your model like thisand use geocoder to geocode
:address
这是一篇很棒的博客文章,解释了 Ruby 符号: Ruby 符号和字符串之间的区别
这里有一个详细的指南:Ruby_Newbie 符号指南
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