I am in the process of converting an application from RoR-2.3.10 to 3.0.1. I have run across the situation where partials are not being rendered at all, whereas the exact same code works fine in Rails2. The form code is: <div class="headers" id="roles_new_page"> <%- content_tag_for :h2, @role, :header do %> Add a New role <%= @role.id.to_s -%> <%- end -%> <%=error_messages_for :role %> <%=form_for(@role, :html => {:id => ''new_role_form''}) do |f| %> <%= render :partial => ''role_header'', :object => @role -%> <%= render :partial => ''role_detail'', :object => @role -%> <%= render :partial => ''shared/effective_period'', :object => @role -%> <p> <%=f.submit :Create, :id => :submit_create -%> </p> <% end %> . . . All this generates is: <form accept-charset="UTF-8" action="/roles" class="new_role" id="new_role_form" method="post"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓" /></div> <p> <input id="submit_create" name="commit" type="submit" value="Create" /> </p> </form> Is there anything wrong with using this syntax in Rails3? -- 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.
James Byrne wrote in post #955566:> I am in the process of converting an application from RoR-2.3.10 to > 3.0.1. I have run across the situation where partials are not being > rendered at all,[...] If the Tattler plugin works with Rails 3 (which I''m not sure of), you might want to use it to make sure that Rails thinks it''s rendering the partials. Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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.
Marnen Laibow-Koser wrote in post #955575:> > If the Tattler plugin works with Rails 3 (which I''m not sure of), you > might want to use it to make sure that Rails thinks it''s rendering the > partials. >Tattler seems not to work but I found this in a post referring to it: Tattler doesn''t work with Rails 3 anymore. This little bit of code, inspired by it, does. unless Rails.env.production? class ActionView::Template def render_with_comment(*args, &block) render_result = render_without_comment(*args, &block) if mime_type.nil? || mime_type === [Mime::HTML, Mime::XML] ("<!-- TEMPLATE: #{identifier} -->\n" + render_result + "\n<!-- ENDTEMPLATE: #{identifier} -->" ).html_safe else render_result end end alias_method_chain :render, :comment end end I added the snippet given above to a file in config/initializers called tattler.rb. However, it does not work. I get a stack trace when I run cucumber against the feature that previously simply failed. http://gist.github.com/635417 So, I am no further ahead. I looked into one of the missing partials. I do not notice anything obviously wrong. The code is here: http://gist.github.com/635423 -- 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.
James Byrne wrote in post #955607:> > I added the snippet given above to a file in config/initializers called > tattler.rb. However, it does not work. I get a stack trace when I run > cucumber against the feature that previously simply failed.I discovered my error that was causing tattler to fail. This is what I get now: http://gist.github.com/635479 It appears that the partials are being called but that the model object is not being passed. -- 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.
James Byrne wrote in post #955611:> > It appears that the partials are being called but that the model object > is not being passed.I discover here ( http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 ) that the :object => syntax is no longer supported. I suppose that I will eventually discover the current usage. -- 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.
On 20 October 2010 01:22, James Byrne <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> James Byrne wrote in post #955611: > >> >> It appears that the partials are being called but that the model object >> is not being passed. > > I discover here ( > http://darwinweb.net/articles/getting-up-to-speed-with-rails-3 ) that > the :object => syntax is no longer supported. I suppose that I will > eventually discover the current usage.You can use :locals It still shows :object in the rails 3 guide, http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials, section 3.4.4. It does not appear in http://api.rubyonrails.org/classes/ActionView/Partials.html however. Is it the guide that is out of date? Colin -- 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.
Colin Law wrote in post #955669:> > > You can use :locals >I have tried and I evidently am missing something that is obvious to others. The partial I am calling has this: <%- fields_for(role_header) do |ff| -%> <%= label role_header.class.to_s.downcase, :rolename, :''Role Name: '', :class => :input_box_label, :for => ''input_rolename'' -%> </b> <br /> I have tried this: <<%=form_for(@role, :html => {:id => :''new_role_form''}) do |f| %> <%=render :partial => ''role_header'', :locals => { ''role_header'' => @role }-%> And I get this: undefined method `model_name'' for NilClass:Class (ActionView::Template::Error) /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.1/lib/active_model/naming.rb:90:in `model_name_from_record_or_class'' I tried this: <%=render :partial => ''role_header'', :locals => { :role_header => @role }-%> And got this: cannot fill in, no text field, text area or password field with id, name, or label ''Role Name'' found. I tried this: <%=render :partial => ''role_header'', @role-%> And got this: compile error /home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:9: syntax error, unexpected '')'', expecting tASSOC ...tial => ''role_header'', @role); ^ /home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:18: syntax error, unexpected kEND, expecting '')'' ''); end ^ /home/byrnejb/Software/Development/Projects/proforma.rails3/app/views/roles/new.html.erb:26: syntax error, unexpected kENSURE, expecting '')'' I evidently have no idea how to get this to work in Rails3. So, if anyone can see my obvious error then I would be grateful if you would be so kind as to point it out to me. -- 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.
On 20 October 2010 14:05, James Byrne <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #955669: >> >> >> You can use :locals >> > > I have tried and I evidently am missing something that is obvious to > others. The partial I am calling has this: > > <%- fields_for(role_header) do |ff| -%> > <%= label role_header.class.to_s.downcase, > :rolename, > :''Role Name: '', > :class => :input_box_label, > :for => ''input_rolename'' -%> > </b> <br /> > > > I have tried this: > > <<%=form_for(@role, :html => {:id => :''new_role_form''}) do |f| %> > > <%=render :partial => ''role_header'', > :locals => { ''role_header'' => @role }-%>I think it should be :role_header> > > And I get this: > > undefined method `model_name'' for NilClass:Class > (ActionView::Template::Error) > /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.1/lib/active_model/naming.rb:90:in > `model_name_from_record_or_class'' > > > I tried this: > > <%=render :partial => ''role_header'', > :locals => { :role_header => @role }-%>That looks better> > And got this: > > cannot fill in, no text field, text area or password field with id, > name, or label ''Role Name'' found.The fact that it has got past the Class call means we have moved on. It suggests there is a problem with your label statement. I suggest you simplify that to get it working and work back up again. Colin -- 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 20 October 2010 14:31, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 20 October 2010 14:05, James Byrne <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Colin Law wrote in post #955669: >>> >>> >>> You can use :locals >>> >> >> I have tried and I evidently am missing something that is obvious to >> others. The partial I am calling has this: >> >> <%- fields_for(role_header) do |ff| -%> >> <%= label role_header.class.to_s.downcase, >> :rolename, >> :''Role Name: '', >> :class => :input_box_label, >> :for => ''input_rolename'' -%> >> </b> <br /> >> >> >> I have tried this: >> >> <<%=form_for(@role, :html => {:id => :''new_role_form''}) do |f| %> >> >> <%=render :partial => ''role_header'', >> :locals => { ''role_header'' => @role }-%> > > I think it should be :role_header > >> >> >> And I get this: >> >> undefined method `model_name'' for NilClass:Class >> (ActionView::Template::Error) >> /home/byrnejb/.rvm/gems/ruby-1.8.7-p302/gems/activemodel-3.0.1/lib/active_model/naming.rb:90:in >> `model_name_from_record_or_class'' >> >> >> I tried this: >> >> <%=render :partial => ''role_header'', >> :locals => { :role_header => @role }-%> > > That looks better > >> >> And got this: >> >> cannot fill in, no text field, text area or password field with id, >> name, or label ''Role Name'' found. > > The fact that it has got past the Class call means we have moved on. > It suggests there is a problem with your label statement. I suggest > you simplify that to get it working and work back up again.Actually it is obvious, look carefully at the Role Name line. What is it supposed to mean? Clue : and '' do not usually go together like that. Colin -- 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.
James Byrne wrote in post #955754:> I evidently have no idea how to get this to work in Rails3. So, if > anyone can see my obvious error then I would be grateful if you would be > so kind as to point it out to me.Well, it appears that all along the problem was one of a missing ''='' as in: <%= fields_for instead of <%- fields_for And now everything works, even with :object => @role. -- 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.
Colin Law wrote in post #955764: [...]> Actually it is obvious, look carefully at the Role Name line. What is > it supposed to mean? > > Clue : and '' do not usually go together like that.Wrong. :''Role Name: '' is perfectly legitimate syntax -- it''s the way you type symbol literals that contain characters that aren''t allowed in Ruby identifiers. The meaning is more or less the same as ''Role Name: ''.to_sym . It''s probably not what the OP *wanted*, though. :)> > ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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.
On 20 October 2010 16:11, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #955764: > [...] >> Actually it is obvious, look carefully at the Role Name line. What is >> it supposed to mean? >> >> Clue : and '' do not usually go together like that. > > Wrong. :''Role Name: '' is perfectly legitimate syntax -- it''s the way > you type symbol literals that contain characters that aren''t allowed in > Ruby identifiers. The meaning is more or less the same as ''Role Name: > ''.to_sym .Well, I never new that you could do that, one lives and learns (for the moment anyway). Thanks, Marnen. Colin -- 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.
Colin Law wrote in post #955799:> On 20 October 2010 16:11, Marnen Laibow-Koser <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> ''.to_sym . > Well, I never new that you could do that, one lives and learns (for > the moment anyway). > > Thanks, Marnen.You''re welcome! I think I first came across it when I was developing a Facebook app: FBML tags have the form fb:something (that is, they''re in an XML namespace), and I didn''t want to use a string for a content_tag tag name if I could help it. Obviously, :fb:something doesn''t work, but :''fb:something'' does. You can use a double-quoted string too, and get the expected substitution. Nice way of generating :"#{symbols}" on the fly.> > ColinBest, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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.
Marnen Laibow-Koser wrote in post #955795:> Colin Law wrote in post #955764: > [...] >> Actually it is obvious, look carefully at the Role Name line. What is >> it supposed to mean? >> >> Clue : and '' do not usually go together like that. > > Wrong. :''Role Name: '' is perfectly legitimate syntax -- it''s the way > you type symbol literals that contain characters that aren''t allowed in > Ruby identifiers. The meaning is more or less the same as ''Role Name: > ''.to_sym . > > It''s probably not what the OP *wanted*, though. :) >Actually, that is an artifact of an earlier implementation which used embedded spaces. I just never got around to removing the quote marks. -- 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.