Ruby On Rails Classroom image

Anil  Bist / 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
Anil  Bist

Skills    Ruby On Rails

Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,
Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-

I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore

 

  Students (0)