Hey guys, I''m having a little trouble working out partials. I have successfully made a partial work in my list.rhtml, but as I see it on the 15min introductry video. They guy uses one partial on multipul pages. At the moment I am trying this in my show.rhtml, I write <%= render :partial => "journal" %> and I get this. NoMethodError in Write#show> > Showing *app/views/write/_journal.rhtml* where line *#1* raised: > > undefined method `each'' for #<Write:0x333c9a0> > > Extracted source (around line *#1*): > > 1: <% for write in @write %> > 2: <div> > 3: <h2><%= link_to write.title, :action => ''show'', :id => write %></h2> > 4: <span><%= write.date.to_s(:long) %></span> > > Trace of template inclusion: /app/views/write/show.rhtml > > RAILS_ROOT: C:/source/lifejournal/public/../config/.. >If anyone has any answers, please help a n00b. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060118/fcb93575/attachment-0001.html
I''d venture to guess that @write is a single ActiveRecord object, not a collection. If it *is* a collection, you should have named it @writes, at the very least. Note: It''s not the naming that caused me to suggest the problem, but it''s a separate rant of its own. :-) -- -- Tom Mornini On Jan 18, 2006, at 1:43 AM, levi mccallum wrote:> Hey guys, > > I''m having a little trouble working out partials. > I have successfully made a partial work in my list.rhtml, but as I > see it on the 15min introductry video. They guy uses one partial on > multipul pages. > > At the moment I am trying this in my show.rhtml, I write <%= > render :partial => "journal" %> and I get this. > > NoMethodError in Write#show > > Showing app/views/write/_journal.rhtml where line #1 raised: > > undefined method `each'' for #<Write:0x333c9a0> > Extracted source (around line #1): > > 1: <% for write in @write %> > 2: <div> > 3: <h2><%= link_to write.title, :action => ''show'', :id => write % > ></h2> > 4: <span><%= write.date.to_s(:long) %></span> > > Trace of template inclusion: /app/views/write/show.rhtml > > RAILS_ROOT: C:/source/lifejournal/public/../config/.. > > > If anyone has any answers, please help a n00b. > > Thanks > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060118/54891db2/attachment.html
Hi Tom, Just one problem with that, every time I rename it to @writes. I get a null error on all my partials. Thans On 1/18/06, Tom Mornini <tmornini@infomania.com> wrote:> > I''d venture to guess that @write is a single ActiveRecord object, not a > collection. > If it *is* a collection, you should have named it @writes, at the very > least. > > Note: It''s not the naming that caused me to suggest the problem, but it''s > a > separate rant of its own. :-) > > -- > -- Tom Mornini > > > On Jan 18, 2006, at 1:43 AM, levi mccallum wrote: > > Hey guys, > > I''m having a little trouble working out partials. > I have successfully made a partial work in my list.rhtml, but as I see it > on the 15min introductry video. They guy uses one partial on multipul pages. > > At the moment I am trying this in my show.rhtml, I write <%= render > :partial => "journal" %> and I get this. > > NoMethodError in Write#show > > > > Showing *app/views/write/_journal.rhtml* where line *#1* raised: > > > > undefined method `each'' for #<Write:0x333c9a0> > > > > Extracted source (around line *#1*): > > > > 1: <% for write in @write %> > > 2: <div> > > 3: <h2><%= link_to write.title, :action => ''show'', :id => write %></h2> > > 4: <span><%= write.date.to_s(:long) %></span> > > > > Trace of template inclusion: /app/views/write/show.rhtml > > > > RAILS_ROOT: C:/source/lifejournal/public/../config/.. > > > > If anyone has any answers, please help a n00b. > > Thanks > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060118/ff274bcb/attachment.html
Must be a keyword collision. Pick a different name. :-) -- -- Tom Mornini On Jan 18, 2006, at 1:59 AM, levi mccallum wrote:> Hi Tom, > > Just one problem with that, every time I rename it to @writes. I > get a null error on all my partials. > > Thans > > On 1/18/06, Tom Mornini <tmornini@infomania.com> wrote: > I''d venture to guess that @write is a single ActiveRecord object, > not a collection. > > If it *is* a collection, you should have named it @writes, at the > very least. > > Note: It''s not the naming that caused me to suggest the problem, > but it''s a > separate rant of its own. :-) > > -- > -- Tom Mornini > > > On Jan 18, 2006, at 1:43 AM, levi mccallum wrote: > >> Hey guys, >> >> I''m having a little trouble working out partials. >> I have successfully made a partial work in my list.rhtml, but as I >> see it on the 15min introductry video. They guy uses one partial >> on multipul pages. >> >> At the moment I am trying this in my show.rhtml, I write <%= >> render :partial => "journal" %> and I get this. >> >> NoMethodError in Write#show >> >> Showing app/views/write/_journal.rhtml where line #1 raised: >> >> undefined method `each'' for #<Write:0x333c9a0> >> Extracted source (around line #1): >> >> 1: <% for write in @write %> >> 2: <div> >> 3: <h2><%= link_to write.title, :action => ''show'', :id => write % >> ></h2> >> 4: <span><%= write.date.to_s >> (:long) %></span> >> >> Trace of template inclusion: /app/views/write/show.rhtml >> >> RAILS_ROOT: C:/source/lifejournal/public/../config/.. >> >> >> If anyone has any answers, please help a n00b. >> >> Thanks >> >> >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060118/1d78a8e0/attachment-0001.html