Ruby On Rails Classroom image

Neeraj  Amoli / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7|Last
Lessons:- Creating Microposts

Having so much code in each branch of the if-else conditional is a bit messy, and cleaning it up using partials is left as an exercise (Section 10.5). Filling in the necessary partials from Listing 10.31 isn’t an exercise, though; we fill in the new Home page sidebar in Listing 10.32 and the micropost form partial in Listing 10.33.

 

 

As in Listing 9.25, the code in Listing 10.32 uses the version of the gravatar_for helper defined in Listing 7.29.

           Note that, as in the profile sidebar (Listing 10.20), the user info in Listing 10.32 displays the total number of microposts for the user. There’s a slight difference in the display, though; in the profilesidebar, ‘‘Microposts’’ is a label, and showing ‘‘Microposts (1)’’ makes sense. In the present case, though, saying ‘‘1 microposts’’ is ungrammatical, so we arrange to display ‘‘1 micropost’’ (but ‘‘2 microposts’’) using pluralize.

         We next define the form for creating microposts (Listing 10.33), which is similar to the signup form in Listing 7.17.

 

We need to make two changes before the form in Listing 10.33 will work. First, we need to define @micropost, which (as before) we do through the association:

@micropost = current user.microposts.build
 
 
 
image
Neeraj  Amoli

Skills    Ruby On Rails

Qualifications :-
Location :-Dehradun,Dehradun,Uttrakhand,India
Description:-

I have 3 year experience as a Software Engineer. My Skilled are Android Development (Java), ROR Development .   


Explore
 

  Students (0)