0

持っている:

class User < WsBasedPlainRubyObject
  def subscriptions
     Subscription.where(:user_id=>self.id)
  end

  [...]
end

class Subscription < ActiveRecord::Base
  has_user #using an underlying composed_of
  [...]
end

resources :users do
  resources :subscriptions
end

user_subscriptions_path(@current_user)ビューでヘルパーメソッドを使用しようとすると、params[:user_id]コンテンツにIDではなくユーザーのシリアル化が含まれます。

ActiveModelを使用して、これを回避する実用的な方法はありますか?

4

1 に答える 1

0

どうやら、user_subscriptions_path(@current_user.id)うまく動作します..

とにかく、ActiveModel を使用して Ruby オブジェクトを ActiveRecord オブジェクトのように動作させる方法についての素晴らしい記事を次に示します。 ActiveModel: Make Any Ruby Object Feel Like ActiveRecord

于 2011-07-08T11:25:13.040 に答える