Forum: Ruby on Rails Page does not seem to be reloaded on prod server

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Joshua M. (Guest)
on 2008-10-28 20:07
Hi all

I've coded a small shop that works well on my dev machine (OSX 10.5).

But look at the following page:

http://shop.incense.ch/compact_discs/1

When clicking "Reservieren", the page is forwarded to a new page, where
the product is added to the shopping cart, and a flash notice is
prepare. Then the page is redirected back to the shop page.

On my dev machine this works well. But on the production server this
doesn't seem to work! But look what happens when you click on another
link, e.g. "Kontakt"! There the stuff seems to be!
What the heck? Never stumbled over this before...

Anyone has an idea what's wrong here?

Thanks
Josh
Hubert Łępicki (Guest)
on 2008-10-28 20:59
(Received via mailing list)
Hi Josh,

could you post some source code (of "add" action for example) and some
more info about your production env? Do you display flash messages in
your layout or view files? If in view files, do you include it on the
page where it is missing?

Best,
Hubert

On 28 Pa¼, 19:07, Joshua M. <removed_email_address@domain.invalid>
Joshua M. (Guest)
on 2008-10-29 19:45
> could you post some source code (of "add" action for example)

  def add
    session[:ordered_compact_disc_ids] ||= []
    compact_disc = CompactDisc.find(params[:id])
    if compact_disc.quantity > 0
      session[:ordered_compact_disc_ids].push(compact_disc.id)
      flash[:notice] = "CD '#{compact_disc.display_title}' zu Warenkorb
hinzugefügt. Um den Warenkorb an zu schauen, bitte den Link 'Warenkorb'
rechts oben klicken."
    else
      flash[:notice] = "CD '#{compact_disc.display_title}' ist leider
nicht mehr verfügbar."
    end
    redirect_to(compact_disc_path(compact_disc))
  end

> and some
> more info about your production env?

It's a shared hoster, www.cyon.ch, everything should be OK there I
guess. I'm using Rails >2 and a MySQL db.

Any more infos needed?

> Do you display flash messages in
> your layout or view files? If in view files, do you include it on the
> page where it is missing?

I display the flash messages in my layouts/application.rhtml view, which
is my only layout.

I just created a new app on the server using the tools that are
available, and there with a simple people-scaffold flashes etc. seem to
work without any problem...
Joshua M. (Guest)
on 2008-10-29 20:01
I did a

tail -f log/production.log

and watched the log while clicking on the "Reservieren" Button.
Everything seems OK, I'm getting normal logs:

Processing CartController#add (for 212.41.91.181 at 2008-10-29 18:54:24)
[GET]
  Session ID:
BAh7Bzodb3JkZXJlZF9jb21wYWN0X2Rpc2NfaWRzWxBpMmkyaTJpMmkyaTJp
MmkyaTJpMmkyIgpmbGFzaElDOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6
Rmxhc2hIYXNoewY6C25vdGljZSIBlENEICdDb20gLSBIaWdoIFZvbHRhZ2Ug
SG91c2UgTXVzaWMgKDJDRCknIHp1IFdhcmVua29yYiBoaW56dWdlZsO8Z3Qu
IFVtIGRlbiBXYXJlbmtvcmIgYW4genUgc2NoYXVlbiwgYml0dGUgZGVuIExp
bmsgJ1dhcmVua29yYicgcmVjaHRzIG9iZW4ga2xpY2tlbi4GOgpAdXNlZHsG
OwdG--786b160f3fa0dc9f9e025d460bca95fe6fd226f6
  Parameters: {"action"=>"add", "id"=>"45", "controller"=>"cart"}
