简体   繁体   English

如何使用rails date_field助手?

[英]How to use the rails date_field helper?

I am completely new to ruby on rails, and trying to follow the rails guide on Form Helpers . 我对rails上的ruby完全不熟悉,并尝试按照Form Helpers上rails指南 When I try using a date_field helper with: 当我尝试使用date_field助手时:

<%= date_field(:user, :born_on) %>

I get an error: 我收到一个错误:

undefined method `date_field' for #<#<Class:0x007fa42ffe3dc0>:0x007fa42f82c410>

Am I supposed to include something in order to use certain helpers? 我是否应该包含一些东西以便使用某些帮助者? Thanks! 谢谢!

date_field() is a new helper in Ruby on Rails 4.0, so you're probably using an older version like 3.2.13. date_field()是Ruby on Rails 4.0中的一个新助手,所以你可能正在使用像3.2.13这样的旧版本。

These are examples of the form helpers available in Rails 3.2.13: 这些是Rails 3.2.13中提供的表单助手的示例:

<%= text_area_tag(:message, "Hi, nice site", :size => "24x6") %>
<%= password_field_tag(:password) %>
<%= hidden_field_tag(:parent_id, "5") %>
<%= search_field(:user, :name) %>
<%= telephone_field(:user, :phone) %>
<%= url_field(:user, :homepage) %>
<%= email_field(:user, :address) %>

And you can find the documentation of this here: http://guides.rubyonrails.org/v3.2.13/form_helpers.html#other-helpers-of-interest 你可以在这里找到这方面的文档: http//guides.rubyonrails.org/v3.2.13/form_helpers.html#other-helpers-of-interest

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM