<p>I'm using Ruby on Rails for an internal site. Different users of the site have access to a wide variety of data and highly disparate perspectives of the data. Within those different classes of users, there needs to be levels of access. Within the levels of access I need to be able to add features from other classes of users.</p>

<p>In the released "Version 1.0" of the intranet site I have implemented the general classes of users. I am now needed to implement much finer-grained control of a users access.</p>

<p>The question is how?</p>

<p>What is the generally accepted practice for coding up user preferences (display the map (or not); access to this feature, but not this feature) without exploding the database schema and populating the view code with &lt;% if feature_allowed %> tags everywhere.</p>

[{'answer_id': 33381, 'author': 'Christian Lescuyer', 'author_id': 341, 'author_profile': 'https://Stackoverflow.com/users/341', 'pm_score': 2, 'selected': False, 'text': '<p>Another totally different approach would be to use acts_as_authenticated and authorization plugins. The tables will be built by the plugins (ie <strong>users</strong>, <strong>roles</strong> and <strong>roles</strong>_users). From the doc:</p>\n\n<blockquote>\n  <p>The authorization plugin provides the following:</p>\n</blockquote>\n\n<ul>\n<li><p>A simple way of checking authorization at either the class or instance method\nlevel using #permit and #permit?</p></li>\n<li><p>Authorization using roles for the entire application, a model class, or an\ninstance of a model (i.e., a particular object).</p></li>\n<li><p>Some english-like dynamic methods that draw on the defined roles. You will be\nable to use methods like "user.is_fan_of angelina" or "angelina.has_fans?",\nwhere a \'fan\' is only defined in the roles table.</p></li>\n<li><p>Pick-and-choose a mixin for your desired level of database complexity. For\nall the features, you will want to use "object roles table" (see below)</p></li>\n</ul>\n'}, {'answer_id': 34268, 'author': 'Mike Woodhouse', 'author_id': 1060, 'author_profile': 'https://Stackoverflow.com/users/1060', 'pm_score': 2, 'selected': False, 'text': '<blockquote>\n  <p>populating the view code with &lt;% if\n  feature_allowed %> tags everywhere.</p>\n</blockquote>\n\n<p>I don\'t think you want to do that. Assuming none of the alternatives suggested are practicable, at the very least you should consider shifting those checks into your controllers, where you can refactor them into a before_filter. </p>\n\n<p>See section 11.3 in "Agile Web Development With Rails" (page 158 in my copy of the 2nd edition) where they do exactly that.</p>\n'}]
['https://Stackoverflow.com/questions/32966', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/757/']