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
-~----------~----~----~----~------~----~------~--~---

Reply via email to