Redirected to http://shop.incense.ch/compact_discs/45
Completed in 0.00154 (649 reqs/sec) | DB: 0.00091 (58%) | 302 Found
[http://shop.incense.ch/cart/add/45]

========> No flash is displayed


Processing CartController#add (for 212.41.91.181 at 2008-10-29 18:54:25)
[GET]
  Session ID:
BAh7Bzodb3JkZXJlZF9jb21wYWN0X2Rpc2NfaWRzWxFpMmkyaTJpMmkyaTJp
MmkyaTJpMmkyaTIiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNo
OjpGbGFzaEhhc2h7BjoLbm90aWNlIgGUQ0QgJ0NvbSAtIEhpZ2ggVm9sdGFn
ZSBIb3VzZSBNdXNpYyAoMkNEKScgenUgV2FyZW5rb3JiIGhpbnp1Z2Vmw7xn
dC4gVW0gZGVuIFdhcmVua29yYiBhbiB6dSBzY2hhdWVuLCBiaXR0ZSBkZW4g
TGluayAnV2FyZW5rb3JiJyByZWNodHMgb2JlbiBrbGlja2VuLgY6CkB1c2Vk
ewY7B0Y=--c078843aa25fb7b31d43846b43e7e2d1532b5120
  Parameters: {"action"=>"add", "id"=>"45", "controller"=>"cart"}
Redirected to http://shop.incense.ch/compact_discs/45
Completed in 0.00137 (730 reqs/sec) | DB: 0.00086 (62%) | 302 Found
[http://shop.incense.ch/cart/add/45]

========> No flash is displayed


Processing CompactDiscsController#index (for 212.41.91.181 at 2008-10-29
18:54:29) [GET]
  Session ID:
BAh7Bzodb3JkZXJlZF9jb21wYWN0X2Rpc2NfaWRzWxJpMmkyaTJpMmkyaTJp
MmkyaTJpMmkyaTJpMiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxh
c2g6OkZsYXNoSGFzaHsGOgtub3RpY2UiAZRDRCAnQ29tIC0gSGlnaCBWb2x0
YWdlIEhvdXNlIE11c2ljICgyQ0QpJyB6dSBXYXJlbmtvcmIgaGluenVnZWbD
vGd0LiBVbSBkZW4gV2FyZW5rb3JiIGFuIHp1IHNjaGF1ZW4sIGJpdHRlIGRl
biBMaW5rICdXYXJlbmtvcmInIHJlY2h0cyBvYmVuIGtsaWNrZW4uBjoKQHVz
ZWR7BjsHRg==--587f09afeb0519059216fd16af66614ee5da117a
  Parameters: {"action"=>"index", "controller"=>"compact_discs"}
Rendering template within layouts/application
Rendering compact_discs/index
Completed in 0.01801 (55 reqs/sec) | Rendering: 0.00267 (14%) | DB:
0.01058 (58%) | 200 OK [http://shop.incense.ch/compact_discs/]

========> Flash is displayed (we're on the index page now)
Joshua M. (Guest)
on 2008-10-29 20:03
OK, I'm getting closer...

On my local machine, a click on the "Reservieren" link provoces Rails to
render two pages, as it seems from the log:

Processing CartController#add (for 127.0.0.1 at 2008-10-29 19:00:06)
[GET]
  Session ID:
BAh7CjoPbG9nZ2VkX2luP1Q6FHJlZGlyZWN0X3RvX3VybCIML29yZGVyczoM%0AY3NyZl9pZCIlODRhMjcyMDVkNDkwMDRlYTE1MzEyYjljZGY3OGVjOWQ6HW9y%0AZGVyZWRfY29tcGFjdF9kaXNjX2lkc1sKaRhpGGkvaS9pLyIKZmxhc2hJQzon%0AQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7%0AAA%3D%3D--9793d460b6529b998d4827aadc7c93d405b3bdec
  Parameters: {"action"=>"add", "id"=>"43", "controller"=>"cart"}
  ^[[4;36;1mCompactDisc Columns (0.003871)^[[0m   ^[[0;1mSHOW FIELDS
FROM `compact_discs`^[[0m
  ^[[4;35;1mCompactDisc Load (0.000924)^[[0m   ^[[0mSELECT * FROM
`compact_discs` WHERE (`compact_discs`.`id` = 43) ^[[0m
Redirected to http://localhost:3000/compact_discs/43
Completed in 0.01200 (83 reqs/sec) | DB: 0.00480 (39%) | 302 Found
[http://localhost/cart/add/43]


Processing CompactDiscsController#show (for 127.0.0.1 at 2008-10-29
19:00:06) [GET]
  Session ID:
BAh7CjoPbG9nZ2VkX2luP1Q6DGNzcmZfaWQiJTg0YTI3MjA1ZDQ5MDA0ZWEx%0ANTMxMmI5Y2RmNzhlYzlkOhRyZWRpcmVjdF90b191cmwiDC9vcmRlcnM6HW9y%0AZGVyZWRfY29tcGFjdF9kaXNjX2lkc1sLaRhpGGkvaS9pL2kwIgpmbGFzaElD%0AOidBY3Rpb25Db250cm9sbGVyOjpGbGFzaDo6Rmxhc2hIYXNoewY6C25vdGlj%0AZSIBikNEICdWYXJpb3VzIEFydGlzdHMgLSBDaG9zZW4gMycgenUgV2FyZW5r%0Ab3JiIGhpbnp1Z2Vmw7xndC4gVW0gZGVuIFdhcmVua29yYiBhbiB6dSBzY2hh%0AdWVuLCBiaXR0ZSBkZW4gTGluayAnV2FyZW5rb3JiJyByZWNodHMgb2JlbiBr%0AbGlja2VuLgY6CkB1c2VkewY7ClQ%3D--6947e65cd6a49398180926b4e276fbacf12fdb20
  Parameters: {"action"=>"show", "id"=>"43",
"controller"=>"compact_discs"}
  ^[[4;36;1mCompactDisc Columns (0.002575)^[[0m   ^[[0;1mSHOW FIELDS
FROM `compact_discs`^[[0m
  ^[[4;35;1mCompactDisc Load (0.000940)^[[0m   ^[[0mSELECT * FROM
`compact_discs` WHERE (`compact_discs`.`id` = 43) ^[[0m
Rendering template within layouts/application
Rendering compact_discs/show
  ^[[4;36;1mGenre Columns (0.001683)^[[0m   ^[[0;1mSHOW FIELDS FROM
`genres`^[[0m
  ^[[4;35;1mGenre Load (0.000474)^[[0m   ^[[0mSELECT * FROM `genres`
WHERE (`genres`.`id` = 2) ^[[0m
  ^[[4;36;1mCompactDisc Load (0.009509)^[[0m   ^[[0;1mSELECT * FROM
`compact_discs` ^[[0m
  ^[[4;35;1mCACHE (0.000000)^[[0m   ^[[0mSELECT * FROM `compact_discs`
^[[0m
  ^[[4;36;1mGenre Load (0.000629)^[[0m   ^[[0;1mSELECT * FROM `genres`
^[[0m
  ^[[4;35;1mCACHE (0.000000)^[[0m   ^[[0mSELECT * FROM `compact_discs`
^[[0m
Rendered compact_discs/_statistics (0.02044)
Completed in 0.09845 (10 reqs/sec) | Rendering: 0.02061 (20%) | DB:
0.01581 (16%) | 200 OK [http://localhost/compact_discs/43]

But on the production server it's only one rendering:

Processing CartController#add (for 212.41.91.181 at 2008-10-29 19:00:30)
[GET]
  Session ID:
BAh7CjoPbG9nZ2VkX2luP1Q6FHJlZGlyZWN0X3RvX3VybCIML29yZGVyczod
b3JkZXJlZF9jb21wYWN0X2Rpc2NfaWRzWw9pXmk5aTlpDmkOaQ5pDmkOaTBp
MDoMY3NyZl9pZCIlYjA2ZTk2M2MzMGFmZWUxZTQ5MDZiOGYxNjM3OTdkNmEi
CmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhhc2h7
BjoLbm90aWNlIgGKQ0QgJ1ZhcmlvdXMgQXJ0aXN0cyAtIENob3NlbiAzJyB6
dSBXYXJlbmtvcmIgaGluenVnZWbDvGd0LiBVbSBkZW4gV2FyZW5rb3JiIGFu
IHp1IHNjaGF1ZW4sIGJpdHRlIGRlbiBMaW5rICdXYXJlbmtvcmInIHJlY2h0
cyBvYmVuIGtsaWNrZW4uBjoKQHVzZWR7BjsKRg==--dfab3309b1521a0f661186c03d0a6a06533ea09d
  Parameters: {"action"=>"add", "id"=>"43", "controller"=>"cart"}
Redirected to http://shop.incense.ch/compact_discs/43
Completed in 0.00137 (728 reqs/sec) | DB: 0.00101 (73%) | 302 Found
[http://shop.incense.ch/cart/add/43]

Maybe it's a caching problem...?
Joshua M. (Guest)
on 2008-10-29 20:10
Yes, it's definitely a caching problem. In production mode the whole
page is cached, so it is loaded from public/compact_discs/xxx and so the
flash is not displayed. What a newbie mistake... :-)

Thanks anyway for help.
This topic is locked and can not be replied to.