I have the following in a Rails 3.0.5 controller: respond_to :html, :xml, :json def index @open_jobs = Job.incomplete @open_jobs_count = @open_jobs.count @late_jobs = Job.past_due @late_jobs_count = @late_jobs.count end However, adding this to the index action doesn''t work: respond_with @open_jobs, @open_jobs_count, @late_jobs, @late_jobs_count I just get a "Template is missing" error. How am I supposed to pass multipe resources to respond_with? -- 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.
Phil On Fri, Mar 11, 2011 at 4:55 PM, Todd A. Jacobs < codegnome.consulting-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have the following in a Rails 3.0.5 controller: > > respond_to :html, :xml, :json > def index > @open_jobs = Job.incomplete > @open_jobs_count = @open_jobs.count > > @late_jobs = Job.past_due > @late_jobs_count = @late_jobs.count > end > > However, adding this to the index action doesn''t work: > > respond_with @open_jobs, @open_jobs_count, @late_jobs, > @late_jobs_count > > I just get a "Template is missing" error. How am I supposed to pass > multipe resources to respond_with? >"Template is missing" should not be related to the multiple resources (afaik). Do you have an index template? I''m curious why you''re using respond_with at all; the instance variables will all be available in the views without that...> > -- > 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. > >-- 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 Mar 11, 3:04 pm, Phil Crissman <phil.criss...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> "Template is missing" should not be related to the multiple resources > (afaik). Do you have an index template?Yes, I have an index template.> I''m curious why you''re using respond_with at all; the instance variables > will all be available in the views without that...Because you need format or respond_with to generate xml or json views dynamically. -- 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 Mar 11, 10:55 pm, "Todd A. Jacobs" <codegnome.consult...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have the following in a Rails 3.0.5 controller: > > respond_to :html, :xml, :json > def index > @open_jobs = Job.incomplete > @open_jobs_count = @open_jobs.count > > @late_jobs = Job.past_due > @late_jobs_count = @late_jobs.count > end > > However, adding this to the index action doesn''t work: > > respond_with @open_jobs, @open_jobs_count, @late_jobs, > @late_jobs_count > > I just get a "Template is missing" error. How am I supposed to pass > multipe resources to respond_with?I don''t think you can - if you do say respond_with @person, @comments then rails thinks you are talking about nested resources, whereas you have separate resources The other problem you have here is that some of the things you are passing (eg those integers) aren''t resources, which may well confuse things Personally, my understanding is that respond_with is there to deal with the really common case, if you have something more exotic there''s nothing wrong with falling back to some more traditional respond_to stuff Fred -- 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.