Ruby On Rails Classroom image

Neha  Jaggi / 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
Neha  Jaggi

Skills    Ruby On Rails

Qualifications :- High School - , College/University - Graphic Era Hill University, Dehradun, College/University - ,
Location :-Dehradun,Dehradun,UTTARAKHAND,India
Description:-

Experienced Software Developer with a demonstrated history of working in the Information Technology and services industry. Skilled in Web Technologies (Ruby on Rails, PostgreSQL, php, Laravel and AJAX). 


Explore
 

  Students (0)