Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 935
David Avatar asked Jul 09 '13 16:07

David


1 Answers

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

like image 84
Jeroen Avatar answered Oct 11 '22 23:10

Jeroen