How to use the rails date_field helper?
Asked Answered
I

1

6

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!

Izanami answered 9/7, 2013 at 16:49 Comment(1)
What does the rest of your form code look like?Gunderson
F
6

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

Floatstone answered 9/7, 2013 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.