0

iOS デバイスにプッシュ通知を送信する Rails アプリケーションを開発しています。apn_on_rails gem を使用しています。Railsコンソールではすべて正常に動作します。content_forただし、サーバーを実行すると、またはform_tagなどのすべての基本的なビュー メソッドに対して未定義のメソッド エラーが発生します。

外出するとrequire 'apn_on_rails'development.rbビューは再び機能しますが、もちろんプッシュ通知はありません。

トレースの例を次に示します。

Processing DashboardController#index (for 127.0.0.1 at 2011-02-27 13:55:59) [GET]
User Load (0.2ms)   SELECT * FROM "users" WHERE ("users"."id" = 1) 
CACHE (0.0ms)   SELECT * FROM "users" WHERE ("users"."id" = 1) 
Rendering template within layouts/dashboard
Rendering dashboard/index

ActionView::TemplateError (undefined method `content_for' for #<ActionView::Base:0x103343970>) on line #1 of app/views/dashboard/index.html.erb:
1: <% content_for :header do %>
2:  <%= render :partial => "header", :locals => {:title => "Dashboard"} %>
3: <% end %>


app/views/dashboard/index.html.erb:1
app/controllers/dashboard_controller.rb:6:in `index'

Rendered rescues/_trace (28.5ms)


Processing ApplicationController#index (for 127.0.0.1 at 2011-02-27 13:55:59) [GET]

ActionView::TemplateError (undefined method `debug' for #<ActionView::Base:0x103343970>) in /Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb:



Rendered rescues/_trace (24.0ms)
/!\ FAILSAFE /!\  Sun Feb 27 13:55:59 +0100 2011
 Status: 500 Internal Server Error

ActionView::TemplateError (undefined method `debug' for #<ActionView::Base:0x1031eaad8>) in /Library/Ruby/Gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb:




In /library/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/templates/rescues/_request_and_response.erb

助けてくれてありがとう...

4

1 に答える 1

1

呼び出しているかどうかは明らかではありませんconfig.gem 'apn_on_rails'- ライブラリを :ing しているように聞こえますがrequire、これはおそらくこの時点ですべきではないことです: 環境設定のポイントです。

config.gem を環境セットアップ (つまり、development.rb) に配置しますが、最終的なrequires が後で発生するようにします (-> 問題のコントローラー / モデル / ヘルパー内)。

于 2011-02-27T18:52:54.547 に答える