rails 1.2.3
code :
in controller:
cookies[:test] = 1
@cookies = cookies
in view:
<%=@cookies[:test].class.to_s%>
<%=cookies[:text].class.to_s%>
output:
String Array
rails 1.2.3
code :
in controller:
cookies[:test] = 1
@cookies = cookies
in view:
<%=@cookies[:test].class.to_s%>
<%=cookies[:text].class.to_s%>
output:
String Array
[email protected] wrote:
in view:
<%=@cookies[:test].class.to_s%>
<%=cookies[:text].class.to_s%>output:
String Array
Did you type that in wrong? You have two different key names there.
ā
Michael W.
Guest wrote:
rails 1.2.3
code :
in controller:cookies[:test] = 1
@cookies = cookiesin view:
<%=@cookies[:test].class.to_s%>
<%=cookies[:text].class.to_s%>output:
String Array
sorry , type wrong
the cookies in view is a Hash
the cookies in controller is a ActionController::CookieJar
now , how to use cookies in the view?
thank you.
Michael W. wrote:
[email protected] wrote:
in view:
<%=@cookies[:test].class.to_s%>
<%=cookies[:text].class.to_s%>output:
String ArrayDid you type that in wrong? You have two different key names there.
ā
Michael W.
thank you .
your name looks like a chinese , and iām too.
nice to meet you.
i was resolved this issure:
in controllers/application.rb
add a class method
helper_method :cookies
the cookies method in view will work correct.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs