开发者

POSTing from a controller. Need help

I have a bit of a strange situation. I am currently in the process of modifying fat_free_crm for a client. They want a lightweight CRM which will automatically create a few followup tasks in the weeks following a customer's entry into the system. In the Contacts Controller, I am writing a method to run when the create action is performed. I would like this action to automatically create the four necessary tasks. I have the data saved in several hashes.

Is there a way that I can do these extra queries without changing pages? As it is, the query to create the contact is going through perfectly but Task.new(hash_name).save doesn't seem to function as intended or at least, as I intended.

Any ideas?

def autotask(user,contact)
  user.id
  t=Time.now
  task1 = [
    :hash_data => here
  ]

  task2 =[
    :hash_data => here
  ]

  task3 =[
    :hash_data => here
  ]

  task4 =[
      :hash_data => here
  ]

  task=Task.new(task1)
  task.save
  task=Task.new(task2)
  task.save
  task=Task.new(task3)
  task.save
  task=Task.new(t开发者_运维技巧ask4)
  task.save
end


task1 = [
    :hash_data => here
  ]

makes task1 an Array instead of a Hash. If you want a hash instead, you will need to change the brackets to curly braces:

task1 = {
    :hash_data => here
  }

The constructor only accepts hash and will ignore the array.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