KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm going through the Getting Started with Rails guide and got confused with section 6.7. After generating a scaffold I find the following auto-generated block in my controller: def index @posts = Post.all respond_to do |format| format.html # index.html.erb format.json { render :json => @posts } end end I'd like to understand how the respond_to block actually works. What type of variable is format? Are .html and .json methods of the format object? The documentation for ActionController::MimeResponds::ClassMethods::respond_to doesn't answer the question.
Tags (comma-separated)
Save Edits
Cancel