Witam.
Utworzyłem podstawową apkę w emberjs. Następnie template poprzez ember g scaffold… Wyświetlanie itemków/usuwanie działa, natomiast edycja, dodanie nowej nie. Co jest źle z tym API ?
module API
module V1
class Projects < Grape::API
include API::V1::Defaults
resource :projects do
desc "Return all projects"
get "", root: :projects do
Project.all
end
desc "Return a project"
params do
requires :id, type: String, desc: "ID of the project"
end
get ":id", root: "project" do
Project.where(id: permitted_params[:id]).first!
end
desc "Create a project."
params do
requires :name, type: String, desc: "Name of project."
requires :user_id, type: String, desc: "user id"
requires :description, type: String, desc: "Description of project"
requires :project_type_id, type: String, desc: "Type of project"
end
post do
Project.create!({
name: params[:name],
user_id: params[:user_id],
description: params[:description],
project_type_id: params[:project_type_id]
})
end
desc "Update a project."
params do
requires :id, type: String, desc: "project ID."
requires :name, type: String, desc: "Name of project."
requires :user_id, type: String, desc: "user id"
requires :description, type: String, desc: "Description of project"
requires :project_type_id, type: String, desc: "Type of project"
end
put ':id' do
Project.find(params[:id]).update({
name: params[:name],
user_id: params[:user_id],
description: params[:description],
project_type_id: params[:project_type_id]
})
end
desc "Delete a project."
params do
requires :id, type: String, desc: "project ID."
end
delete ':id' do
Project.find(params[:id]).destroy
end
end
end
end
end