Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 22

Show
Ignore:
Timestamp:
11/26/04 02:11:42 (4 years ago)
Author:
david
Message:

Allow symbols to be used as names for setting cookies

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/cookies.rb

    r21 r22  
    3737    # or cookies[]= (for simple name/value cookies without options). 
    3838    def [](name) 
    39       @cookies[name].value if @cookies[name
     39      @cookies[name.to_s].value if @cookies[name.to_s
    4040    end 
    4141     
     
    4343      if options.is_a?(Hash) 
    4444        options.each { |key, value| options[key.to_s] = value } 
    45         options["name"] = name 
     45        options["name"] = name.to_s 
    4646      else 
    4747        options = [ name, options ] 
  • trunk/actionpack/test/controller/cookie_test.rb

    r21 r22  
    1919 
    2020    def authenticate_for_fourten_days_with_symbols 
    21       cookies["user_name"] = { :value => "david", :expires => Time.local(2005, 10, 10) } 
     21      cookies[:user_name] = { :value => "david", :expires => Time.local(2005, 10, 10) } 
    2222      render_text "hello world" 
    2323    end