简体   繁体   中英

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 . When I try using a date_field helper with:

<%= 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.

These are examples of the form helpers available in 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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