0

私のアプリは2つの異なるデータベースで実行され、アプリケーションロジックを使用してそれらを処理します。

外部データベースUserモデルがあり、default_roleクラスにのみIDを記録します。

したがって、インデックステンプレートでは、リモートからアカウントを取得します。アカウントごとに、テーブルにクエリを実行して不変の情報を出力する必要があり、テーブルの役割を変更できるようにします。

インデックス情報=リモートテーブル情報(名前surname ecc)+マイテーブル情報(ロール)

best_in_placeを使用して、ユーザーのrole_idフィールドを編集します。

問題は、外部からのインデックスサイクル@operatorsです。私の側にある役割を変更する必要があります!

- @operators.each do |ope|   #cycle users
      %tr
        %td
          - user = User.find_by_bay_id(ope.account_id)
          - df = DefaultRole.find_by_operator_id(user.id)
          = best_in_place [:admin, df], :role_id, :type => :select, :collection => [[1, 'admin'], [2, 'coordinator'], [3, 'operator'], [4, 'base']]

とコントローラーの私の更新:

respond_to :html, :json

def index
  @operators = some logic from model where I get all the users
end

def update
  @df = DefaultRole.find(params[:id])
  @df.update_attributes(params[:default_role])
  respond_with [:admin, @df]
end

しかし、コントローラーのupdateメソッドも呼び出されませんでした。通常、コレクションタグをチェックし、変更することはできますが、送信することはできません。

私は何が間違っているのですか?

編集

私のブラウザはリクエストをキャッチしません。

4

2 に答える 2

0

私はついにエラーを見つけました。

https://github.com/bernat/best_in_place/issues/217

これは、そのバージョンの best_in_place での Jquery の問題でした。ランニング:

bundle update

サーバーを再起動すると問題が解決します、ありがとう

于 2013-01-24T16:20:21.873 に答える
0

Best_in_place gem は、JSON 呼び出しを使用してコンテンツを更新します。この場合respond_to json、コントローラーに次のようなステートメントが必要です。

def update
 @df = DefaultRole.find(params[:id])
respond_to do |format|
  if @df.update_attributes(params[:default_role])
    format.html { redirect_to root_path, notice: 'Role was successfully updated.' }
    format.json { head :no_content }
  else
    format.html { render action: "edit" }
    format.json { render json: @df.errors, status: :unprocessable_entity }
  end 
end

ビューに変数の仕様を含めるのは奇妙だと思います。それらはコントローラに属します ( - user = User.find_by_bay_id(ope.account_id) - df = DefaultRole.find_by_operator_id(user.id).

于 2013-01-24T10:40:05.570 に答える