Browse files

"finished saving pets to repository"

  • Loading branch information...
1 parent fa2dc10 commit 9028021ab5907f28c61c941cc75c035ab457164e @Aaronontheweb committed Feb 18, 2012
Showing with 26 additions and 0 deletions.
  1. +1 −0 app.js
  2. +11 −0 routes/pets.js
  3. +14 −0 views/pets/new.jade
View
1 app.js
@@ -18,6 +18,7 @@ app.configure(function(){
});
app.configure('development', function(){
+ app.set('view options', {pretty:true});
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
View
11 routes/pets.js
@@ -17,5 +17,16 @@ module.exports = function(app){
});
});
+ app.get('/pets/new', function(req, res){
+ res.render('pets/new', {title: 'Adding an awesome pet'});
+ });
+
+ app.post('/pets/new', function(req, res){
+ Pets.save(req.body.pet, function(error, data){
+ if(error) return res.render('dead_pets', {title:"Your pets are dead" + Pets.PetStoreName, error:error});
+ res.redirect('/pets/list');
+ });
+ });
+
/* Catch-alls */
};
View
14 views/pets/new.jade
@@ -0,0 +1,14 @@
+h1= title
+
+form(action="/pets/new",method="post")
+ div
+ label(for="pet[petName]") Pet Name
+ input(type="text", size="30", name = "pet[petName]")
+ div
+ label(for="pet[petType]") Pet Type
+ input(type="text", size="30", name = "pet[petType]")
+ div
+ label(for="pet[petPrice]") Pet Price
+ input(type="text", size="30", name = "pet[petPrice]")
+ div#submitButton.large
+ input(type="submit", value="SAVE THIS AWESOME PET")

0 comments on commit 9028021

Please sign in to comment.