Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • C chouette-core
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 36
    • Merge requests 36
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Infrastructure Registry
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Administrator
  • chouette-core
  • Merge requests
  • !37

Merged
Created Jul 19, 2017 by Administrator@rootMaintainer

Fix errors from JS-formatted templates using the table_builder

  • Overview 0
  • Commits 1
  • Changes 5

Created by: teddywing

We were getting errors like these:

Started GET "/referentials/4/networks?_=1500482065840" for 127.0.0.1 at 2017-07-19 18:34:27 +0200
Processing by ReferentialNetworksController#index as JS
  Parameters: {"_"=>"1500482065840", "referential_id"=>"4"}
  User Load (3.6ms)  SELECT  "public"."users".* FROM "public"."users" WHERE "public"."users"."id" = $1  ORDER BY "public"."users"."id" ASC LIMIT 1  [["id", 1]]
locale set to :fr
  Organisation Load (5.6ms)  SELECT  "public"."organisations".* FROM "public"."organisations" WHERE "public"."organisations"."id" = $1 LIMIT 1  [["id", 1]]
  Referential Load (1.0ms)  SELECT  "public"."referentials".* FROM "public"."referentials" WHERE "public"."referentials"."organisation_id" = $1 AND "public"."referentials"."id" = $2 LIMIT 1  [["organisation_id", 1], ["id", 4]]
  Workbench Load (0.7ms)  SELECT  "public"."workbenches".* FROM "public"."workbenches" WHERE "public"."workbenches"."id" = $1 LIMIT 1  [["id", 1]]
   (1.3ms)  SELECT DISTINCT COUNT(DISTINCT "public"."networks"."id") FROM "public"."networks" INNER JOIN "public"."line_referentials" ON "public"."networks"."line_referential_id" = "public"."line_referentials"."id" WHERE "public"."line_referentials"."id" = $1  [["id", 1]]
  CACHE (0.0ms)  SELECT DISTINCT COUNT(DISTINCT "public"."networks"."id") FROM "public"."networks" INNER JOIN "public"."line_referentials" ON "public"."networks"."line_referential_id" = "public"."line_referentials"."id" WHERE "public"."line_referentials"."id" = $1  [["id", 1]]
  Chouette::Network Load (2.3ms)  SELECT  DISTINCT "public"."networks".* FROM "public"."networks" INNER JOIN "public"."line_referentials" ON "public"."networks"."line_referential_id" = "public"."line_referentials"."id" WHERE "public"."line_referentials"."id" = $1  ORDER BY name asc LIMIT 12 OFFSET 0  [["id", 1]]
  CACHE (0.0ms)  SELECT DISTINCT COUNT(DISTINCT "public"."networks"."id") FROM "public"."networks" INNER JOIN "public"."line_referentials" ON "public"."networks"."line_referential_id" = "public"."line_referentials"."id" WHERE "public"."line_referentials"."id" = $1  [["id", 1]]
  Chouette::Network Exists (1.2ms)  SELECT  1 AS one FROM "public"."networks" WHERE "public"."networks"."id" = $1 LIMIT 1  [["id", 118]]
  Rendered referential_networks/index.html.slim (48.9ms)
Completed 500 Internal Server Error in 184ms (ActiveRecord: 17.4ms)

ActionView::Template::Error (undefined method `action_links' for #<Chouette::Network:0x007ffea2148b08>):
    22:     - if @networks.any?
    23:       .row
    24:         .col-lg-12
    25:           = table_builder_2 @networks,
    26:             [ \
    27:               TableBuilderHelper::Column.new( \
    28:                 name: 'ID Codifligne', \
  app/helpers/table_builder_helper.rb:161:in `block in build_links'
  app/helpers/table_builder_helper.rb:158:in `build_links'
  app/helpers/table_builder_helper.rb:138:in `block (3 levels) in tbody'
  app/helpers/table_builder_helper.rb:110:in `block (2 levels) in tbody'
  app/helpers/table_builder_helper.rb:108:in `block in tbody'
  app/helpers/table_builder_helper.rb:107:in `tbody'
  app/helpers/table_builder_helper.rb:72:in `table_builder_2'
  app/views/referential_networks/index.html.slim:25:in `_app_views_referential_networks_index_html_slim___1557411244315414919_70366016986820'
  app/controllers/referential_networks_controller.rb:27:in `index'

  Rendered .../lib/ruby/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (1.8ms)
  Rendered .../lib/ruby/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb (2.5ms)
  Rendered .../lib/ruby/gems/2.3.0/gems/actionpack-4.2.8/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb (76.0ms)

on the following pages:

  • http://stif-boiv.dev:3000/referentials/4/time_tables
  • http://stif-boiv.dev:3000/line_referentials/1/companies
  • http://stif-boiv.dev:3000/line_referentials/1/networks
  • http://stif-boiv.dev:3000/referentials/4/companies
  • http://stif-boiv.dev:3000/referentials/4/networks

This was caused by the request of a JS-formatted view that rendered the HTML template, since the collection decoration only happened in the HTML format section.

Do the decoration in both the HTML format and JS format for the relevant controllers in order to eliminate this error.

Maybe there's a cleaner way to do this than just duplicating the decoration in both format.X blocks, but I don't know of it. Wanted to make sure not to decorate when it wasn't necessary, like when rendering other formats (XML, etc.).

Refs #4105

Assignee
Assign to
Reviewer
Request review from
None
Milestone
None
Assign milestone
Time tracking
Source branch: 4105-fix-server-error-resulting-from-table-builder-on-JS-formatted-routes