Running a rake task from a controller (pass/return values)


    Sponsored Links


  • 1. Statement modifiers causing confusion
    I'm working my way through the second edition of the pickaxe and have encountered an example that doesn't work as I'd expected. while line = gets puts line.downcase end That code made sense... it was then simplified to: puts line.downcase while line = gets This doesn't work the same, however. I get: 02.07.rb:1: undefined local variable or method `line' for main:Object (NameError) The odd part (to me) is that the error isn't spit out until after I've entered a line. In which order does the interpreter do it's job? Even more perplexing is: line = 'This will never be seen...' puts line.downcase while line = gets Defining line solves the issue. So, it seems to me, gets is executed but something is erroring before the assignment to line... ? Any help in understanding would be greatly appreciated!

Running a rake task from a controller (pass/return values)

Postby Harp Oon » Mon, 17 Mar 2008 11:01:40 GMT

I'm a RoR noob.
I have a controller that receives data from a view. I want to save that
data into a DB, which is fine. After saving the data, I want to run a
rake task on it to get more data to save it in the DB.

The rake task work fine, but I can't figure out a way to pass in the
recordID for the task I want the task to run on.

Within the rake task I can access all the data within a table and run
the task on all the data, but I don't want that to happen. All I want is
to pass in the recordID for the task to run on .

Also, is there a way for a rake task to return an array back to the
Posted via  http://www.**--****.com/ 

Re: Running a rake task from a controller (pass/return values)

Postby Julian Leviston » Tue, 01 Apr 2008 09:33:20 GMT


It's like a bundle of mixedupness! :-)

Can I ask why you're using a rake task?

Better to clarify what you're talking about first, then we can help out.


Similar Threads:

1.Rake Task: passing params and return values

2.rake finds & runs task, but doesn't show in --tasks list

hi, rake & ruby-talk newbie, a boy's 1st rake task, lib/tasks/load.rake:

namespace :load do
  task :hello_world do |t|
    puts 'hello, world!'

runs fine:

# rake load:hello_world
(in ... )
hello, world!

but it's a no-show in rake --tasks, which just shows the standard rails 

the task is not listed even when rake is pointed directly at the rake file:

# rake -f lib/tasks/load.rake --tasks
(in ... )

w/ or w/o explicit namespace in rake file doesn't help it show up in 

rake 0.8.3, rails 2.1.1, ruby 1.8, fedora 9

what am i doing wrong? thanks in advance. sorry if this is a FAQ.


3.passing values from partial to controller

4.rake: passing args to Task invoke

5.Rake dependencies unknown prior to running tasks

6. Running a rake test task within a specific directory

7. Running a Rake task without prereqs

8. changing rake task dependencies, runs in wrong order

Return to ruby


Who is online

Users browsing this forum: No registered users and 36 guest