I have nested model like following:
class Project < ActiveRecord::Base
has_many :tasks
accepts_nested_attributes_for :tasks
end
class Project::Task < ActiveRecord::Base
attr_accessible :task_id, :name
belongs_to :Project
end
I have json data coming from outside:
"project": {
"name": "My Project Name",
"tasks": [
{"name": "Design prototype"},
{"name": "Home page UI prototype"},
{"name": "Other Miscellaneous task"}
]
}
How can I create controller in Rails 4 which receives above json data as POST vars and store it in DB?