Topic: confused about redirect_to and render
i realize it is somewhat of a strange question but i'm new to webdevelopment, rails and ruby. i'm reading a book foundation rails 2, there i found the following piece of code:
def create @toy = current_user.toys.build(params[:toy]) if @toy.save redirect_to @toy else case params[:toy][:status] when 'LOST' render :file => 'toys/lost', :use_full_path => true, :layout => true when 'FOUND' render :file => 'toys/found' :use_full_path => true, :layout => true end end end
the question i have is why do we use render in the else clause, why can't we use redirect_to or vice verse, why do we use redirect_to in the if clause, why don't we use render?
Last edited by cyboman (2010-12-26 10:57:12)