Closed jvatic closed 14 years ago
Super strange, I think this is a know dm issue. Can you try to drop and recreate the db and then run migrations?
Thanks!
I deleted the db and ran padrino rake dm:create and the migration still does the exact same thing.
sqlite or mysql?
sqlite
Ok, thanks, can you tell me wich step I need to do for reproduce the problem?
This for me work fine:
padrino-gen project foo -d datamapper -b cd foo padrino-gen admin padrino-gen rake dm:migrate padrino-gen model post title:string description:string padrino-gen rake dm:migrate padrino-gen admin_page post padrino-gen rake seed padrino start rm -rf ../foo cd ..
I can't seem to recreate this issue, I do however get a different error when executing padrino-gen admin_page post
$ padrino-gen admin_page post => Located unlocked Gemfile for development /Library/Ruby/Gems/1.8/gems/padrino-admin-0.9.9/lib/padrino-admin/generators/orm.rb:17:in `initialize': Model post was not found! (Padrino::Admin::Generators::OrmError) from /Library/Ruby/Gems/1.8/gems/padrino-admin-0.9.9/lib/padrino-admin/generators/admin_page.rb:33:in `new' from /Library/Ruby/Gems/1.8/gems/padrino-admin-0.9.9/lib/padrino-admin/generators/admin_page.rb:33:in `create_controller' from /Library/Ruby/Gems/1.8/gems/padrino-admin-0.9.9/lib/padrino-admin/generators/admin_page.rb:32:in `each' from /Library/Ruby/Gems/1.8/gems/padrino-admin-0.9.9/lib/padrino-admin/generators/admin_page.rb:32:in `create_controller' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/task.rb:33:in `send' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/task.rb:33:in `run' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:109:in `invoke' from /Library/Ruby/Gems/1.8/gems/padrino-gen-0.9.9/lib/padrino-gen.rb:53:in `map' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/core_ext/ordered_hash.rb:73:in `each' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:118:in `map' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:118:in `invoke' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/group.rb:36:in `start' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/base.rb:378:in `start' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/group.rb:29:in `start' from /Library/Ruby/Gems/1.8/gems/padrino-gen-0.9.9/lib/padrino-gen/generators/cli.rb:42:in `setup' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/task.rb:33:in `send' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/task.rb:33:in `run' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:109:in `invoke' from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `map' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/core_ext/ordered_hash.rb:75:in `each' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:118:in `map' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/invocation.rb:118:in `invoke' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/group.rb:36:in `start' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/base.rb:378:in `start' from /Library/Ruby/Gems/1.8/gems/thor-0.13.4/lib/thor/group.rb:29:in `start' from /Library/Ruby/Gems/1.8/gems/padrino-gen-0.9.9/bin/padrino-gen:14 from /usr/bin/padrino-gen:19:in `load' from /usr/bin/padrino-gen:19
Mmm, iper strange
can you puts me your gem env?
RubyGems Environment: - RUBYGEMS VERSION: 1.3.6 - RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [universal-darwin10.0] - INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8 - RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS PLATFORMS: - ruby - universal-darwin-10 - GEM PATHS: - /Library/Ruby/Gems/1.8 - /Users/jesse/.gem/ruby/1.8 - /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8 - GEM CONFIGURATION: - :update_sources => true - :verbose => true - :benchmark => false - :backtrace => false - :bulk_threshold => 1000 - :sources => ["http://gems.rubyforge.org/", "http://gemcutter.org/", "http://gemcutter.org/", "http://gems.github.com", "http://gems.github.com", "http://gemcutter.org"] - REMOTE SOURCES: - http://gems.rubyforge.org/ - http://gemcutter.org/ - http://gemcutter.org/ - http://gems.github.com - http://gems.github.com - http://gemcutter.org
I have tried these steps as well:
padrino-gen project foo -d datamapper -b
cd foo
padrino-gen admin
padrino rake dm:migrate
padrino-gen model post title:string description:string
padrino rake dm:migrate
padrino-gen admin_page post
padrino rake seed
padrino start
and it seems to execute without error. The last error you got seems to suggest the Post model isnt being loaded into the environment.
weird, I tried it again and it works. I guess the migration problem is probably caused by the padrino project being corrupt in some way and can be fixed by moving it into a new project. I have do idea how it corrupted though.
Ok if you can reproduce the problem reopen this ticket! Thanks!
I managed to reproduce the problem:
$ padrino-gen project demo -t rspec -e haml -m rr -s jquery -d datamapper -c sass create create config/apps.rb create config/boot.rb create config.ru create public/favicon.ico create .gitignore create public/images create public/javascripts create public/stylesheets create tmp create app create app/app.rb create app/controllers create app/helpers create app/views create app/views/layouts/.emptydirectory create .components create Gemfile Applying 'datamapper' (orm)... inject Gemfile inject Gemfile inject Gemfile create config/database.rb create app/models Applying 'rspec' (test)... inject Gemfile create spec/spec_helper.rb create spec/spec.rake Applying 'rr' (mock)... inject Gemfile inject spec/spec_helper.rb Applying 'jquery' (script)... create public/javascripts/jquery.js create public/javascripts/application.js Applying 'haml' (renderer)... inject Gemfile Applying 'sass' (stylesheet)... inject Gemfile create lib/sass.rb inject app/app.rb create app/stylesheets ================================================================= demo is ready for development! Next, follow these steps: ================================================================= 1) cd demo 2) bundle install ================================================================= Jesse-Stuarts-HackBook-Pro:Projects jesse$ cd demo Jesse-Stuarts-HackBook-Pro:demo jesse$ bundle install Fetching source index from http://gemcutter.org/ Using rake (0.8.7) from system gems Using activesupport (2.3.5) from system gems Using addressable (2.1.1) from system gems Using bcrypt-ruby (2.1.2) from system gems Using bundler (0.9.16) from system gems Using daemons (1.0.10) from system gems Using data_objects (0.10.1) from system gems Using extlib (0.9.14) from system gems Using dm-core (0.10.2) from system gems Using dm-aggregates (0.10.2) from system gems Using dm-constraints (0.10.2) from system gems Using dm-migrations (0.10.2) from system gems Using fastercsv (1.5.3) from bundler gems Using json_pure (1.2.3) from bundler gems Using dm-serializer (0.10.2) from system gems Using dm-timestamps (0.10.2) from system gems Using stringex (1.1.0) from system gems Using uuidtools (2.1.1) from system gems Using dm-types (0.10.2) from system gems Using dm-validations (0.10.2) from system gems Using datamapper (0.10.2) from bundler gems Using do_sqlite3 (0.10.1.1) from system gems Using eventmachine (0.12.10) from system gems Using fuzzyhash (0.0.11) from system gems Using haml (2.2.22) from bundler gems Using i18n (0.3.6) from system gems Using rack (1.1.0) from system gems Using sinatra (1.0) from system gems Using thor (0.13.4) from system gems Using usher (0.7.1) from system gems Using padrino-core (0.9.9) from system gems Using padrino-gen (0.9.9) from system gems Using padrino-helpers (0.9.9) from system gems Using padrino-admin (0.9.9) from system gems Using tmail (1.2.7.1) from system gems Using padrino-mailer (0.9.9) from system gems Using padrino (0.9.9) from system gems Using rack-flash (0.1.1) from system gems Using rack-test (0.5.3) from system gems Using rr (0.10.11) from bundler gems Using rspec (1.3.0) from system gems Using thin (1.2.7) from bundler gems Your bundle is complete! Use `bundle show gemname` to see where a bundled gem is installed. demo $ padrino-gen admin => Located unlocked Gemfile for development create admin create admin/app.rb create admin/controllers/base.rb create admin/controllers/sessions.rb create public/admin create public/admin/stylesheets/base.css create public/admin/stylesheets/themes/amro/style.css create public/admin/stylesheets/themes/bec/style.css create public/admin/stylesheets/themes/bec-green/style.css create public/admin/stylesheets/themes/blue/style.css create public/admin/stylesheets/themes/default/style.css create public/admin/stylesheets/themes/djime-cerulean/style.css create public/admin/stylesheets/themes/kathleene/style.css create public/admin/stylesheets/themes/olive/style.css create public/admin/stylesheets/themes/orange/style.css create public/admin/stylesheets/themes/reidb-greenish/style.css create public/admin/stylesheets/themes/ruby/style.css create public/admin/stylesheets/themes/warehouse/style.css create app/models/account.rb create spec/models/account_spec.rb create db/migrate/001_create_accounts.rb create admin/controllers/accounts.rb create admin/views/accounts/_form.haml create admin/views/accounts/edit.haml create admin/views/accounts/index.haml create admin/views/accounts/new.haml inject admin/app.rb force app/models/account.rb create db/seeds.rb create admin/views/base/_sidebar.haml create admin/views/base/index.haml create admin/views/layouts/application.haml create admin/views/sessions/new.haml inject admin/app.rb append config/apps.rb gsub admin/views/accounts/_form.haml gsub admin/controllers/accounts.rb ================================================================= The admin panel has been mounted! Next, follow these steps: ================================================================= 1) Run migrations (if necessary) 2) Run 'padrino rake seed' 3) Visit the admin panel in the browser at '/admin' ================================================================= demo $ padrino rake dm:create => Executing Rake dm:create ... => Creating database <= dm:auto:migrate executed demo $ padrino rake seed => Executing Rake seed ... Which email do you want use for loggin into admin? demo@demo.com Tell me the password to use: Demo ================================================================= Account has been successfully created, now you can login with: ================================================================= email: demo@demo.com password: Demo ================================================================= demo $ padrino-gen model post => Located unlocked Gemfile for development create app/models/post.rb create spec/models/post_spec.rb create db/migrate/002_create_posts.rb demo $ mate app/models/post.rb
added "property :title, String" to app/models/post.rb
demo $ padrino rake dm:migrate => Executing Rake dm:migrate ... == Performing Up Migration #1: create_accounts CREATE TABLE "accounts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" VARCHAR(50), "surname" VARCHAR(50), "email" VARCHAR(50), "crypted_password" VARCHAR(50), "salt" VARCHAR(50), "role" VARCHAR(50)) rake aborted! table "accounts" already exists /Library/Ruby/Gems/1.8/gems/padrino-core-0.9.9/lib/padrino-core/cli/rake.rb:9:in `init' (See full trace by running task with --trace) demo $
Basically what causes the problem is manually editing a model after generating it with padrino-gen model and then running migrations.
Thanks so much! Now we will try your steps and made a fix (if not dm related).
I believe this has something to do with dm's migrate. instead of: $ padrino rake dm:migrate
use $ padrino rake dm:auto:migrate
Actually, I would advise against auto:migrate as it is destructive. I would use
$ padrino rake dm:auto:upgrade
which does non-destructive auto migrations
Yes, I have essentially confirmed that this works. Please let me know if it works for you.
$ padrino rake seed
$ padrino-gen model post
# added "property :title, String" to app/models/post.rb
$ padrino rake dm:auto:upgrade
$ padrino-gen admin_page post
Seems to work fine. Hope that helps. I will re-open if you are still experiencing problems.
Yes, this works!
Glad to hear it :)
I am still having this problem with 0.9.14 and datamapper. I have previously created admin pages, but when I try to generate a page for the model "pass" I get:
padrino-framework-56c5d91/padrino-admin/lib/padrino-admin/generators/orm.rb:17:in `initialize': Model 'pass' could not be found! (Padrino::Admin::Generators::OrmError)
Any ideas?
I've ran: padrino rake dm:migrate and padrino rake dm:auto:upgrade
both completed without errors. But still no luck generating the page.
Sorry, google didn't turn up this issue: http://github.com/padrino/padrino-framework/issues/issue/309
The patch there fixed my problem.
Every time I try and run padrino rake dm:migrate I get the following:
and with --trace:
Is there any way of fixing this?