Form_tag error (model)


#1

That’s give me an error

:: <%= form “user” %>
:: <%= input “user”, “username” %>
:: <%= end_form_tag %>

NoMethodError in Home#index
Showing app/views/components/_loginbox.rhtml where line #1 raised:

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.new_record?

Note that the directory /components/ doesn’t match a controller (but it
isn’t important).

Why?


#2

Hi!
Unless i am missing something, there is no helper method just ‘form’
you
might use form_for or form_tag. (start_form_tag is deprecated from Rails
1.2.1)
For full list please refer
http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html
Thanks and regards,
Swanand.


#3

Swanand Deodhar wrote:

Hi!
Unless i am missing something, there is no helper method just ‘form’
you
might use form_for or form_tag. (start_form_tag is deprecated from Rails
1.2.1)
For full list please refer
http://api.rubyonrails.com/classes/ActionView/Helpers/FormTagHelper.html
Thanks and regards,
Swanand.

Sorry, I changed it in order to try to resolve the error.

Actually, the error is:

You have a nil object when you didn’t expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.column_for_attribute

And match the row:
<%= input “user”, “username” %>


#4

Swanand Deodhar wrote:

Hi!
As you are trying have an rhtml page with a textfield
corresponding
to a username column of users table.
You might wanna try <%= text_field :user, :username%>.
I am not too sure what is <%= input%>
Thanks and regards,
Swanand

MMmmh it doesn’t work.

input =>
http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M000565


#5

Hi!
As you are trying have an rhtml page with a textfield
corresponding
to a username column of users table.
You might wanna try <%= text_field :user, :username%>.
I am not too sure what is <%= input%>
Thanks and regards,
Swanand