Forum: Ruby Rails AJAX question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
on 2006-02-10 06:53
(Received via mailing list)
Hi all, It must be a very simple solution, but i'm just not getting it.
I want to display some picture continously on a page using Rail+AJAX.
Here is the snippet of code:

 def show
    @albums = Album.find(:all)
    @size =  @albums.length

def show_next
    @id = params[:cur_id].to_i
    @size =  params[:max].to_i
    if ( @id == 0 or ir @id > @size)
      @id = 1

    @album = Album.find(@id)
    @id += 1

       Continous picture display<br>
   <%= periodically_call_remote(:update    => 'mydiv',
                             :url       => { :action => :show_next,
:cur_id =>  @id, :max => @size},
                             :frequency => 2 )
   <div id="mydiv">
     image will display here


def show_next
  <img width="600" height="200" src="<%= @album .image_url %>"/>


But the @id is not being updated. I think I need to store the @id
statically in the html page (may as hidden field), but is there any
better solution for this

thanks in avdvance
unknown (Guest)
on 2006-02-10 07:15
(Received via mailing list)
On Friday 10 February 2006 01:53 pm, removed_email_address@domain.invalid wrote:


anne001 (Guest)
on 2006-02-10 14:23
(Received via mailing list)
I liked this tutorial, it has a nice example on the lack of memory of
web applications

I have been working with a controller code as such
   if params.has_key? :id
         @stimuliobj=Stimuli.find(params[:id].to_i + 1)
         @stimuliobj = Stimuli.find(:first)

with a form in the view
 <%= start_form_tag(:action => "hello") %>
  <%= hidden_field_tag "id", %>
    <%= text_field("responseobj", "name", "size" => "20") %>
    <%= submit_tag("Name") %>
    <% end_form_tag %>

you can use
render_text params.inspect
in your show_next method to see what your parameter hash is like. I am
not sure if an action redirect can transmit parameters.
This topic is locked and can not be replied to.