The respond_to block is optional, and if the block is missing rails
will execute a render :task so for the edit task it will look for the /
controller/edit.html.erb file

Here is information from the api...
http://apidock.com/rails/ActionController/MimeResponds/InstanceMethods/respond_to



On Dec 29, 9:13 am, Sarah Allen <[email protected]>
wrote:
> I'm new to Rails and I'm trying to understand the code created by
> generate scaffold.  I'm using Rails 2.2.2.
>
> $ ./script/generate scaffold Task description:string
>
> generated the following code in app/controller/tasks_controller.rb
>
> class TasksController < ApplicationController
>   # GET /tasks
>   # GET /tasks.xml
>   def index
>     @tasks = Task.find(:all)
>
>     respond_to do |format|
>       format.html # index.html.erb
>       format.xml  { render :xml => @tasks }
>     end
>   end
>
>   # GET /tasks/1
>   # GET /tasks/1.xml
>   def show
>     @task = Task.find(params[:id])
>
>     respond_to do |format|
>       format.html # show.html.erb
>       format.xml  { render :xml => @task }
>     end
>   end
>
>   # GET /tasks/new
>   # GET /tasks/new.xml
>   def new
>     @task = Task.new
>
>     respond_to do |format|
>       format.html # new.html.erb
>       format.xml  { render :xml => @task }
>     end
>   end
>
>   # GET /tasks/1/edit
>   def edit
>     @task = Task.find(params[:id])
>   end
>
> I noticed that the edit method is missing some code.  If I remove those
> same lines from each of the methods above.  The code still works, why?
>
> I couldn't find ApplicationController in the API docs 
> athttp://api.rubyonrails.org/... I figured the behavior must be defined
> in the super class, but I can't seem to find the code for it either.
>
> Can someone point me in the right direction to illuminate this mystery?
>
> Thanks in advance,
> Sarah
>
> http://www.ultrasaurus.com/code(where I'm keeping a journal of my
> learning Rails so far)http://www.ultrasaurus.com(primary blog)
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to