Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 304 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
304
Dung lượng
5,94 MB
Nội dung
this print for content only—size & color not accurate spine = 0.711" 304 page count Books for professionals By professionals ® PracticalRESTonRails2 Projects Dear Reader, Over the last few years, the landscape of the Web has been changing. Service providers are progressively opening up their applications—making their data available to anyone who wants to use it. This aspect of the Web 2.0 phenom- enon has resulted in unprecedented new opportunities for developers. At the same time, Ruby onRails has become an increasingly well-known option for building applications on the web, and it has been undergoing con- tinuous development and refinement. Toward the end of 2007, Rails2 was released, bringing with it a number of new features and encapsulating a particular philosophy—REST (Representational State Transfer)—that meshes nicely with the open Web. This book is about the intersection of those two trends. You’ll see arguments for the benefits of openness, and you’ll learn how the newest features in Rails make it easier than ever to develop interconnected applications. Using RESTful methodologies, you’ll learn how to make your web applications less complex and more responsive. You’ll also get hands-on experience in building these applications—from MovieList, a fully fledged Rails2 RESTful server application, to a variety of clients (in JavaScript, PHP, and Rails) on several platforms (including Safari on the iPhone and the Facebook application platform) that consume the movie data it provides. It will bring you up to speed on real-world best practices through a variety of commonly encountered scenarios. I can’t think of a more exciting time to be building things for the Web, and I hope that the projects in this book convey some of that excitement to you. Happy coding! Ben Scofield US $42.99 Shelve in Programming Languages User level: Intermediate–Advanced Scofield RESTonRails2 Projects The eXperT’s Voice ® in WeB DeVelopmenT cyan maGenTa yelloW Black panTone 123 c Ben Scofield Companion eBook Available THE APRESS ROADMAP Beginning Ruby: From Novice to Professional Beginning Rails: From Novice to Professional Beginning Ruby onRails E-Commerce: From Novice to Professional PracticalRESTonRails2 Projects Practical Ruby Gems PracticalRails Projects www.apress.com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN-13: 978-1-59059-994-5 ISBN-10: 1-59059-994-2 9 781590 599945 5 4 2 9 9 Learn everything you need to know to build open Web 2.0 applications with RailsPracticalRESTonRails2 Projects Practical [...]... more recent rise of REST as an alternative style of design Chapter 2 moves the focus to Rails and especially the features added in Rails2 that support the design and development of RESTful applications Rails2 has been out since late 20 07, but many developers seem unaware of the functionality it provides and the conventions that have grown up around using it After the introductory content in the first... implementation flaws that might otherwise be more obvious Building Rails Applications The final benefit of adopting REST is relevant to you and me for a very different reason Since 20 06, the developers behind Rails have made a concerted effort to support RESTful architectures Through new features, new conventions, and educating the community, they have made it much easier to develop a RESTful application in Rails. .. order, however One of the more exciting things about working in REST and Rails is the speed of change During the writing of this book, Rails2 was officially released (and quickly upgraded to version 2. 0 .2) , the iPhone SDK (for building completely native applications, as opposed to the iPhone web applications you’ll be working with in Chapter 6) was made available, and the Facebook application platform... 25 9 What Is the Enterprise? 25 9 Problems with REST 26 0 Problems with Rails 26 0 Why REST? 26 1 Integration with REST 26 1 Examples of Integration 26 1 Scalability... via some sort of key When building a truly RESTful service, however, developers must abandon server-based sessions and other such tricks for simulating statefulness Happily, however, Rails2 incorporates a solution to this issue, as you’ll see in the discussion of cookie-based sessions in Chapter 2 The third constraint requires that responses from a server in a RESTful system must be flagged (implicitly... 24 5 The Bad Problems 25 2 Monitoring Your Site 25 2 Identity and Authorization 25 7 Other Tactics 25 7 Summary 25 8 s CHAPTER 9 REST in the Enterprise ... the sample application—you won’t have to worry about proxies, tunnels, and the like here With code -on- demand, clients of a RESTful application can be modified on- the-fly by downloading additional functional code from the server (e.g., applets) This is another constraint that you will not find much information about in this book; it is a topic that has not yet been addressed in the Rails community, though... 20 8 ix 9945FM.qxd x 4/7/08 11:06 AM Page x sCONTENTS Project 2: The FBML Application 20 8 Setup 20 9 Facebook Integration 21 4 Adding Interactivity 22 3 Further Projects 23 4 Summary... available at /users /2/ most_recent_movie no longer points to the same object as /movies/ 123 ) The second requirement of the uniform interface is that RESTful systems allow the description and transformation of resource state via representations of that resource If you want to retrieve info about a given movie, you issue a GET request to the server The server then constructs a representation appropriate to... applications that use HTTP Given that, and that the specific imple mentation of REST in Rails2 is in fact tightly linked to HTTP (as you’ll see in the next chapter) —we can be forgiven for ignoring the distinction for now The Benefits of REST Now that you’ve been convinced of the value of opening your application to the world via web services, and you have seen something of the requirements a RESTful . Professional Practical REST on Rails 2 Projects Practical Ruby Gems Practical Rails Projects www .apress. com SOURCE CODE ONLINE Companion eBook See last page for details on $10 eBook version ISBN-13:. 978-1-59059-994-5 ISBN-10: 1-59059-994 -2 9 781590 599945 5 4 2 9 9 Learn everything you need to know to build open Web 2. 0 applications with Rails Practical REST on Rails 2 Projects Practical