我将以下参数传递给控制器。我该如何处理呢。
{"utf8"=>"✓",
"_method"=>"put",
"authenticity_token"=>"PG7U0PkCb1LViWkUWNV0lKuPWfVKM/Kl4T+zW4Eaaq8=",
"campaign"=>{"2"=>{"status"=>"Approved",
"notes"=>""},
"1"=>{"status"=>"Approved",
"notes"=>""}},
"Commit"=>"Process"}
我的目的是提取每个广告系列,阅读状态并将该记录重定向到拒绝并根据其内容批准控制器。
答案 0 :(得分:1)
params['campaign'].each do |id, attributes|
puts "Campaign id equals #{id} and status is #{attributes['status']}"
# Campaign.find(id).update(attributes)
if attributes['status'] == 'Approved'
reirect_to approved_campaign_path id
else
reirect_to rejected_campaign_path id
end
end