-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UDF #9 - Adding resource-api dependency; Adding /user_defined_fields …
…API endpoint
- Loading branch information
1 parent
317ee05
commit dadad2b
Showing
9 changed files
with
52 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
source "https://rubygems.org" | ||
source 'https://rubygems.org' | ||
git_source(:github) { |repo| "https://github.com/#{repo}.git" } | ||
|
||
gem "sqlite3" | ||
gem 'resource_api', git: 'https://github.com/performant-software/resource-api.git', tag: 'v0.4.2' | ||
|
||
gem "sprockets-rails" | ||
gem 'sqlite3' | ||
|
||
gem 'sprockets-rails' | ||
|
||
# Specify your gem's dependencies in user_defined_fields.gemspec. | ||
gemspec | ||
|
||
# Start debugger with binding.b [https://github.com/ruby/debug] | ||
# gem "debug", ">= 1.0.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 14 additions & 1 deletion
15
app/controllers/user_defined_fields/application_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,17 @@ | ||
module UserDefinedFields | ||
class ApplicationController < ActionController::API | ||
class ApplicationController < Api::ResourceController | ||
def current_user | ||
return super if defined?(super) | ||
|
||
nil | ||
end | ||
|
||
def item_class | ||
"UserDefinedFields::#{controller_name.singularize.classify}".constantize | ||
end | ||
|
||
def serializer_class | ||
"UserDefinedFields::#{"#{controller_name}_serializer".classify}".constantize | ||
end | ||
end | ||
end |
5 changes: 5 additions & 0 deletions
5
app/controllers/user_defined_fields/user_defined_fields_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module UserDefinedFields | ||
class UserDefinedFieldsController < ApplicationController | ||
search_attributes :table_name, :column_name | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
module UserDefinedFields | ||
class ApplicationRecord < ActiveRecord::Base | ||
self.abstract_class = true | ||
|
||
# Includes | ||
include Resourceable | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
module UserDefinedFields | ||
class UserDefinedField < ApplicationRecord | ||
# Relationships | ||
belongs_to :defineable, polymorphic: true, optional: true | ||
|
||
# Resourceable parameters | ||
allow_params :table_name, :column_name, :data_type, :required, :allow_multiple, :options | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
app/serializers/user_defined_fields/user_defined_fields_serializer.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module UserDefinedFields | ||
class UserDefinedFieldsSerializer < BaseSerializer | ||
index_attributes :id, :table_name, :column_name, :required, :allow_multiple, :options | ||
show_attributes :id, :table_name, :column_name, :required, :allow_multiple, :options | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
UserDefinedFields::Engine.routes.draw do | ||
resources :user_defined_fields | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters