DEV Community

Discussion on: Create a Basic API with Ruby on Rails

Collapse
decentralizuj profile image
decentralizuj • Edited on

Nice comment... Instance variables make sense in controllers, so could be used in views:

@band    = Band.find_by(id: params[:id])
@guitars = Guitar.where(band_id: @band.id).all
Enter fullscreen mode Exit fullscreen mode

Now we can see band's guitar on band page.

In API, this is done by Serializers.