Hi Few things
The error is in your route. You have a resource slideshow, you need to tell them you have a non standard action Either uncomment the :controller/:action line or add a :collection => 'show_slide' to the resource :slideshow line. One thing to note Put the slideshow I'd into the session, not the slideshow object. Also, the whole session thing doesn't look right. No reason to be anti- ReSTful If the URL were to read: /slideshow/5/slide/1 (rwad: first picture of slideshow #5) Then the session would go away and the Javascript would only become margionally more complex That uses nested routes and no custom actions or anything. Anyone have a good link for an example of this or suggestion that I'm taking the rest thing too far? Best of luck. On cell phone so sorry I can't research this right now. --Keenan On Feb 22, 2009, at 4:32 PM, Mark <[email protected]> wrote: > > I am a RoR neophyte, and my first foray into Ajax has not gone well. I > am working on an example out of the book Rails Up and Running, and > while I have faithfully replicated the code, nothing seems to be > working. > > Here are the code fragments: > app/controllers/slideshows_controller.rb (partial) > > def show > @slideshow = Slideshow.find(params[:id]) > session[:slideshow] = @slideshow > session[:slide_index] = 0 > @slide = @slideshow.slides[0] > end > > def show_slide > @slideshow = session[:slideshow] > session[:slide_index] += 1 > @slide = @sildeshow.slides[session[:slide_index]] > if @slide == nil > session[:slide_index] = 0 > @slide = @slideshow.slides[0] > end > render :partial => "show_slide" > end > > > app/views/slideshows/show.html.erb > <p><i><%=h @slideshow.name %></i></p> > > <% if @slide %> > <div id="slides"> > <%= render :partial => "show_slide" %> > </div> > > <%= periodically_call_remote :update => "slides", > :url => { :action => :show_slide }, > :frequency => 2.0 %> > > <% end %> > > > app/views/slideshows/_show_slide.html.erb > > <%= image_tag "photos/#[email protected]}" %> > <p><%= @slide.photo.filename %></p> > > > app/views/layouts/application.html.erb (partial) > > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> > <head> > <meta http-equiv="content-type" content="text/html;charset=UTF-8" /> > <title>Photos: <%= controller.action_name %></title> > <%= javascript_include_tag :defaults %> > <%= stylesheet_link_tag 'application', 'photos' %> > <%= stylesheet_link_tag 'slideshows' %> > </head> > > Instead of a nice slideshow in Ajax, I get the following text with > photo info: > > Basket > > basket.jpg > > > and then this error: > > NoMethodError in SlideshowsController#show_slide > > You have a nil object when you didn't expect it! > The error occurred while evaluating nil.slides > > Any help would be greatly appreciated. > > Mark > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Heroku" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/heroku?hl=en -~----------~----~----~----~------~----~------~--~---
