0

I'm looking to build a rails web app with an admin control panel. I'd like the control panel to use a tabbed interface for controlling users, projects, tasks etc, and I'd like to switch between tabs using jquery tab UI controls with ajax. Also using restful authentication for users and my own code for projects, tasks etc.

Here's what I can't wrap my head around. Normally, I'd have a controller for each tab, so validation is simple, if there's an error (say in the user) i just render the proper action with the object and it's errors and we're set. However, if I'm not refreshing (to different controllers between tabs) how does this work? Do I need to have one massive controller with all the user, project, task validation and controls (ie. crud operations)? Seems like not the greatest design.

Or is there some way I can use an 'admin' controller that encompasses separate controllers for proper crud/error checking etc.

Hope this makes sense?

4

2 に答える 2

2

各タブのコンテンツが個別の ajax リクエストによって呼び出されるようにします。これにより、次の利点が得られます

  • 各タブを簡単に異なるビュー/コントローラーにできるようになりました
  • タブの内容は、使用時にのみロードする必要があります。ユーザーが使用しないタブのコードを処理したり、html をダウンロードしたりすることはありません。

このルートを使用したくない場合 (つまり、ページ ダウンロードのタブのすべてのコンテンツを 1 回のリクエストでロードする必要がある場合) は、ヘルパー メソッドとパーシャルを使用してコードを分離できます。ここで私の答えを参照してください: Rails Sub-controllers?

于 2009-04-21T16:27:03.533 に答える
0

個人的には、フォームでインライン検証を使用します。 Jqueryはそれをかなりうまくやっていますが、それを助けることができるライブラリがたくさんあります.

それはまさにあなたが探していたものではないと思いますが、それはあなたの仕事をより簡単にするでしょう. もちろん、誰も検証をバイパスできないように、モデルの検証を維持します (firebug などを使用)

于 2009-04-21T16:18:37.783 に答える