Rails Rake Task - Access to model class - Stack Overflow

Ask questions Research chat →

https://stackoverflow.com/questions/5265021/rails-rake-task-access-to-model-class · scraped

rails ruby

Attachments

Scraped Content

— 46 words · 2026-02-14 17:42:09 UTC ·

Excerpt

You're close :) ```plain text #lib/tasks/defaultuser.rake require 'rake' namespace :defaultuser do task :adduser => :environment do ... end ``` Note the use of :environment, which sets up the necessary Rails environment prior to calling the rake task. After that, your User object will be in scope.
You're close :) ```plain text #lib/tasks/defaultuser.rake require 'rake' namespace :defaultuser do task :adduser => :environment do ... end ``` Note the use of :environment, which sets up the necessary Rails environment prior to calling the rake task. After that, your User object will be in scope.

Visibility

Visible to everyone

Reading Status

Related Bookmarks

My Note


Saved!

Annotations

Export as Markdown
+ Annotate selection

Add Annotation