create models from within thor tasks

46 views
Skip to first unread message

kristiannissen

unread,
Dec 30, 2009, 5:02:35 PM12/30/09
to merb
how do you include merb in thor tasks? In rails rake tasks we use
something like

task :import_assets => :environment do

which makes it possible to load models inside tasks, but how is this
done using thor and merb?

desc 'booh', 'test datamapper'
def booh
Location.new
end

the line above gives me something like:

wikipedia.thor:8:in `booh': uninitialized constant
Thor::Sandbox::Wikipedia::Location (NameError)

Ian Eyberg

unread,
Dec 31, 2009, 10:57:59 AM12/31/09
to me...@googlegroups.com
Hi,
I don't use thor but I store tasks in lib/tasks/custom.rake
for instance and they are just normal rake tasks

example:

task :add_topic_shit => :merb_env do

Topic.all.each do |topic|
tagz = topic.tags.collect do |tag| tag.title end
topic.keywords = tagz.join(", ")
topic.save
end

end

> --
>
> You received this message because you are subscribed to the Google Groups "merb" group.
> To post to this group, send email to me...@googlegroups.com.
> To unsubscribe from this group, send email to merb+uns...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/merb?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages