mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Change examples in guide to reflect changes from XML -> JSON
This commit is contained in:
parent
c60e207674
commit
e6898e3b60
2 changed files with 10 additions and 10 deletions
|
@ -120,7 +120,7 @@ Now that we have a user model to play with, we will just edit the +app/controlle
|
|||
<ruby>
|
||||
class UsersController < ApplicationController
|
||||
# POST /users
|
||||
# POST /users.xml
|
||||
# POST /users.json
|
||||
def create
|
||||
@user = User.new(params[:user])
|
||||
|
||||
|
@ -130,10 +130,10 @@ class UsersController < ApplicationController
|
|||
UserMailer.welcome_email(@user).deliver
|
||||
|
||||
format.html { redirect_to(@user, :notice => 'User was successfully created.') }
|
||||
format.xml { render :xml => @user, :status => :created, :location => @user }
|
||||
format.json { render :json => @user, :status => :created, :location => @user }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.xml { render :xml => @user.errors, :status => :unprocessable_entity }
|
||||
format.json { render :json => @user.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -279,14 +279,14 @@ This command shows you where you are in the code by printing 10 lines centered a
|
|||
[1, 10] in /PathToProject/posts_controller.rb
|
||||
1 class PostsController < ApplicationController
|
||||
2 # GET /posts
|
||||
3 # GET /posts.xml
|
||||
3 # GET /posts.json
|
||||
4 def index
|
||||
5 debugger
|
||||
=> 6 @posts = Post.all
|
||||
7
|
||||
8 respond_to do |format|
|
||||
9 format.html # index.html.erb
|
||||
10 format.xml { render :xml => @posts }
|
||||
10 format.json { render :json => @posts }
|
||||
</shell>
|
||||
|
||||
If you repeat the +list+ command, this time using just +l+, the next ten lines of the file will be printed out.
|
||||
|
@ -298,7 +298,7 @@ If you repeat the +list+ command, this time using just +l+, the next ten lines o
|
|||
12 end
|
||||
13
|
||||
14 # GET /posts/1
|
||||
15 # GET /posts/1.xml
|
||||
15 # GET /posts/1.json
|
||||
16 def show
|
||||
17 @post = Post.find(params[:id])
|
||||
18
|
||||
|
@ -315,14 +315,14 @@ On the other hand, to see the previous ten lines you should type +list-+ (or +l-
|
|||
[1, 10] in /PathToProject/posts_controller.rb
|
||||
1 class PostsController < ApplicationController
|
||||
2 # GET /posts
|
||||
3 # GET /posts.xml
|
||||
3 # GET /posts.json
|
||||
4 def index
|
||||
5 debugger
|
||||
6 @posts = Post.all
|
||||
7
|
||||
8 respond_to do |format|
|
||||
9 format.html # index.html.erb
|
||||
10 format.xml { render :xml => @posts }
|
||||
10 format.json { render :json => @posts }
|
||||
</shell>
|
||||
|
||||
This way you can move inside the file, being able to see the code above and over the line you added the +debugger+.
|
||||
|
@ -333,14 +333,14 @@ Finally, to see where you are in the code again you can type +list=+
|
|||
[1, 10] in /PathToProject/posts_controller.rb
|
||||
1 class PostsController < ApplicationController
|
||||
2 # GET /posts
|
||||
3 # GET /posts.xml
|
||||
3 # GET /posts.json
|
||||
4 def index
|
||||
5 debugger
|
||||
=> 6 @posts = Post.all
|
||||
7
|
||||
8 respond_to do |format|
|
||||
9 format.html # index.html.erb
|
||||
10 format.xml { render :xml => @posts }
|
||||
10 format.json { render :json => @posts }
|
||||
</shell>
|
||||
|
||||
h4. The Context
|
||||
|
|
Loading…
Reference in a new issue