# Baffled with form\_for

**URL:** <https://www.ruby-forum.com/t/baffled-with-form-for/165999>\
**Category:** Rails\
**Created:** [April 20, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999 "2009-04-20T21:12:23Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 20, 2009, 9:12pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/1 "2009-04-20T21:12:23Z")

</div>

I have a simple User form with a simple Usercontroller.  
The ‘edit’ action looks like:  
def edit  
@user = current\_user  
end

In the view:  
\<% form\_for(@user) do |f| %\>  
blah blah  
\<% end %\>

What it generates is:

 . 

How does that form ‘action’ field becomes so b0rked?

Running Rails 2.3.2

Harm

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 10:54am UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/2 "2009-04-21T10:54:51Z")

</div>

On 20 Apr 2009, at 20:11, harm wrote:

> \<% end %\>
> 
> How does that form ‘action’ field becomes so b0rked?

Is user an active record object ?

Fred

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 1:36pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/3 "2009-04-21T13:36:14Z")

</div>

That was my initial hunch as well. And it is an AR object.

I believe that the fact that the user is a singleton resource matters.  
E.g.  
map.resouce :user, :controller =\> “Users”

I modified the form\_for and passed an explicit path with :url =\>  
user\_path. This seems to work. But it is vert strange Rails doesn’t  
pick this up automatically. Then again maybe I’m defining the resource  
wrong.

On Apr 21, 10:50 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 4:10pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/4 "2009-04-21T16:10:28Z")

</div>

Harm wrote:

> That was my initial hunch as well. And it is an AR object.
> 
> I believe that the fact that the user is a singleton resource matters.  
> E.g.  
> map.resouce :user, :controller =\> “Users”  
> […]

You misspelled “resource” here. Is it also misspelled in your actual  
code? If so, that could be the problem…

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 4:15pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/5 "2009-04-21T16:15:17Z")

</div>

Ow I did misspelled it. I didn’t do so in my code.

On Apr 21, 4:10 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/6 "2009-04-21T16:56:22Z")

</div>

Thank you Dmitry.  
I’ll ponder a bit on your remark, my initial gut feeling is that I do  
want a singleton resource as I never want to expose more than 1 user.  
Ever. Which is restful. But I’ll think about it.

On Apr 21, 4:45 pm, Dmitry S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 22, 2009, 8:46am UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/7 "2009-04-22T08:46:47Z")

</div>

Most time, you can put a reference manual in your desk.  
When you can’t confirm the settings , you can find it very quickly.  
For example :  
Rails: Up and Running, Second Edition Appendix B

> **[9780596522001\_appendixB.pdf](https://cdn.oreillystatic.com/oreilly/pdfs/9780596522001_appendixB.pdf)**
>
> 774.65 KB

---

<div class="post-metadata">

**Author:** ![harm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b4bc9f/32.png) [@harm](https://www.ruby-forum.com/u/harm)\
**Post date:** [April 21, 2009, 4:46pm UTC](https://www.ruby-forum.com/t/baffled-with-form-for/165999/8 "2009-04-21T16:46:23Z")

</div>

Just make users a collection (map.resources :users), then everything  
will work fine. Or if your really want it to be a singleton (bad idea,  
not restfull if you have more than 1 user in your app), then use  
form\_for :user, :object =\> @user.

Dmitry
