I am building a Rails 3.2 app. In this app I got two controllers sharing the same nested controller (transactions).
The paths looks like this:
http://localhost:3003/admin/purchases/6/transactions
and like this
http://localhost:3003/admin/subscriptions/6/transactions
In the transactions index action, how can I check if the parent is either purchases or subscriptions?
Assuming you have defined this as a nested resource in your routes file, you could check for params[:purchase_id] and params[:subscription_id]:
if params[:purchase_id]
# parent is purchase
elsif params[:subscription_id]
# parent is subscription
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With