BTW, “a” is not a very helpful name for a block variable (or any
variable for that matter). Assuming you’re not paying for your code by
the byte, it would be more legible thus:
<% f.fields_for :comments do |comment|%>
…
<%=h comment.text %>
<%=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?
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)
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)
a.object.text
(although I’m using Formtastic “SemanticFormBuilder” objects here, so
have fingers crossed the method is the same - dumping “a.methods”
would help you a little if ‘object’ doesn’t work…)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.