rubyonrailsin

A Ruby and Rails talk

Tuesday, March 23, 2010


[Rails] Re: Displaying a nested field as a label

by rubyonrailsin 0 comments

Tag


Share this post:
Design Float
StumbleUpon
Reddit

This is a nested model form using to models: section and comment,
where section has many comments.

"text" is a field for comments
"approval_boolean" is a field for comments

I just want the field value for "text" to show up as a non-form-
element and "approval_boolean" to show as a check box form element.

The code above works, but I can only get the "text" field to show up
as a text_area or text_field form element.

Like I said, if <%= a.text %> worked, I'd be happy... but it gives me
a method error and I'm not sure why.

Ahhhh! a.class = formbuilder. I thought it was a Comments class.
Now I know what to look up.... I guess my question after all is there
any way to "extract" a data value from a field within a formbuilder?
(if I got my terminology right)

Thanks for taking the time to look at this, btw.

-a

On Mar 23, 11:45 am, Michael Pavling <pavl...@gmail.com> wrote:
> On 23 March 2010 16:35, andrew <andrew.ggro...@gmail.com> wrote:
>
> > Ok, I'll clean up the variable names.  Thanks!  :)
>
> > However....
>
> > <%=h comment.txt %>  undefined method `text'
> > <%= text %> and <%=h text %> give undefined local variable or method
> > `text'
>
> > Neither of those ideas work.  :(
>
> Well what *is* your "a/comment" variable? Have you debugged it to see
> what's going on in that block? Do you *know* what methods it's got, or
> are you assuming there's a "text" method?
>
> You can use <% puts .... %> or <% logger.info .... %> to output
> messages to help you diagnose what's going on. Personally, I prefer to
> use breakpoint debugging in Netbeans.
>
> does 'puts a.respond_to("text")' display true?
> what does 'puts a.inspect' give you?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment

Subscribe feeds via e-mail

Blog Archive