2013-03-21 2 views
1

auto_html 깨는 레일 마이그레이션에 문제가 있습니다. 나는이 db/first migration 실행 추적을 얻는다. 마이그레이션이 일을 주석없이 제대로 실행되도록이 문제를 처리하는 방법에auto_html 레일 마이그레이션을 깨기

auto_html_for :story do 
    strip_tags 
    html_escape 
    end 

어떤 제안 :

나는 모델에 같은 코드를 주석으로 그것을 해결?

$rake db:migrate 

** Invoke db:migrate (first_time) 
** Invoke environment (first_time) 
** Execute environment 
rake aborted! 
PG::Error: ERROR: relation "profiles" does not exist 
LINE 4:    WHERE a.attrelid = '"profiles"'::regclass 
             ^
:    SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull 
       FROM pg_attribute a LEFT JOIN pg_attrdef d 
       ON a.attrelid = d.adrelid AND a.attnum = d.adnum 
      WHERE a.attrelid = '"profiles"'::regclass 
       AND a.attnum > 0 AND NOT a.attisdropped 
      ORDER BY a.attnum 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `async_exec' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1158:in `exec_no_cache' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:664:in `block in exec_query' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:280:in `block in log' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/abstract_adapter.rb:275:in `log' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:663:in `exec_query' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:1283:in `column_definitions' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/postgresql_adapter.rb:859:in `columns' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/connection_adapters/schema_cache.rb:12:in `block in initialize' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `yield' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `default' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:228:in `columns' 
/Users/heather/.rvm/gems/[email protected]/gems/activerecord-3.2.8/lib/active_record/model_schema.rb:248:in `column_names' 
/Users/heather/.rvm/gems/[email protected]/gems/auto_html-1.6.0/lib/auto_html/auto_html_for.rb:21:in `auto_html_for' 
/Users/heather/3r/website/app/models/profile.rb:73:in `<class:Profile>' 
/Users/heather/3r/website/app/models/profile.rb:1:in `<top (required)>' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:in `load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:469:in `block in load_file' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:639:in `new_constants_in' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:468:in `load_file' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:353:in `require_or_load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:502:in `load_missing_constant' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:192:in `block in const_missing' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:190:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:190:in `const_missing' 
/Users/heather/3r/website/app/admin/profiles.rb:1:in `<top (required)>' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/application.rb:190:in `block in load!' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/application.rb:190:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/application.rb:190:in `load!' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/application.rb:213:in `routes' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin.rb:79:in `routes' 
/Users/heather/3r/website/config/routes.rb:41:in `block in <top (required)>' 
/Users/heather/.rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:282:in `instance_exec' 
/Users/heather/.rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:282:in `eval_block' 
/Users/heather/.rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/routing/route_set.rb:260:in `draw' 
/Users/heather/3r/website/config/routes.rb:28:in `<top (required)>' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `block in load' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:245:in `load' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `block in load_paths' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:40:in `load_paths' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application/routes_reloader.rb:16:in `reload!' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application.rb:108:in `reload_routes!' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/reloader.rb:34:in `reload!' 
/Users/heather/.rvm/gems/[email protected]/gems/activeadmin-0.5.1/lib/active_admin/reloader.rb:61:in `block in attach!' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:429:in `_run__574638835061218640__prepare__331886071729593740__callbacks' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:405:in `__run_callback' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/callbacks.rb:81:in `run_callbacks' 
/Users/heather/.rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!' 
/Users/heather/.rvm/gems/[email protected]/gems/actionpack-3.2.8/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `instance_exec' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/initializable.rb:30:in `run' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/initializable.rb:55:in `block in run_initializers' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/initializable.rb:54:in `run_initializers' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application.rb:136:in `initialize!' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/railtie/configurable.rb:30:in `method_missing' 
/Users/heather/3r/website/config/environment.rb:5:in `<top (required)>' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `block in require' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:236:in `load_dependency' 
/Users/heather/.rvm/gems/[email protected]/gems/activesupport-3.2.8/lib/active_support/dependencies.rb:251:in `require' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application.rb:103:in `require_environment!' 
/Users/heather/.rvm/gems/[email protected]/gems/railties-3.2.8/lib/rails/application.rb:295:in `block (2 levels) in initialize_tasks' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:228:in `call' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:223:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain' 
/Users/heather/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:187:in `block in invoke_prerequisites' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:185:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:185:in `invoke_prerequisites' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:165:in `block in invoke_with_call_chain' 
/Users/heather/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:101:in `each' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/lib/rake/application.rb:70:in `run' 
/Users/heather/.rvm/gems/[email protected]/gems/rake-10.0.3/bin/rake:33:in `<top (required)>' 
/Users/heather/.rvm/gems/[email protected]/bin/rake:19:in `load' 
/Users/heather/.rvm/gems/[email protected]/bin/rake:19:in `<main>' 
/Users/heather/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `eval' 
/Users/heather/.rvm/gems/[email protected]/bin/ruby_noexec_wrapper:14:in `<main>' 
Tasks: TOP => db:migrate => environment 
Heathers-MacBook-Pro:website heather$ 
+0

나는 그 질문에 대한 답을 알고하지 않습니다,하지만 여전히 나는 https://github.com (최고 [auto_haml 보석] 나에게 보여 주셔서 감사드립니다/dejan/auto_html), 제게 엄지 손가락을 줘요! – weltschmerz

답변

1

기본적으로 레이크가 실행중인 경우 해결책을 찾았습니다. auto_html을 비활성화하십시오. 여기에 auto_html 이니셜의 코드입니다 :

if File.basename($0) == 'rake' && ARGV.grep(/db:/) 
    class ActiveRecord::Base 
    def self.auto_html_for(field, &block) 
     #nothing 
    end 
    end 

else 

    AutoHtml.add_filter(:strip_tags).with({}) do |text, options| 
    view = ActionView::Base.new 
    view.strip_tags text 
    end 
    AutoHtml.add_filter(:autolink).with({}) do |text, options| 
    view = ActionView::Base.new 
    view.auto_link(text, :html => { :target => '_blank', :rel => "nofollow" }) 
    end 


    class ActiveRecord::Base 
    class << self 
     alias_method :auto_html_for!, :auto_html_for 
    end 

    def self.auto_html_for(field, &block) 
     auto_html_for!(field, &block) 
    end 
    end 

end 
+0

그것은 장치와 관련이 있습니다. 만약 당신이 devise route를 꺼낸다면, 그것은 또한 작동합니다. – Marc

관련 문제