Merb#merge_env; Personalized, mergeable Environments[Feature][Patch]
Reported by coryodaniel(midget_nuts|codaniel) | March 26th, 2008 @ 09:23 PM | in 0.9.4
Since merbs environments are pretty abstract (i.e: Merb doesn't explode if you use an environment thats not "test", "production", "development) I have been taking the opportunity to use personalized environments. I can create a "stage" environment or a "localdev" environment that are configured differently that the standard three environments.
What this patch lets you do is call Merb.runs_like "this_environment" in one of your environment.rb files. It will apply that environment config before/after (depending on placement) the settings in the current environment *.rb file.
This allows cool things like having a personal environment locally that maybe specifies a port that you always want to run on, but besides that you always want to use the settings from "Development.rb"
You can do (my_env.rb):
Merb.runs_like "development"
Merb::Config.use {|x| x[:port] = 3004}
Comments and changes to this ticket
-
coryodaniel(midget_nuts|codaniel) March 26th, 2008 @ 09:48 PM
Just wanted to add an indepth example of how to use this...
-
Michael D. Ivey (ivey) April 23rd, 2008 @ 08:16 AM
- → Assigned user changed from to Michael D. Ivey (ivey)
I like this, but I want to play with it a little before applying.
-
coryodaniel(midget_nuts|codaniel) April 25th, 2008 @ 06:39 AM
I'm not very familiar with how Merb interacts with various ORMs. I would like to see this feature (if implemented) also use the same database connection that merb is "running like"
-
Michael Klishin (antares) May 11th, 2008 @ 03:04 PM
- → Milestone changed from to 0.9.4
-
coryodaniel(midget_nuts|codaniel) May 16th, 2008 @ 05:12 AM
I got this working where you can load the other envs database
In my personal env:
Merb.runs_like "development", true
#This will load the development environment, override it with my env's settings, but use the dev database, so you dont have to create a crap load of environments in the database.yml file
Will upload patch tomorrow, I need food right now :)
BTW, you can 'merge' as many environment files as you want, they get merged in as the #runs_like method is called during your env.rb file . . . only one can have the "true" flag set to use the database though (obviously)
-
Michael Klishin (antares) May 16th, 2008 @ 03:10 PM
please do not use port in environment examples! #229 tells why, try to use something like memcache / memory for session store in different environments. This is in case you are going to add example above to docs.
-
coryodaniel(midget_nuts|codaniel) May 16th, 2008 @ 09:39 PM
Updating this ticket with new examples, and the patches for #runs_like to optionally connect to merged environments database...
-
coryodaniel(midget_nuts|codaniel) May 16th, 2008 @ 09:40 PM
Patch to merb-core.rb (this will require a patch in activerecord and datamapper plugins to optionally load the merged db, will submit in a bit)
-
coryodaniel(midget_nuts|codaniel) May 16th, 2008 @ 09:40 PM
This is a patch for the documentation because Im an idiot.
-
coryodaniel(midget_nuts|codaniel) May 16th, 2008 @ 09:52 PM
Here is the Merb::Plugins ActiveRecord patch that is needed for the database loading....
-
-
Ezra Zygmuntowicz May 18th, 2008 @ 02:05 AM
I like this as well. My only issue is I don't like the name ;) Can we come up with a better name for this?
suggestions:
Merb.run_as 'staging'
Merb.use_env 'staging
??
-
Ezra Zygmuntowicz May 18th, 2008 @ 02:05 AM
- → Assigned user changed from Michael D. Ivey (ivey) to Ezra Zygmuntowicz
-
-
coryodaniel(midget_nuts|codaniel) May 21st, 2008 @ 08:10 PM
- → Title changed from Merb#runs_like; Personalized, Overlapping Environments[Feature][Patch] to Merb#merge_env; Personalized, mergeable Environments[Feature][Patch]
Here are teh files ... I tried deleting the old ones, but apparently I dont have access(?)...
Anywho, I went with Merb.merge_env
-
coryodaniel(midget_nuts|codaniel) May 21st, 2008 @ 08:11 PM
- no changes were found...
-
coryodaniel(midget_nuts|codaniel) May 21st, 2008 @ 08:12 PM
- no changes were found...
-
Ezra Zygmuntowicz May 22nd, 2008 @ 02:02 AM
- → State changed from new to resolved
OK I've applied these changes. Thanks corey
-
coryodaniel(midget_nuts|codaniel) May 22nd, 2008 @ 10:02 PM
Just a reminder there is the other half of the patch to make the DB portion work...
This doesn't access the data by the public method, (merge_env) so no updates need to be done to its patch
Please Login or create a free account to add a new comment.
You can update this ticket by sending an email to from your email client. (help)
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
