Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jbuilder without the .json extension

Doing http://localhost:3000/options/audio

And I get error:

Missing template options/audio, application/audio with {:locale=>[:en], :formats=>[:html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee]}. Searched in: * "/Users/mmahalwy/Desktop/Code/quran.com/QuranAPI/app/views"

When I do http://localhost:3000/options/audio.json

That renders my Jbuilder file and the desired json. How can I render my jbuilder template with the .json extension?

like image 878
Mohamed El Mahallawy Avatar asked Dec 05 '25 15:12

Mohamed El Mahallawy


1 Answers

The jbuilder documentation tells you to create your jbuilder template as a *.json.jbuilder file. This makes the route look for the .json extension. If you remove the .json part and make your file *.jbuilder you will be able to go to the route without the .json extension.

Example:

Filename: index.jbuilder route: get 'ticket', to: 'tickets#index'

like image 95
watzon Avatar answered Dec 07 '25 03:12

watzon



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!