I have a method where I would like output to occur via “puts” only if
its currently in the middle of a rake task or if its in the middle of a
migration.
How can I detect if the program execution is in the context of a
migration or a rake task?
I have a method where I would like output to occur via “puts” only if
its currently in the middle of a rake task or if its in the middle of a
migration.
How can I detect if the program execution is in the context of a
migration or a rake task?
Anybody?
On Aug 14, 3:02 am, Aryk G. [email protected]
wrote:
I have a method where I would like output to occur via “puts” only if
its currently in the middle of a rake task or if its in the middle of a
migration.How can I detect if the program execution is in the context of a
migration or a rake task?Posted viahttp://www.ruby-forum.com/.
Not sure about this, but I think calling self.class or self.parent
inside a migration task (self.up and self.down) should return
ActiveRecord::Migration.
I im interested in this question, has somebody the answer?
right, but Im talking about deep in the code, like in an ActiveRecord
model lets say.
Hey guys, i’ve not tested it, but:
you are able to set environment variable when runing rake from
commandline
you are able to test against ENV[:variable] in your code.
problem solved?
here is the inspiration:
http://ryandaigle.com/articles/2007/6/22/using-command-line-parameters-w-rake-and-capistrano
i once had a similar problem. in my case i wanted to skip some code
whenever it is called from a rake task. back then i solved it the way
Frantisek P. proposed. still working, no problems. just set your
ENV-variable at the beginning of your rake task.
Create your own class that inherits ActiveRecord::Migration and use
it, defining the behavior you would like to have.
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
On Mon, Feb 9, 2009 at 5:11 PM, Frantisek P.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs