Passing Data Between Controllers

At this point, we’re using a hardcoded value for cardholder_id, but we haven’t explained what it is. In our simulated payment processor back end, we need to pass an identifier of whose credit card information we want to show.

For the sake of simplicity, let’s assume that, elsewhere in our hypothetical system, when we create credit card info with our payment processor, we explicitly state that the cardholder’s ID is the same as our internal ID used in the CUSTOMERS table. Thus, the value we get back from our controller as customer_id should be the value to use for the cardholder_id.

Given that, how can we get the ID of the customer we’re viewing inside CustomerCreditCardController? We could extract it from ...

Get Rails, Angular, Postgres, and Bootstrap now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.