Reputation: 7835
I'm submitting a form to create a new record of my SpecialDeal model. The params submitted look like this:
@_params
{"utf8"=>"✓", "authenticity_token"=>"cl1SwnHOum8d/kiGnwkDsamG5IMbmdnoeFvlY11KpKc=", "special_deal"=>{"title"=>"5", "provider"=>"5", "description"=>"5", "deal_price"=>"", "conditions"=>"", "expires"=>"07/18/2013 14:38:18", "excerpt"=>"", "original_price"=>"", "phone_number"=>"", "street"=>"", "city"=>"", "postal_code"=>"", "state"=>"", "country"=>""}, "commit"=>"Create Special deal", "action"=>"create", "controller"=>"special_deals"}
Yet when I try to make a variable out of the expires
param...
def create
expiration = params[:expires]
That variable always sets itself as nil!
Local Variables
expiration: nil
Why is this happening?
Upvotes: 0
Views: 65
Reputation: 5734
As I commented earlier it. Now adding it as my answer ;)
def create
expiration = params["special_deal"]["expires"]
# Your code goes here
end
Upvotes: 2
Reputation: 91
expires is in inner hash which is under 'special_deal' key so try
def create
expiration = params[:special_deal][:expires]
i'm assuming you are using rails params
Upvotes: 3