Reputation: 168
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(task4)
task.save
end
Upvotes: 2
Views: 62
Reputation: 3807
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.
Upvotes: 3