2

I'm following this tutorial: http://friendlyorm.com/

I'm using InstantRails to run MySQL locally. To run Ruby and Rails, I'm using normal Windows installations.

When I run Friendly.create_tables! I only get an empty Array returned: => [] and no tables are created in my 'friendly_development' database.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user94154
  • 16,176
  • 20
  • 77
  • 116

3 Answers3

1

Author of Friendly here.

You'll have to require all of your models before calling Friendly.create_tables! Otherwise, there's no way for Friendly to know which models exist. In a future revision, I'll automatically preload all your models.

1

I have a rake task, with help from a guy called Sutto, that will load in all your models and then call Friendly.create_tables! and print out all the tables involved.

namespace :friends do
  desc "load in all the models and create the tables"
  task :create => :environment do
    puts "-----------------------------------------------"
    Dir[Rails.root.join("app", "models", "*.rb")].each { |f|File.basename(f, ".rb").classify.constantize }
    tables = Friendly.create_tables!
    tables.each do |table|
      puts "Table '#{table}'"
    end
    puts "-----------------------------------------------"
  end
end

rake friends:create
Joc
  • 1,059
  • 8
  • 8
0

not much to go on here. My guess is that it can't find your model file that you are creating in the path?

Arthur Thomas
  • 5,088
  • 1
  • 25
  • 31