##概要
RailsAPIでクライアントサイドから届いたJSONをハッシュにデコードしてユーザーを作成したいと考えているのですが、受け取ったリクエストを処理できないエラーに悩ませれています。対処法をご教示いただければ幸いです。
何卒宜しくお願い致します。
##エラー内容
Started
1Processing by Users::RegistrationsController#create as JSON 2 Parameters: {"user"=>"{\"name\":\"Wario\",\"grade\":\"1年\",\"birthday\":12345,\"instrument\":\"piano\",\"password\":\"sgirlic\"}", "Content-Type"=>"application/json; charset=UTF-8"} 3 User Load (64.1ms) SELECT `users`.* FROM `users` WHERE `users`.`name` IS NULL LIMIT 1 4Completed 500 Internal Server Error in 177ms (ActiveRecord: 103.4ms) 5 6 7 8NoMethodError (undefined method `permit' for #<String:0x007fd7d001a9f0> 9Did you mean? print):
##コード
def create json_request = JSON.parse(request.body.read) @users = User.new user_params respond_to do |format| format.json { render json: @users, status: :creates, location: @users } else format.json {render json: @users.errors, status: :unprocessable_entity } end end end
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。