# Fields\_for object methods - no you see them, now you don't

**URL:** <https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477>\
**Category:** Rails\
**Created:** [January 28, 2010, 6:49pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477 "2010-01-28T18:49:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 28, 2010, 6:49pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477/1 "2010-01-28T18:49:16Z")

</div>

I have this:

```
      <%-f.fields_for(:clearances, :index => []) do |ff|

            puts ff.object.methods.sort
            if ff.object.newrecord?
              ff_id = "new_"
            else
              ff_id = "show_"
            end

      -%>

```

Which gives me this:

. . .  
metaclass  
method  
method\_missing  
methods  
nested\_attributes\_options  
new\_record?  
nil?  
object\_id  
partial\_updates  
. . .

```
And we follow the new user roles

```

link # features/app/models/  
clearances/step\_definitions/clearance\_steps.rb:14  
undefined method `newrecord?’ for #Clearance:0x2b203e415238  
(ActionView::TemplateError)

So, where does the missing method go between the puts and the if?

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 28, 2010, 6:52pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477/2 "2010-01-28T18:52:47Z")

</div>

On Jan 28, 12:47 pm, byrnejb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> And we follow the new user roles
> 
> ```
> 
> link # features/app/models/  
> clearances/step\_definitions/clearance\_steps.rb:14  
> undefined method `newrecord?’ for #Clearance:0x2b203e415238  
> (ActionView::TemplateError)
> 
> So, where does the missing method go between the puts and the if?

Never mind. I see my error.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 28, 2010, 6:54pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477/3 "2010-01-28T18:54:32Z")

</div>

On Jan 28, 2010, at 9:47 AM, byrnejb wrote:

> new\_record?
> 
> So, where does the missing method go between the puts and the if?

newrecord? vs new\_record?

you’re missing an underscore in your code.

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 28, 2010, 6:55pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477/4 "2010-01-28T18:55:07Z")

</div>

On 28 January 2010 17:51, byrnejb [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > So, where does the missing method go between the puts and the if?
> 
> Never mind. I see my error.

Which was? We all like to learn from questions here.

Colin

---

<div class="post-metadata">

**Author:** ![byrnejb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d2c977/32.png) [@byrnejb](https://www.ruby-forum.com/u/byrnejb)\
**Post date:** [January 28, 2010, 10:51pm UTC](https://www.ruby-forum.com/t/fields-for-object-methods-no-you-see-them-now-you-dont/182477/5 "2010-01-28T22:51:37Z")

</div>

On Jan 28, 12:53 pm, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > (ActionView::TemplateError)
> 
> > > So, where does the missing method go between the puts and the if?
> 
> > Never mind. I see my error.
> 
> Which was? We all like to learn from questions here.
> 
> Colin

newrecord? should be new\_record? instead.
