Prev | Current Page 123 | Next

David Berube

"Practical Reporting with Ruby and Rails"

sql. In the listing, note the use of the DATE_ADD
function to create relative times, rather than hard-coding them, so the times will
always be in the future. Additionally, note the DELETE FROM statements at the beginning of
Listing 5-3. These clear the database before the new data is inserted. For example, this
lets you modify the data and then rerun this SQL script to have a fresh copy of your data.
nTip You can also use migration to insert data, but the advantage of inserting your data in a separate SQL
file is that it keeps the structure and the data separate. If you had two separate deployments, with two separate
databases, you could use the same migrations on both.
You can run the SQL in Listing 5-3 and populate the database using the following
command:
mysql -u my_mysql_username -p actor_schedule_development < actor_schedule_data.sql
Now that your Rails application has been created, your database connection is ready,
and your database structure and data are prepared, you need to create code that accesses
this database.


Pages:
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
pustaki szklane House Extension Kąty Rybackie noclegi kasyno Kołobrzeg