$ head app/views/foo/*
==> app/views/foo/_foo.html.erb <==
<%= foo_counter %>
==> app/views/foo/index.html.erb <==
<%= render :partial => "foo", :locals => {:foo_counter => 3} %>
で、2.2.2 だと
$ ruby script/console production
Loading production environment (Rails 2.2.2)
>> app.tap{|a| a.get("/foo")}.response.body
=> "3\n\n"
なんだけど、2.1.2 だと
$ ruby script/console production
Loading production environment (Rails 2.1.2)
>> app.tap{|a| a.get("/foo")}.response.body
=> "0\n\n"
なのは、がいしゅつ?
追記:pingooさんに教えていただきました。
http://www.nabble.com/Partial-loop-counter-in-Rails-2.1-td18784146.html
$ head app/controllers/foo_controller.rb app/views/foo/index.rhtml
==> app/controllers/foo_controller.rb <==
class FooController < ApplicationController
def index
flash[:message] = "Hoge"
flash.discard(:message)
end
end
==> app/views/foo/index.rhtml <==
Flash: <%= flash[:message] %>
で、
$ ruby script/console production
Loading production environment.
>> RAILS_GEM_VERSION
=> "1.2.6"
>> app.tap{|a| a.get("/foo")}.response.body
=> "Flash: Hoge\n"
>> app.controller.__send__(:flash)
=> {}
だったのが、
$ ruby script/console production
Loading production environment (Rails 2.2.2)
>> app.tap{|a| a.get("/foo")}.response.body
=> "Flash: Hoge\n"
>> app.controller.__send__(:flash)
=> {:message=>"Hoge"}
だったりしてまいる。
$ ruby script/console production
Loading production environment (Rails 2.3.2)
>> app.tap{|a| a.get("/foo")}.response.body
=> "Flash: Hoge\n"
>> app.controller.__send__(:flash)
=> {}
もう 2.3.2 を使うしか?