Having:
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
When I try to use the helper method user_subscriptions_path(@current_user) on the view, params[:user_id] content contains the user’s serialization instead of its id.
Is there any practical way to avoid this, maybe by using ActiveModel ?
Apparently,
user_subscriptions_path(@current_user.id)works fine..Anyway, here goes a nice writeup on how to make Ruby objects behave like ActiveRecord Objects by using ActiveModel:
ActiveModel: Make Any Ruby Object Feel Like ActiveRecord