views:

243

answers:

1

When I copied _form.haml partial to _edit_form.haml partial and replaced "_form", with "_edit_form" in my edit.haml I got strange error (maybe it is not strange, I just cant understand the reason).

wrong number of arguments (0 for 1)

Extracted source (around line #1):

1: = form.label :email
2: %br
3: = form.text_field :email
4: %br

.../app/views/users/_edit_form.haml:1:in `form'
.../app/views/users/_edit_form.haml:1:in `_run_haml_app47views47users47_edit_form46haml_locals_edit_form_object'
.../app/views/users/edit.haml:5:in `_run_haml_app47views47users47edit46haml'
.../app/views/users/edit.haml:3:in `_run_haml_app47views47users47edit46haml'

Here is edit.haml:

%h1 Edit My Account

- form_for @user, :url => account_path do |f|
  = f.error_messages
  = render :partial => "edit_form", :object => f
  = f.submit "Update"

%br
= link_to "My Profile", account_path

...and edit_form.haml

= form.label :email
%br
= form.text_field :email
%br
%br
= form.label :old_password, "Old password"
%br
= form.password_field :old_password
%br
%br
= form.label :password, "Change password"
%br
= form.password_field :password
%br
%br
= form.label :password_confirmation
%br
= form.password_field :password_confirmation
%br

I can't understand where is the problem. Because it worked nicely with _form.haml

diff _form.haml _edit_form.haml   
1c1
< = form.label :login
---
> = form.label :email
3c3
< = form.text_field :login
---
> = form.text_field :email
6c6
< = form.label :email
---
> = form.label :old_password, "Old password"
8c8
< = form.text_field :email
---
> = form.password_field :old_password
11c11
< = form.label :password, form.object.new_record? ? nil : "Change password"
---
> = form.label :password, "Change password"
+2  A: 

The :object is implicitly exposed in the partial as the name of the partial. Change form to edit_form in _edit_form.haml and it should work.

Jonathan Julian