From ef7eeb8ed18092bde97ebc30d249d32e56d5645f Mon Sep 17 00:00:00 2001 From: mo khan Date: Sat, 22 Feb 2014 11:12:06 -0700 Subject: found a weird bug with jbuilder and trying to render the location json node. --- app/controllers/application_controller.rb | 1 - app/controllers/v1/licenses_controller.rb | 2 -- app/models/location.rb | 2 +- app/views/v1/company_licenses/index.jbuilder | 7 ------- app/views/v1/company_licenses/index.json.jbuilder | 7 +++++++ app/views/v1/licenses/_license.json.jbuilder | 2 +- 6 files changed, 9 insertions(+), 12 deletions(-) delete mode 100644 app/views/v1/company_licenses/index.jbuilder create mode 100644 app/views/v1/company_licenses/index.json.jbuilder (limited to 'app') diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 1b2f9f7..424262c 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,7 +5,6 @@ class ApplicationController < ActionController::Base before_filter :load_additional_payload_data rescue_from StandardError, with: :return_server_error - def load_additional_payload_data @license_statuses = LicenseStatus::ALL @well_types = WellType::ALL diff --git a/app/controllers/v1/licenses_controller.rb b/app/controllers/v1/licenses_controller.rb index c62c78b..8966100 100644 --- a/app/controllers/v1/licenses_controller.rb +++ b/app/controllers/v1/licenses_controller.rb @@ -5,12 +5,10 @@ class V1::LicensesController < ApplicationController def index @licenses = License.most_recent(page: @page, per_page: @per_page) - render json: @licenses end def show @license = License.find(params[:id]) - render json: @license end private diff --git a/app/models/location.rb b/app/models/location.rb index bf7b7ef..b74eabc 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,3 +1,3 @@ class Location < ActiveRecord::Base - belongs_to :license + belongs_to :license, autosave: true end diff --git a/app/views/v1/company_licenses/index.jbuilder b/app/views/v1/company_licenses/index.jbuilder deleted file mode 100644 index 8228f3e..0000000 --- a/app/views/v1/company_licenses/index.jbuilder +++ /dev/null @@ -1,7 +0,0 @@ -json.licenses do - json.array! @licenses do |license| - json.partial! 'v1/licenses/license', license: license - end -end -json.partial! 'v1/shared/well_types', well_types: @well_types -json.partial! 'v1/shared/license_statuses', license_statuses: @license_statuses diff --git a/app/views/v1/company_licenses/index.json.jbuilder b/app/views/v1/company_licenses/index.json.jbuilder new file mode 100644 index 0000000..8228f3e --- /dev/null +++ b/app/views/v1/company_licenses/index.json.jbuilder @@ -0,0 +1,7 @@ +json.licenses do + json.array! @licenses do |license| + json.partial! 'v1/licenses/license', license: license + end +end +json.partial! 'v1/shared/well_types', well_types: @well_types +json.partial! 'v1/shared/license_statuses', license_statuses: @license_statuses diff --git a/app/views/v1/licenses/_license.json.jbuilder b/app/views/v1/licenses/_license.json.jbuilder index c66fb3f..b62f91b 100644 --- a/app/views/v1/licenses/_license.json.jbuilder +++ b/app/views/v1/licenses/_license.json.jbuilder @@ -1,6 +1,6 @@ json.id license.id json.status license.status.to_s -json.partial! 'v1/licenses/location', location: license.location +#json.partial! 'v1/licenses/location', location: license.location if license.confidential? json.partial! 'v1/licenses/confidential_well_type', well_type: license.well_type json.partial! 'v1/licenses/confidential_company' -- cgit v1.2.3