質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

Q&A

0回答

1085閲覧

【Rails】【nginx】検証サーバー上で、API(patch)を叩くと400エラーが返ってくる

13marble

総合スコア10

nginx

nginixは軽量で高性能なwebサーバーの1つです。BSD-likeライセンスのもとリリースされており、あわせてHTTPサーバ、リバースプロキシ、メールプロキシの機能も備えています。MacOSX、Windows、Linux、上で動作します。

Ruby on Rails 4

Ruby on Rails4はRubyによって書かれたオープンソースのウェブフレームワークです。 Ruby on Railsは「設定より規約」の原則に従っており、効率的に作業を行うために再開発を行う必要をなくしてくれます。

0グッド

1クリップ

投稿2016/09/13 05:01

お世話になります。
どうしても自力で解決できそうになかったので、
ご相談させてください。

###前提・実現したいこと
データ更新用のAPIを作成しております。
前提として、
Ruy on rails4
アプリケーションサーバーはnginxを使用しております。
cookpad製のgarageといったライブラリも使用しております。

###発生している事象

ローカルではうまくデータが更新されるのですが、
検証サーバーではpatchだと400エラー、putだと404が返ってきてしまいます。
サーバー上のソースを確認する限りでは、
ソースは最新版がセットされており、デプロイに失敗している傾向はございません。

###該当のソースコード

下記、該当のcontrollerです。

ruby

1module Api 2 module V2 3 class LogSamplesController < BaseController 4 validates :update do 5 string :keyword, description: 'You can specify a keyword.' 6 integer :prefecture_id, description: 'You can specify a prefecture.' 7 integer :city_id, description: 'You can specify a city.' 8 integer :area_from, description: 'You can specify the from of the range of the area.' 9 integer :area_to, description: 'You can specify the to of the range of the area.' 10 float :latitude_from, description: 'You can specify the from of the range of the latitude.' 11 float :latitude_to, description: 'You can specify the to of the range of the latitude.' 12 float :longitude_from, description: 'You can specify the from of the range of the longitude.' 13 float :longitude_to, description: 'You can specify the to of the range of the longitude.' 14 end 15 16 include NoAuthentication 17 include Pageable 18 19 private 20 def require_resources 21 @resources = LogSample.all 22 end 23 24 def require_resource 25 @resource = LogSample.find(params[:id]) 26 end 27 28 def create_resource 29 @resource = @resources.create(work_params) 30 end 31 32 def update_resource 33 @resource.update_attributes!(work_params) 34 @resource 35 end 36 37 def work_params 38 params.permit(:id ,:remarks,:visible,:user_report_id) 39 end 40 end 41 end 42 end 43 44

下記、該当のmodelです。

ruby

1 2Parkful.require_model 'log_park' 3 4class LogPark 5 include Garage::Representer 6 include Garage::Authorizable 7 8 # before_create :upper_limit_validate 9 10 property :id 11 property :remarks 12 property :visible, selectable: true 13 property :user_report_id 14 15 def self.build_permissions(perms, other, target) 16 perms.permits! :read 17 perms.permits! :write 18 end 19 20 def build_permissions(perms, other) 21 perms.permits! :read 22 perms.permits! :write 23 end 24 25end 26

rake routesで見る限りでは特に問題はなく、
ローカルでは更新ができているので、
nginxなどサーバーの設定側の問題なのかなと思い調べているのですが、
どうにもそれらしい情報がなく、困っております。

どなたかお詳しい方いらっしゃいましたら、
ご教示していただけますと幸いです。
どうぞよろしくお願いいたします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問