Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Rake Task: passing params and return values
Harp Oon
3/16/2008 5:21:00 AM
1. Is there a way to pass params to a rake task and have it return
values?
2. I have seen the ENV var being used to pass in the args to rake. Is it
thread safe? Are there any unintended consequences if two controllers
execute a new task?
3. Is it advisable to invoke a rake task (from a controller) to update
the DB?
--
Posted via
http://www.ruby-...
.
2 Answers
Harp Oon
3/16/2008 7:56:00 AM
0
Harp Oon wrote:
> 1. Is there a way to pass params to a rake task and have it return
> values?
>
> 2. I have seen the ENV var being used to pass in the args to rake. Is it
> thread safe? Are there any unintended consequences if two controllers
> execute a new task?
>
> 3. Is it advisable to invoke a rake task (from a controller) to update
> the DB?
My tasks.rake file has:
task :my_script => :environment do
puts "ID: = #{args.user_id}"
end
and I invoke it using:
load "#{RAILS_ROOT}/Rakefile"
def update_user
Rake::Task["my_script"].invoke
end
Using the code above, how would I pass in arguments to the script?
--
Posted via
http://www.ruby-...
.
Julian Leviston
3/31/2008 12:36:00 AM
0
Hi,
Why use rake to update the database? You're better off using the
controller to update the database, with a model or two - that is,
after all, what the model was designed for.
Julian.
On 16/03/2008, at 4:20 PM, Harp Oon wrote:
> 1. Is there a way to pass params to a rake task and have it return
> values?
>
> 2. I have seen the ENV var being used to pass in the args to rake.
> Is it
> thread safe? Are there any unintended consequences if two controllers
> execute a new task?
>
> 3. Is it advisable to invoke a rake task (from a controller) to update
> the DB?
> --
> Posted via
http://www.ruby-...
.
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Rake Task: passing params and return values
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password