お世話になります。
どうしても自力で解決できそうになかったので、
ご相談させてください。
###前提・実現したいこと
データ更新用の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などサーバーの設定側の問題なのかなと思い調べているのですが、
どうにもそれらしい情報がなく、困っております。
どなたかお詳しい方いらっしゃいましたら、
ご教示していただけますと幸いです。
どうぞよろしくお願いいたします。
あなたの回答
tips
プレビュー