1

レール用の「in_place_editing」プラグインを使用して、インプレース編集でフォームをレンダリングしています。デフォルトのテンプレートがレールによって選択されている限り(コントローラー内で「render」メソッドが呼び出されていない場合)、問題なく動作しますが、「render :partial => 'partial_name'」呼び出しを使用してパーシャルをレンダリングしようとすると、うまくいきません。これは既知の問題ですか (in_place_edit はパーシャルでは機能しませんか?)、それとも何か不足していますか? パーシャルのレンダリング中に次のエラーが発生します。

Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
.../vendor/plugins/in_place_editing/lib/in_place_macros_helper.rb:74:in `in_place_editor_field'
4

2 に答える 2

1

You don't provide anywhere near enough information in your question, giving only two lines of the backtrace and no fragments of the view which does work, or the partial which does not. This means that any attempts to answer you must be based largely on guesswork. That said, the in-place editor helper is just a helper method like any other, nothing special. You can call it from just about any view component. It is highly likely that the way in which that view is included by the controller, or indeed a parent view, is not the reason it is failing.

The helper method is complaining about a nil value. This means that most likely, your partial is invoking in_place_editor_field and passing it values which are not defined in the partial. Check to make sure it isn't using local variables which are not defined, compared to those used in the view where your in_place_editor_field call works; check to make sure that it isn't asking for different instance variables too. In all probability you'll find the views which work are using one variable name while the partial you've tried to render is using another.

The render :partial => ... mechanism supports different ways of explicitly passing in values to the partial; you may choose to use these to clarify your code. See the :locals and :object options for the "Rendering partials" section of the render documentation in the Rails API at:

于 2010-02-24T12:13:53.867 に答える