Cookies are not saved

Hi,

I’m developing my first RoR application and working first time with
cookies on RoR.

I create a product object, save it and set the id into the cookie

def create
@image = Image.new(params[:image])

respond_to do |format|
  if @image.save
    @product = Product.new
    @product.image_id = @image.id
    @product.order_id = @order.id
    @product.save
    cookies[:product_id] = @product.id.to_s
    flash[:notice] = 'Image was successfully created.'
    format.html {redirect_to('/karte/waehlen')}
    format.xml  { render :xml => @image, :status => :created,

:location => @image }
else
format.html { render :action => “new” }
format.xml { render :xml => @image.errors, :status =>
:unprocessable_entity }
end
end
end

Then I redirect to the “karte” controller and “waehlen” action

The karte controller looks like this

class KarteController < ApplicationController
def waehlen
@product = Product.find(cookies[:product_id])
@image = Image.find(@product.image_id)
end
end

I try to get the product_id from the cookie.

The waehlen.html.erb looks like

<%= image_tag(@image.filename, :size => "190x153") %>

I get a NoMethodError

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.filename

Extracted source (around line #12):

9:
10:
11:


12: <%= image_tag(@image.filename, :size => “190x153”) %>

I checked the Cookie folder on my filesystem. There is no Cookie.

Do I have activate cookies? I already browsed for the problem, but I
find only information about read/write cookies and other options.

Cheers Adam