All threads / Rails exceptions from reserved keywords
Ask A Question

Notifications

You’re not receiving notifications from this thread.

Rails exceptions from reserved keywords

Simon Fisher asked in Rails

I keep bumping into exception errors that I believe are due to conflicts from reserved keywords.

For example, I have a permit model with the attribute "gross_value." When my view tries to retrieve @permit.gross_value I get the following exception error. However, when I rename the attribute to @permit.value_gross (without changing anything else) the view works fine. I've had similar issues with other attribute names.

Is my diagnosis of the reason for the exception correct? How do I know what keywords to avoid this issue?

fatal (exception reentered):

actionpack (5.0.1) lib/action_controller/metal/rescue.rb:23:in rescue in process_action'
actionpack (5.0.1) lib/action_controller/metal/rescue.rb:20:in
process_action'
actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:32:in block in process_action'
activesupport (5.0.1) lib/active_support/notifications.rb:164:in
block in instrument'
activesupport (5.0.1) lib/active_support/notifications/instrumenter.rb:21:in instrument'
activesupport (5.0.1) lib/active_support/notifications.rb:164:in
instrument'
actionpack (5.0.1) lib/action_controller/metal/instrumentation.rb:30:in process_action'
actionpack (5.0.1) lib/action_controller/metal/params_wrapper.rb:248:in
process_action'
activerecord (5.0.1) lib/active_record/railties/controller_runtime.rb:18:in process_action'
actionpack (5.0.1) lib/abstract_controller/base.rb:126:in
process'
actionview (5.0.1) lib/action_view/rendering.rb:30:in process'
actionpack (5.0.1) lib/action_controller/metal.rb:190:in
dispatch'
actionpack (5.0.1) lib/action_controller/metal.rb:262:in dispatch'
actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:50:in
dispatch'
actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:32:in serve'
actionpack (5.0.1) lib/action_dispatch/journey/router.rb:39:in
block in serve'
actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in each'
actionpack (5.0.1) lib/action_dispatch/journey/router.rb:26:in
serve'
actionpack (5.0.1) lib/action_dispatch/routing/route_set.rb:725:in call'
rack (2.0.1) lib/rack/etag.rb:25:in
call'
rack (2.0.1) lib/rack/conditional_get.rb:25:in call'
rack (2.0.1) lib/rack/head.rb:12:in
call'
rack (2.0.1) lib/rack/session/abstract/id.rb:222:in context'
rack (2.0.1) lib/rack/session/abstract/id.rb:216:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/cookies.rb:613:in call'
activerecord (5.0.1) lib/active_record/migration.rb:553:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in block in call'
activesupport (5.0.1) lib/active_support/callbacks.rb:97:in
run_callbacks'
activesupport (5.0.1) lib/active_support/callbacks.rb:750:in _run_call_callbacks'
activesupport (5.0.1) lib/active_support/callbacks.rb:90:in
run_callbacks'
actionpack (5.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in call'
actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in call'
actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in
call'
web-console (3.1.1) lib/web_console/middleware.rb:131:in call_app'
web-console (3.1.1) lib/web_console/middleware.rb:28:in
block in call'
web-console (3.1.1) lib/web_console/middleware.rb:18:in catch'
web-console (3.1.1) lib/web_console/middleware.rb:18:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in call'
railties (5.0.1) lib/rails/rack/logger.rb:36:in
call_app'
railties (5.0.1) lib/rails/rack/logger.rb:24:in block in call'
activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in
block in tagged'
activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in tagged'
activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in
tagged'
railties (5.0.1) lib/rails/rack/logger.rb:24:in call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in call'
rack (2.0.1) lib/rack/method_override.rb:22:in
call'
rack (2.0.1) lib/rack/runtime.rb:22:in call'
activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in
call'
actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in call'
actionpack (5.0.1) lib/action_dispatch/middleware/static.rb:136:in
call'
rack (2.0.1) lib/rack/sendfile.rb:111:in call'
railties (5.0.1) lib/rails/engine.rb:522:in
call'
puma (3.4.0) lib/puma/configuration.rb:224:in call'
puma (3.4.0) lib/puma/server.rb:569:in
handle_request'
puma (3.4.0) lib/puma/server.rb:406:in process_client'
puma (3.4.0) lib/puma/server.rb:271:in
block in run'
puma (3.4.0) lib/puma/thread_pool.rb:114:in `block in spawn_thread'

Thanks for your help!

Simon

Join the discussion

Want to stay up-to-date with Ruby on Rails?

Join 60,968+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    logo Created with Sketch.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more. Icons by Icons8

    © 2022 GoRails, LLC. All rights reserved.