Add /pixiv_ugoira_frame_data.json endpoint.
This commit is contained in:
8
app/controllers/pixiv_ugoira_frame_data_controller.rb
Normal file
8
app/controllers/pixiv_ugoira_frame_data_controller.rb
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
class PixivUgoiraFrameDataController < ApplicationController
|
||||||
|
respond_to :json, :xml
|
||||||
|
|
||||||
|
def index
|
||||||
|
@pixiv_ugoira_frame_data = PixivUgoiraFrameData.paginated_search(params)
|
||||||
|
respond_with(@pixiv_ugoira_frame_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,7 +1,19 @@
|
|||||||
class PixivUgoiraFrameData < ApplicationRecord
|
class PixivUgoiraFrameData < ApplicationRecord
|
||||||
|
belongs_to :post
|
||||||
|
|
||||||
serialize :data
|
serialize :data
|
||||||
before_validation :normalize_data, on: :create
|
before_validation :normalize_data, on: :create
|
||||||
|
|
||||||
|
def self.available_includes
|
||||||
|
[:post]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.search(params)
|
||||||
|
q = super
|
||||||
|
q = q.search_attributes(params, :post, :data, :content_type)
|
||||||
|
q.apply_default_order(params)
|
||||||
|
end
|
||||||
|
|
||||||
def normalize_data
|
def normalize_data
|
||||||
return if data.nil?
|
return if data.nil?
|
||||||
|
|
||||||
|
|||||||
@@ -161,6 +161,7 @@ Rails.application.routes.draw do
|
|||||||
end
|
end
|
||||||
resources :note_versions, :only => [:index, :show]
|
resources :note_versions, :only => [:index, :show]
|
||||||
resource :note_previews, :only => [:show]
|
resource :note_previews, :only => [:show]
|
||||||
|
resources :pixiv_ugoira_frame_data, only: [:index]
|
||||||
resources :pools do
|
resources :pools do
|
||||||
member do
|
member do
|
||||||
put :revert
|
put :revert
|
||||||
|
|||||||
Reference in New Issue
Block a user