Recipe 13.1. Serializing Data with YAML
Problem
You want to serialize a data structure and use it later. You may want to send the data structure to a file, then load it into a program written in a different programming language.
Solut...
Recipe 13.2. Serializing Data with Marshal
Problem
You want to serialize a data structure to disk faster than YAML can do it. You don't care about the readability of the serialized data structure, or portability to other programming langua...
Recipe 13.3. Persisting Objects with Madeleine
Problem
You want to store objects in RAM and persist them between independent executions of the program. This will let your program recall its state indefinitely and access it very quickly.
...
Recipe 13.4. Indexing Unstructured Text with SimpleSearch
Problem
You want to index a number of texts and do quick keyword searches on them.
Solution
Use the
SimpleSearch library, available in the SimpleSearch gem.
Here's how to ...
Recipe 13.5. Indexing Structured Text with Ferret
Problem
You want to perform searches on structured text. For instance, you might want to search just the headline of a news story, or just the body.
Discussion
The Ferret library can ...
Recipe 13.6. Using Berkeley DB Databases
Problem
You want a simple, fast database that doesn't need a server to run.
Solution
Ruby's standard dbm library lets you store a database in a set of standalone binary files. It's not a SQL d...
Recipe 13.7. Controlling MySQL on Unix
Problem
The standard Ruby database interfaces assume you're connecting to a preexisting database, and that you already have access to this database. You want to create and administer
MySQL database...
Recipe 13.8. Finding the Number of Rows Returned by a Query
Problem
Writing a DBI program, you want an efficient way to see how many rows were returned by a query.
Solution
A do command returns the number of rows affected by the comm...
Recipe 13.9. Talking Directly to a MySQL Database
Problem
You want to send SQL queries and commands directly to a MySQL database.
Solution
Do you really need to do this? Almost all the time, it's better to use the generic DBI library...
Recipe 13.10. Talking Directly to a PostgreSQL Database
Problem
You want to send SQL queries and commands directly to a
PostgreSQL database.
Solution
As with the MySQL recipe preceding this one, ask: do you really need to do this?...
Recipe 13.11. Using Object Relational Mapping with ActiveRecord
Problem
You want to store data in a database without having to use SQL to access it.
Solution
Use the ActiveRecord library, available as the activerecord gem. It automat...
Recipe 13.12. Using Object Relational Mapping with Og
Credit: Mauro Cicio
Problem
You want to store data in a database, without having to use SQL to create or access the database.
Solution
Use the Og (ObjectGraph) library, available...
Recipe 13.13. Building Queries Programmatically
Problem
You have to write fragments of SQL to pass parameters into an ActiveRecord query. You'd like to dispense with SQL altogether, and represent the query paramaters as a Ruby data structu...
Recipe 13.14. Validating Data with ActiveRecord
Problem
You want to prevent bad data from getting into your ActiveRecord data objects, whether the source of the data is clueless users or buggy code.
Solution
The simplest way is to us...
Recipe 13.15. Preventing SQL Injection Attacks
Problem
You want to harden your code against SQL injection attacks, whether in DBI or ActiveRecord code.
Solution
With both ActiveRecord and DBI applications, you should create your SQL ...
Recipe 13.16. Using Transactions in ActiveRecord
Problem
You want to perform database operations as a group: if one of the operations fails, it should be as though none of them had ever happened.
Solution
Include active_record/
tra...
Recipe 13.17. Adding Hooks to Table Events
Problem
You want to run some code whenever a database row is added, updated, or deleted. For instance, you might want to send out email whenever a new blog post is created.
Solution
For Og, ...
AJAX popular information C# language guides Windows books and cookbooks
.......
С 2009 года мы стали переводить структура сайта на различные языки. Сайт теперь будет содержать книги не только на английском языке, но также и на других европейских языках, в том числе и на Русском языке.