0

In my Padrino App I define model classes that I want to use from a script in bin/ without actually serving something (e.g. pre-populate database with a command line tool).

How can I access the model classes and database? I digged around the padrino console and tried with

Padrino.mounted_apps.each do |app|
  puts "=> Loading Application #{app.app_class}"
  app.app_obj.setup_application!
end     

but to no avail, I keep getting

bin/gusy_fill:13:in `<main>': uninitialized constant Seminar (NameError)

errors. I start bin/gusy_fill with bundle exec bin/gusy_fill and Seminar is the name of a model, referenced like

puts Seminar.all

in bin/gusy_fill. I have a related question about how to do this from a different gem.

Community
  • 1
  • 1
Felix
  • 4,510
  • 2
  • 31
  • 46
  • @dario posted an awesome answer at http://stackoverflow.com/questions/26213806/how-to-access-a-gemified-padrino-apps-model-from-other-gem-that-requires-that-app , which includes solutions to this question too. I will merge when tested. – Felix Oct 07 '14 at 06:19
  • I rephrased the other question slightly. The answer matches. Will mark as dupe now. – Felix Oct 08 '14 at 06:30

0 Answers0