When I'm sending data to my controller I'm getting the following error
with the parameters
{"title"=>"some",
"user_id"=>"2",
"task"=>{"title"=>"some"}}
Why is that so? And what's the difference between respond_to and respond_with in Rails?
class TasksController < ApplicationController
respond_to :json
def create
respond_with current_user.tasks.create(task_params)
end
private
def task_params
params.require(:task).permit(:id, :title, :due_date, :priority, :complete)
end
end
When I'm using respond_to it says Undefined method upcase for Task
It's saying it doesn't recognize the format of your response. Since
respond_with current_user.tasks.create(task_params)
will generate ahtml
response.In your routes.rb change
to
This question may help you
Try this one: