Reloading a div with a changed session variable

New to this, so bear with me.

Controller:

def show
@client = Client.find_by_permalink(params[:permalink])
@images = ClientImage.find_all_by_client_id(@client, :order => “id
ASC”)
session[:client] = @client
if session[:image].blank?
session[:image] = @images[0]
end
end

def view_image
@image = ClientImage.find_by_id(params[:id])
session[:image] = @image
end

View:

<%= image_tag url_for_file_column(session[:image], “image”), :alt =>
@client.name %>

RJS:

page[:content_top].reload

I thought that reloading the div after changing the session variable out
would cause a new image to display, but it does nothing.

What button/link are you hitting that you want to reload the page
with? What is the name of the function? What is the name of the
view? What is the name of the controller? What is the name of the
RJS file? Are you passing in info from the app to reload it?

On 5/18/07, Aaron W. [email protected] wrote:

if session[:image].blank?

I thought that reloading the div after changing the session variable out
would cause a new image to display, but it does nothing.


Posted via http://www.ruby-forum.com/.


Amos K.
Ramped Media
USPS
Programmer/Analyst
St. Louis, MO
Looking for something to do? Visit ImThere.com

What button/link are you hitting that you want to reload the page with?

This creates a list of all the images in the client_images table
associated with that client. It appears just below “content_top”.

    <% if @images.length > 1 %> <% @images.each_with_index do |image, index| %> <%= link_to_remote index + 1, { :url => { :action => 'view_image', :id => image } }, { :href => url_for(:action => 'view_image', :id => image ) } %> <% end %> <% end %>

What is the name of the function? What is the name of the
view? What is the name of the controller? What is the name of the
RJS file?

Everything is under the Client controller.

This all takes place under the ‘show’ view and action, ‘view_image’ is
the action to cycle out images and is also the name of the RJS.

Are you passing in info from the app to reload it?

Yes. The value of the image to be changed is passed to the
session[:image] variable.

The idea is that by default the image shown is the oldest one associated
with that client. @image is stored in a session variable
(session[:image]) and called in the image_tag at the top. If a link in
the ul is clicked, the ID of the image is passed to the ‘view_image’
action.

The view_image action assigns this new image to the session[:image]
variable and the RJS reloads the div ‘content_top’.

hi
i have a quick question for you if you could help me with it.
my view is previously set up like this :

<%= link_to( image_tag(session[:slide_array]
[session[:slide_index]], :size => “580x146”), session[:slide_link]
[session[:slide_index]] ) %>

where do slide_array and slide_link reside?..It is basically a
slideshow of images and I have to take off some of the pictures and
modify them. But I don’t know how to access slide_array.

I tried to read up on link_to’s and image_tag’s APIs, didn’t really
help.

Any help would be appreciated.

Thank you

On May 18 2007, 12:01 pm, Aaron W. <rails-mailing-l…@andreas-

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs