class TablesController
Public Instance Methods
create()
click to toggle source
POST /tables
# File natural-backend/app/controllers/tables_controller.rb, line 16 def create @table = current_user.tables.build(table_params) if @table.save render json: @table, status: :created, location: @table else render json: @table.errors, status: :unprocessable_entity end end
destroy()
click to toggle source
DELETE /tables/1
# File natural-backend/app/controllers/tables_controller.rb, line 36 def destroy @table.destroy end
index()
click to toggle source
GET /tables
# File natural-backend/app/controllers/tables_controller.rb, line 6 def index render json: @tables end
show()
click to toggle source
GET /tables/1
# File natural-backend/app/controllers/tables_controller.rb, line 11 def show render json: @table end
update()
click to toggle source
PATCH/PUT /tables/1
# File natural-backend/app/controllers/tables_controller.rb, line 27 def update if @table.update(table_params) render json: @table else render json: @table.errors, status: :unprocessable_entity end end
Private Instance Methods
get_tables()
click to toggle source
Get tables associated with a particular db
# File natural-backend/app/controllers/tables_controller.rb, line 43 def get_tables @tables = Table.for_database_id(params[:db_id]) end
set_table()
click to toggle source
Use callbacks to share common setup or constraints between actions.
# File natural-backend/app/controllers/tables_controller.rb, line 47 def set_table @table = current_user.tables.find(params[:id]) end
table_params()
click to toggle source
Only allow a trusted parameter “white list” through.
# File natural-backend/app/controllers/tables_controller.rb, line 52 def table_params ActiveModelSerializers::Deserialization.jsonapi_parse(params, only: [:name, :database]) end