gregbell/active_admin — Issue #863: rake db:schema:load and dynamic scopes
Author: fabienengels
Created: 2011-12-20 15:39:42+00:00
State: open

I'm using a dynamic scope added after the database creation.

Now I'm trying to create the database from scratch, rake db:schema:load failed saying is unable to find a table. Here the code :

```ruby

ActiveAdmin.register Photo do
config.clear_sidebar_sections!

scope :all, :default => true

scope :not_assigned do |photos|
photos.where('gallery_id is null')
end

Gallery.all.each do |gallery|
self.send(:scope, gallery.slug.to_sym) do |photos|
photos.where(:gallery_id => gallery)
end
end

form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs do
f.input :gallery
f.input :file, :as => :file
end
f.buttons
end

index :as => :grid, :columns => 6 do |photo|
link_to(image_tag(photo.file.url(:thumb)), admin_photo_path(photo))
end

show do
render "show"
end
end
```

The error message I get :

```bash
fabien@mrtea:~/Dropbox/portfolio$ rake db:schema:load
rake aborted!
Could not find table 'galleries'
```

More details about this issue here : http://stackoverflow.com/questions/8353744/rake-dbschemaload-could-not-find-a-table

I'm not sure it's a bug or me who miss something ...