Question

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!

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top