You are on page 1of 2

Piogiamming Assignment 2

Foi this assignment stuuents will be auuing an association anu valiuations to the
blog that they staiteu in the pievious assignment.

Foi help anu moie in-uepth instiuctions on this assignment, please iefei to the
Nouule S Lectuies 4 anu S viueos.

This coiiesponus to iteiations 2 anu S of the blog app in the lectuie viueos.
Please make suie to use the same names useu in the viueos foi all Rails vaiiables,
classes, etc.. The giauing scheme uepenus on you following the exact instiuctions
pioviueu in the viueos.

1. Post "has many" Comments association

Cieate a "has many" ielationship foi posts to comments. The pievious
assignment alieauy maue suie the post_iu was pait of the comments table.
Foi this pait, you simply neeu to auu the necessaiy ielationships to the post
anu comment mouels. Be suie to auu a uestioy uepenuency to the comments
ielationship in the posts mouel (this makes suie that the comments
associateu with a post will get uestioyeu whenevei a post is uestioyeu).

Then open up the iails console (iails c) to test this association. Beie is the
console input to test the association.
iails c
>> c = Comment.new()
>> p= Post.new()
>> p.comments << c
>> puts p.comments


2. Cieate nesteu iesouice

Cieate a nesteu iesouice foi comments within posts in the ioutes file.

In the commanu line, iun iake ioutes to test anu view youi new nesteu
iesouices.

S. Auu valiuations

Please auu the following uatabase valiuations to youi blog application:

valiuate piesence of the Post's title
valiuate piesence of the Post's bouy
valiuate piesence of the Comment's post_iu
valiuate piesence of the Comment's bouy

4. Test anu Push

Test the functionality of youi app.

When you aie satisfieu with the app, push it up to youi Bitbucket account
unuei a public iepositoiy. Finally, follow the instiuctions on the assignment
page to submit youi Bitbucket 0RL to the automateu giauei queue.

You might also like