Using Ruby on Rails Create a cookbook application like the one in Rolling with Ruby on Rails. 1. rails cookbook Creates a framework for the application in a cookbook folder. 2. cd cookbook 3. mysqld --console Starts the mysql database server, if necessary. 4. mysql -u root 5. In mysql, create database cook; 6. In cookbook\config, edit database.yml by changing the database name three times to "cook". 7. ruby script/server or ruby script/server webrick depending upon which version of Rails is used Starts the WEBrick server on port 3000. 8. To create the recipes table (See 8a for an alternate approach) a. Save the following file as create.sql in cookbook\db drop table if exists recipes; create table recipes ( id int not null auto_increment, title varchar(255) not null, description varchar(255)not null, date datetime not null, instructions text, primary key(id) ); b. In mysql execute use cook; and then source c:/cookbook/db/create.sql; Make sure to include the full path to create.sql on your system. 8a. Another way to create the recipes table. Execute ruby script/generate migration recipes which will produce a skeleton .rb file in the db\migrate folder. Add to the skeleton so the methods read def self.up create_table :recipes do |table| table.column :title, :string, :null => false table.column :description, :string, :null => false table.column :date, :datetime, :null => false table.column :instructions, :text end end def self.down drop_table :recipes end Execute rake migrate 9. To create the scaffolding for the controller and the model, execute ruby script/generate scaffold recipe recipe This will also create the views. 10. http://localhost:3000/recipe/new will get you started Some mysql commands create database cook; (where "cook" is the name of the database.) show databases; use cook; (where "cook" is one of the databases.) show tables; describe recipes; (where "recipes" is one of the tables.) drop table recipes; drop database cook; To modify to search for certain recipes you might 1. Add a search action to the recipe contoller def search @recipe_pages, @recipes = paginate :recipes, :per_page => 10 @recipes.delete_if{|t| ! (t.title =~ /#{params[:name]}/)} render :action => 'list' end 2. Add a search form to list.rhtml <%= start_form_tag :action => 'search' %> <%= text_field 'name', '' %> <%= submit_tag 'Search' %> <%= end_form_tag %> use http://localhost:3000/recipe/search