나는 RoR을 수년간 해왔지만, 이것은 Mongo (내 첫 번째 api 전용 프로젝트)의 첫 번째 프로젝트입니다. 저는 HABTM 협회와 어색한 시간을 보냈고 params와 관련이 있다고 생각합니다. 그러나 그 밖의 무엇을 시도해야할지 모르겠습니다. 여기 Mongoid 6, Rails 5, HABTM "unpermitted parmeter"
내가있어 무엇 :def project_params
params.permit(:id, :name, :start_date, :target_date, :description, user_ids: [])
end
을 그리고 그래, 나 또한 {user_ids 일을 시도했다 : 내 프로젝트 컨트롤러에서
class Project
include Mongoid::Document
field :name, type: String
field :start_date, type: Date
field :target_date, type: Date
has_and_belongs_to_many :users
end
class User
include Mongoid::Document
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable,
:jwt_authenticatable, jwt_revocation_strategy: JWTBlacklist
field :email, type: String
field :_id, type: String, default: ->{ email }
{ ... devise stuff ...}
has_and_belongs_to_many :projects
end
, 나는 매개 변수이있다 []를 }.
우편 배달부를 사용하여 사용자를 프로젝트에 추가하려고하는 URL PUT 요청을 만들 때 "허용되지 않은 매개 변수"오류가 발생합니다. 하지만 ... 나는 그 매개 변수를 허용하고 있습니다. 맞습니까?
Mongo 문제, Rails 5 문제 또는 API 문제가 있는지 알 수 없기 때문에 나는 일종의 견해가 없습니다. 다른 모든 통화는 정상적으로 작동합니다.
Started PUT "/rapi/projects/3" for 127.0.0.1 at 2017-02-15 22:55:10 -0500
Overwriting existing field _id in class JWTBlacklist.
Overwriting existing field _id in class User.
Processing by Api::V1::ProjectsController#update as JSON
Parameters: {"user_ids"=>"[email protected]", "id"=>"3"}
MONGODB | localhost:27017 | anthem.find | STARTED | {"find"=>"users", "filter"=>{"_id"=>"[email protected]"}}
MONGODB | localhost:27017 | anthem.find | SUCCEEDED | 0.000363703s
Overwriting existing field _id in class Project.
MONGODB | localhost:27017 | anthem.find | STARTED | {"find"=>"projects", "filter"=>{"_id"=>"3"}}
MONGODB | localhost:27017 | anthem.find | SUCCEEDED | 0.000244022s
Unpermitted parameters: user_ids, format
Overwriting existing field _id in class Release.
Completed 204 No Content in 20ms
내가 시도해 볼만한 다른 아이디어에 감사드립니다.
아! 내 문제는 난관 문제가 아니었고, 나는 우편 배달부를 어떻게 사용하는지 정말로 알지 못했다. 답변 해 주셔서 감사합니다. :) – nilatti