No commit activity in last 3 years
No release in over 3 years
Force loading all data from the controller by raising when the database is accessed from the view. This can help create effective database queries and help avoid SQL N+1 problems.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 3.1.1
 Project Readme

rails_no_database_in_view

Prevent database access from the view.

Force loading all data from the controller by raising when the database is accessed from the view. This can help create effective database queries and help avoid SQL N+1 problems.

Installation

gem install rails_no_database_in_view

Usage

Enable in controller:

class ItemsController < ActionController::Base

  no_database_access_from_view! if Rails.env.development?

  ...

end

If the database is accessed from the view, a DatabaseAccessFromViewError will be raised.

Badness

You can't tell where in the view the exception came from. Yeah, that's pretty bad.

Disclaimer

Don't use this. It probably doesn't work. :)