This is not the document you are looking for? Use the search form below to find more!

Report home > Others

Rails2’s template and respond_to method

0.00 (0 votes)
Document Description
Rails2’s template and respond_to method
File Details
Submitter
  • Name: indiana

We are unable to create an online viewer for this document. Please download the document instead.

Rails2’s template and respond_to method screenshot

Add New Comment




Related Documents

Ohio’s Ogt And Oat Success Port

by: tommy, 10 pages

Ohio's OGT and OAT  SUCCESS Portal for more information contact Kathy Lawrence at X3096   Please remember to turn on the speaker notes when viewing this presentation (face icon ...

NYC iZone at WNET’s Teaching and Learning

by: wick, 14 pages

 Core elements of school innovation New school models will focus on capturing and replicating a core set of practices designed to disrupt the fundamental assumptions about ...

Irish Venture Funding - Ireland’s Innovation and Technology Economy - John McIntyre - Enterprise Ireland - Stanford - Jan0410

by: sebestyen, 19 pages

Stanford Engineering's European Entrepreneurship and Innovation Irish Venture Funding John McIntyre, SVP Enterprise Ireland Silicon Valley [email_address] Tel : +1-650-329-0404 ...

south Africa’s Scarce and Critical Skills

by: gusta, 32 pages

South Africa’s Skills Crisis Gill Connellan Chairperson Are We Getting the Skills Development Deserve? 17% of school leavers achieved the standard necessary to proceed ...

Dynamics 2 - Newton’s 1st and 2nd Laws of Motion

by: lian, 14 pages

DYNAMICS Newton’s 1 st Law of Motion Newton’s 2 nd Law of Motion Objectives State Newton’s 1st Law of Motion Show an understanding that mass is the ...

Discussion of Jeb’s Jobs and Customer Care

by: justin, 3 pages

Greeting with No name given department Didn't take break away from Kept calm (mostly) workstation Bad advice ...

Amanda Nevins from Zappos Keynote IBF\’s Demand Planning and Forecasting Conference

by: ronja, 38 pages

Amanda Nevins from Zappos Keynote IBF\’s Demand Planning and Forecasting Conference

Sphere Humanitarian Standards for Shelter and Settlement Planning in Kenya’s Dadaab Refugee Camps

by: johanna, 109 pages

Sphere Humanitarian Standards for Shelter and Settlement Planning in Kenya’s Dadaab Refugee Camps

Mobile web development techniques (and Opera’s developer tools)

by: hulyah, 58 pages

Mobile web development techniques (and Opera’s developer tools)

Search Institute’s Developmental Assets Profile: What It Is and How to Use It

by: sebestyen, 19 pages

Search Institute’s Developmental Assets Profile: What It Is and How to Use It

Content Preview
Rails2’s template(respond_to method)可以怎麼玩?ihower@handlino.comabout me• 張文鈿 (a.k.a ihower)http://ihower.idv.tw/blog/• 和多(Handlino) 鐵道員• 主持 http://registrano.com 開發agenda• Ruby on Rails overview• respond_to (what’s format you want)• template (how to generate format)Rails Overview• an open-source web framework for developing database-backed web applications• Model-View-Control pattern• a pure-Ruby development environment, from the Ajax in the view, to the request and response in the controller, to the domain model wrapping the database.Browser決定哪一個MVCController 和 ActionModel-View-ControlHTTP requestGET /users/1route.rbUsersControllerModeldef show@user = User.find(params[:id])Databaserespond_to do |format|format.htmlformat.xmlend#show.html.erbendViewdef index<html>...... <h1>User Profile</h1>end <p><%= @user.nickname %></p></html>endrespond_to你要什麼格式?One Action, Multiple Response Formatsdef index@users = User.find(:all)respond_to do |format| format.html # index.html.erb format.xml { render :xml => @user.to_xml }endendformat.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head><body> <p> ihower at 2008-01-19 </p></body></html>format.xml<?xml version="1.0" encoding="UTF-8"?><user> <created-at type="datetime">2008-01-19T09:55:32+08:00</created-at> <id type="integer">2</id> <name>ihower</name> <updated-at type="datetime">2008-01-19T09:55:32+08:00</updated-at></user>you don't need this!def show_html@users = User.find(:all)enddef show_xml@users = User.find(:all)render :xml => @user.to_xmlenddef show_json@user = User.find(:all)render :json => @user.to_jsonend只需定義一個 action減少重複的程式碼Don’t repeat yourself

Download
Rails2’s template and respond_to method

 

 

Your download will begin in a moment.
If it doesn't, click here to try again.

Share Rails2’s template and respond_to method to:

Insert your wordpress URL:

example:

http://myblog.wordpress.com/
or
http://myblog.com/

Share Rails2’s template and respond_to method as:

From:

To:

Share Rails2’s template and respond_to method.

Enter two words as shown below. If you cannot read the words, click the refresh icon.

loading

Share Rails2’s template and respond_to method as:

Copy html code above and paste to your web page.

loading