Last active
December 25, 2015 15:19
-
-
Save mrded/6997495 to your computer and use it in GitHub Desktop.
Rails: How to render different format.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CodesController < ApplicationController | |
def index | |
@codes = Code.all | |
respond_to do |format| | |
format.html | |
format.json do | |
render json: @codes, | |
only: [:id, :name, :description] | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Opcs::Application.routes.draw do | |
get "codes/index(.:format)" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment