There is what I''m doing: I want to display a series of text_area fields (read only) of which each has a checkbox. Is this the best way to do it? <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> <% f.fields_for :comments do |a|%> <li> <%= a.text_area :text, :read_only => ''true'' %> <br> <%= a.check_box :approval_boolean %> <br> <hr> </li> <% end %> <% end %> Is there any other way to display the field "text" other than above? Thanks! -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
If it is going to be read-only, why do you need to display it in a text_area instead of directly on the page? andrew wrote:> There is what I''m doing: I want to display a series of text_area > fields (read only) of which each has a checkbox. > > Is this the best way to do it? > > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > <% f.fields_for :comments do |a|%> > <li> > <%= a.text_area :text, :read_only => ''true'' %> <br> > <%= a.check_box :approval_boolean %> <br> > <hr> > </li> > <% end %> > <% end %> > > Is there any other way to display the field "text" other than above? > > Thanks!-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
That''s my question! How do you do that. <% a.text %> gives me this error: NoMethodError in Sections#edit_acknowledgments Showing app/views/sections/edit_acknowledgments.html.erb where line #11 raised: Thanks! -a On Mar 23, 3:47 am, Sharagoz -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> If it is going to be read-only, why do you need to display it in a > text_area instead of directly on the page? > > > > > > andrew wrote: > > There is what I''m doing: I want to display a series of text_area > > fields (read only) of which each has a checkbox. > > > Is this the best way to do it? > > > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > > <% f.fields_for :comments do |a|%> > > <li> > > <%= a.text_area :text, :read_only => ''true'' %> <br> > > <%= a.check_box :approval_boolean %> <br> > > <hr> > > </li> > > <% end %> > > <% end %> > > > Is there any other way to display the field "text" other than above? > > > Thanks! > > -- > Posted viahttp://www.ruby-forum.com/.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 23 March 2010 14:55, andrew <andrew.ggroups-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That''s my question! How do you do that. > > <% a.text %> gives me this error:<%=h a.text %> 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 %> YMMV -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 23 March 2010 14:55, andrew <andrew.ggroups-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> That''s my question! How do you do that. > > <% a.text %> gives me this error:You want just <%= text %> or probably <%= h text %> dependant on where text is coming from Colin> > NoMethodError in Sections#edit_acknowledgments > > Showing app/views/sections/edit_acknowledgments.html.erb where line > #11 raised: > > Thanks! -a > > On Mar 23, 3:47 am, Sharagoz -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> If it is going to be read-only, why do you need to display it in a >> text_area instead of directly on the page? >> >> >> >> >> >> andrew wrote: >> > There is what I''m doing: I want to display a series of text_area >> > fields (read only) of which each has a checkbox. >> >> > Is this the best way to do it? >> >> > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> >> > <% f.fields_for :comments do |a|%> >> > <li> >> > <%= a.text_area :text, :read_only => ''true'' %> <br> >> > <%= a.check_box :approval_boolean %> <br> >> > <hr> >> > </li> >> > <% end %> >> > <% end %> >> >> > Is there any other way to display the field "text" other than above? >> >> > Thanks! >> >> -- >> Posted viahttp://www.ruby-forum.com/. > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > 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. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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. :( On Mar 23, 10:14 am, Colin Law <clan...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 23 March 2010 14:55, andrew <andrew.ggro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > That''s my question! How do you do that. > > > <% a.text %> gives me this error: > > You want just > <%= text %> > or probably > <%= h text %> dependant on where text is coming from > > Colin > > > > > > > NoMethodError in Sections#edit_acknowledgments > > > Showing app/views/sections/edit_acknowledgments.html.erb where line > > #11 raised: > > > Thanks! -a > > > On Mar 23, 3:47 am, Sharagoz -- <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >> If it is going to be read-only, why do you need to display it in a > >> text_area instead of directly on the page? > > >> andrew wrote: > >> > There is what I''m doing: I want to display a series of text_area > >> > fields (read only) of which each has a checkbox. > > >> > Is this the best way to do it? > > >> > <% form_for (@section), :url =>{:action => "save_comments"} do |f| %> > >> > <% f.fields_for :comments do |a|%> > >> > <li> > >> > <%= a.text_area :text, :read_only => ''true'' %> <br> > >> > <%= a.check_box :approval_boolean %> <br> > >> > <hr> > >> > </li> > >> > <% end %> > >> > <% end %> > > >> > Is there any other way to display the field "text" other than above? > > >> > Thanks! > > >> -- > >> Posted viahttp://www.ruby-forum.com/. > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 23 March 2010 16:35, andrew <andrew.ggroups-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 March 2010 16:35, andrew <andrew.ggro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
On 23 March 2010 17:01, andrew <andrew.ggroups-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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...) -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
That''s exactly what I was looking for! THANK YOU! And thanks for the insight. -a On Mar 23, 12:10 pm, Michael Pavling <pavl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 23 March 2010 17:01, andrew <andrew.ggro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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...)-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.