# Best approach to providing app congurations?

**URL:** <https://www.ruby-forum.com/t/best-approach-to-providing-app-congurations/174471>\
**Category:** Rails\
**Created:** [August 27, 2009, 6:33am UTC](https://www.ruby-forum.com/t/best-approach-to-providing-app-congurations/174471 "2009-08-27T06:33:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [August 27, 2009, 6:33am UTC](https://www.ruby-forum.com/t/best-approach-to-providing-app-congurations/174471/1 "2009-08-27T06:33:48Z")

</div>

This is more about theory than coding so I hope I have the right place.  
I would very much appreciate some input as to the best approach on how  
to offer different options in my app depending on configuration criteria  
and current user.

Some examples of what I want to do I guess would be a help.

Firstly I have an administration control panel that administrators can  
log into and do the usual stuff that admins do 🙂  
The site may have different configration switches that determine what  
options are available in the administration panel.  
For example the site may be configured to have blogs enabled.  
Obviously if blogs are not enabled then there should be no  
administration options to maintain blogs other than to enable them.  
I though I might use a site\_configuration table to determine what site  
“add on’s” are available and what are enabled.

A user can have different levels of access.  
Some user roles will not have access to the administration panel at all.  
For example users that are logged in as members i.e. users with a role  
of member will not be able to log in as administrators but will be able  
to view their own profile and will be able to access areas of the site  
that non logged in users can’t see.

I’m using a user\_roles table to record a users role where a user can  
have many roles therefore allowing for a user to be both an  
administrator and a member.

That just about covers the requirement although there are more roles and  
more functionality than mentioned.

So the question comes down to how best to achieve site configuration  
options and also user access options.

Current thoughts are that I could provide the site configurations as  
some kind of plug in or possibly a better solution might be to have  
specific menu options that only visible according to the state of the  
current user and the site configuration settings.

One concern I have is that I don’t want to clutter up the views with too  
much conditional logic for options that may never even exist for that  
particular site.

I have implemented my own authoridsation process based around AWDWR’s  
authentication solution but I was wondering if authlogic may be asble to  
provide a better answer to the user role scenarios?

Hope that makes sense and any input as to best approach would be greatly  
appreciated.

p.s. target language is Rails 2.3.23 but will be moving on to 2.3.4  
ASAP.

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [August 27, 2009, 7:00am UTC](https://www.ruby-forum.com/t/best-approach-to-providing-app-congurations/174471/2 "2009-08-27T07:00:43Z")

</div>

James W. wrote:

> options are available in the administration panel.  
> to view their own profile and will be able to access areas of the site  
> options and also user access options.  
> I have implemented my own authoridsation process based around AWDWR’s  
> authentication solution but I was wondering if authlogic may be asble to  
> provide a better answer to the user role scenarios?
> 
> Hope that makes sense and any input as to best approach would be greatly  
> appreciated.
> 
> p.s. target language is Rails 2.3.23 but will be moving on to 2.3.4  
> ASAP.

I have no idea if this is the best method by any means, but I have used  
it before with no problems:

I created a model called AppConfig which had an id, a key and a value. I  
could set the key to the name of the configuration (such as  
“allow\_new\_signups”) and then set the value as required.

Then all I needed to do was AppConfig.find\_by\_key(“allow\_new\_signups”)  
and I have my configurations back.

As I say, there are possibly much better ways to do this, but it worked  
fine for my needs. YMMV.

Hope this helps.

Matt

---

<div class="post-metadata">

**Author:** ![aftershock](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8e7dd6/32.png) [@aftershock](https://www.ruby-forum.com/u/aftershock)\
**Post date:** [August 28, 2009, 3:51am UTC](https://www.ruby-forum.com/t/best-approach-to-providing-app-congurations/174471/3 "2009-08-28T03:51:35Z")

</div>

Matt H. wrote:

> I have no idea if this is the best method by any means, but I have used  
> it before with no problems:
> 
> I created a model called AppConfig which had an id, a key and a value. I  
> could set the key to the name of the configuration (such as  
> “allow\_new\_signups”) and then set the value as required.
> 
> Then all I needed to do was AppConfig.find\_by\_key(“allow\_new\_signups”)  
> and I have my configurations back.
> 
> As I say, there are possibly much better ways to do this, but it worked  
> fine for my needs. YMMV.
> 
> Hope this helps.
> 
> Matt

Thankyou Matt.  
I would like to explore that option further. I think it has potential  
🙂  
Very much appreciated the input

James
