rake:db迁移不在Refinery CMS应用程序中发生

时间:2013-08-26 18:48:11

标签: ruby-on-rails ruby rake refinerycms

http://refinerycms.com/guides/getting-started#rails-application-templates

处进行使用Refinery CMS的教程

6使用您的第一个引擎扩展炼油厂

表示要运行

rails generate refinery:engine singular_model_name attribute:type [attribute:type ...]

然后运行

rails generate refinery:engine event title:string date:datetime photo:image blurb:text

之后我完成了剩下的工作,但rake db:migrate似乎无法正常工作,因为当我尝试运行rake db:seed时,我遇到了运行rake db:migrate所需的错误。我尝试在本地运行应用程序并获得此

events

这是在某个地方的终端,看起来很相关

ActionView::Template::Error (Could not find table 'refinery_events'):
1: <%= render 'refinery/admin/search_header', :url => refinery.events_admin_events_path %>
2: <div class='pagination_container'>
3:   <% if @events.any? %>
4:     <%= render 'events' %>
5:   <% else %>
6:     <p>

我也有关于作者的错误,但教程没有提到它

Using refinerycms-events (1.0) from source at vendor/extensions
refinerycms-events at /Users/juan.gallardo/Desktop/myfiles/test-projects/rickrockstar/vendor/extensions/events did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  authors may not be empty

Using refinerycms-singular_model_names (1.0) from source at vendor/extensions
refinerycms-singular_model_names at /Users/juan.gallardo/Desktop/myfiles/test-projects/rickrockstar/vendor/extensions/singular_model_names did not have a valid gemspec.
This prevents bundler from installing bins or native extensions, but that may not affect its functionality.
The validation message from Rubygems was:
  authors may not be empty

所以我再次完成了这个过程

jgallardo:rickrockstar juan.gallardo$ rails generate refinery:events
    rake  refinery_events:install:migrations
  append  db/seeds.rb
jgallardo:rickrockstar juan.gallardo$ rake db:migrate
rake aborted!

这一次,我清楚地看到rake aborted,但无论如何都试过了

jgallardo:rickrockstar juan.gallardo$ rake db:seed
You have 2 pending migrations:
  20130826173639 CreateSingularModelNamesSingularModelNames
  20130826173941 CreateEventsEvents
Run `rake db:migrate` to update your database then try again.

我在Google上搜索了有待迁移的内容,我看到有人告诉其他有类似问题的人与--trace一起运行,所以这是我的尝试

jgallardo:rickrockstar juan.gallardo$ rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
rake aborted!
/Users/juan.gallardo/Desktop/myfiles/test-projects/rickrockstar/db/migrate/20130826173639_create_singular_model_names_singular_model_names.refinery_singular_model_names.rb:7: syntax error, unexpected '[', expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
  t.type :[attribute
           ^
/Users/juan.gallardo/Desktop/myfiles/test-projects/rickrockstar/db/migrate/20130826173639_create_singular_model_names_singular_model_names.refinery_singular_model_names.rb:8: syntax error, unexpected ..., expecting tSTRING_CONTENT or tSTRING_DBEG or tSTRING_DVAR or tSTRING_END
  t.string :...]
               ^
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:537:in `load_migration'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:533:in `migration'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:528:in `migrate'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:720:in `block (2 levels) in migrate'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:775:in `call'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:775:in `block in ddl_transaction'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/transactions.rb:208:in `transaction'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:775:in `ddl_transaction'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:719:in `block in migrate'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:700:in `each'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:700:in `migrate'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:570:in `up'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/migration.rb:551:in `migrate'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/activerecord-3.2.14/lib/active_record/railties/databases.rake:193:in `block (2 levels) in <top (required)>'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:236:in `call'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:236:in `block in execute'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:231:in `each'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:231:in `execute'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:175:in `block in invoke_with_call_chain'
/Users/juan.gallardo/.rvm/rubies/ruby-2.0.0-p195/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:168:in `invoke_with_call_chain'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/task.rb:161:in `invoke'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:149:in `invoke_task'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:106:in `each'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:106:in `block in top_level'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:115:in `run_with_threads'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:100:in `top_level'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:78:in `block in run'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:165:in `standard_exception_handling'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/lib/rake/application.rb:75:in `run'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/gems/rake-10.1.0/bin/rake:33:in `<top (required)>'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/bin/rake:23:in `load'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/bin/rake:23:in `<main>'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `eval'
/Users/juan.gallardo/.rvm/gems/ruby-2.0.0-p195/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => db:migrate

2 个答案:

答案 0 :(得分:1)

如果您阅读并思考他们所说的内容而不仅仅是复制&amp;将部分内容粘贴到终端中。

在这种情况下,您复制和粘贴的示例是:

rails generate refinery:engine singular_model_name attribute:type [attribute:type ...] 

但是,在生成事件扩展名时,您已成功将此替换为正确的语法,因此没有问题。

删除名为CreateSingularModelNamesSingularModelNames的迁移及其整个相应的扩展名。您复制粘贴的示例语法,该语法不会产生有效的Ruby。

答案 1 :(得分:0)

正如在接受的答案中指出的那样,我复制粘贴了错误的代码,如下面6.2所示

sample code

我最终只是删除了项目并重新开始。但后来我从下面粘贴了

copy pasta

一切都运转良好。