Forum: Ruby on Rails undefined method form_for ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3f96d68ca28cf3a2b72edca1c14e386?d=identicon&s=25 meltman (Guest)
on 2006-04-25 04:32
Seems the only issues I ever have with Rails are these bizarre fiddly
little things that make no sense.

Can't for the life of me understand why I'm getting undefined method on
form_for in a view?

And it's actually part of the acts_as_authenticated plugin that's doing
it. But how can it not know about form_for?
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-04-25 04:44
(Received via mailing list)
On 4/24/06, meltman <petony@gmail.com> wrote:
> Seems the only issues I ever have with Rails are these bizarre fiddly
> little things that make no sense.
>
> Can't for the life of me understand why I'm getting undefined method on
> form_for in a view?
>
> And it's actually part of the acts_as_authenticated plugin that's doing
> it. But how can it not know about form_for?
>

Can you send over some code that isn't working for you?
F3f96d68ca28cf3a2b72edca1c14e386?d=identicon&s=25 meltman (Guest)
on 2006-04-25 04:58
Wilson Bilkovich wrote:
> Can you send over some code that isn't working for you?

Yep, dies on line 1:

<% form_for :user, @user do |f| -%>

The controller executes only one line:

    @user = User.new(params[:user])

That's it. Totally boggled. I should know better perhaps than to work on
this sort of thing late in the evening. I'm sure it's something obvious,
but it just makes no sense to me right now.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-04-25 05:18
(Received via mailing list)
On 4/24/06, meltman <petony@gmail.com> wrote:
>
> That's it. Totally boggled. I should know better perhaps than to work on
> this sort of thing late in the evening. I'm sure it's something obvious,
> but it just makes no sense to me right now.
>

form_for creates a <form> tag, so that needs to be:
<%= %>, not <% %>.
F3f96d68ca28cf3a2b72edca1c14e386?d=identicon&s=25 meltman (Guest)
on 2006-04-25 05:23
Wilson Bilkovich wrote:
> form_for creates a <form> tag, so that needs to be:
> <%= %>, not <% %>.

Actually no it's not. According to the API docs:

"Worth noting is that the form_for tag is called in a ERb evaluation
block, not a ERb output block. So thatâ??s <% %>, not <%= %>."

And changing it to <%= just yields a pile of syntax errors.

The mystery continues.
25e11a00a89683f7e01e425a1a6e305c?d=identicon&s=25 Wilson Bilkovich (Guest)
on 2006-04-25 05:51
(Received via mailing list)
On 4/24/06, meltman <petony@gmail.com> wrote:
>
> The mystery continues.
>
> --
>

Sorry; too much/not enough wine. (Depends on perspective.)

What happens when you do:
<% form_for :user, @user, :url => {:action => 'some_action'} do |f| -%>
<% end -%>

?
6076c22b65b36f5d75c30bdcfb2fda85?d=identicon&s=25 Ezra Zygmuntowicz (Guest)
on 2006-04-25 20:25
(Received via mailing list)
On Apr 24, 2006, at 8:50 PM, Wilson Bilkovich wrote:

>> And changing it to <%= just yields a pile of syntax errors.
> -%>
> <% end -%>


form_for require rails 1.1 or better. You can't run acts_as_auth on
1.0 by default anymore because of form_for.

-Ezra
F3f96d68ca28cf3a2b72edca1c14e386?d=identicon&s=25 meltman (Guest)
on 2006-04-26 00:41
Ezra Zygmuntowicz wrote:
> form_for require rails 1.1 or better. You can't run acts_as_auth on
> 1.0 by default anymore because of form_for.
>
> -Ezra

That'd be it. Son of a.....bleep!

Thanks. Guess it's time to upgrade. Wish the API docs specified that,
might've saved me hours of head banging.
This topic is locked and can not be replied to.