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|Last
Lessons:- User Index

As you may recall from the corresponding action in the demo app (Listing 2.4), the application code uses User.all to pull all the users out of the database, assigning them to an @users instance variable for use in the view, as seen in Listing 9.24. (If displaying all the users at once seems like a bad idea, you’re right, and we’ll remove this blemish in Section 9.3.3.)

 

 

To make the actual index page, we need to make a view that iterates through the users and wraps each one in an li tag. We do this with the each method, displaying each user’s Gravatar and name, while wrapping the whole thing in an unordered list (ul) tag (Listing 9.25). The code in Listing 9.25 uses the result of Listing 7.29 from Section 7.6, which allows us to pass an option to the Gravatar helper specifying a size other than the default. If you didn’t do that exercise, update your Users helper file with the contents of Listing 7.29 before proceeding.

 

 

Let’s also add a little CSS (or, rather, SCSS) for style (Listing 9.26).

 

Finally, we’ll add the URI to the users link in the site’s navigation header using users_path, thereby using the last of the unused named routes in Table 7.1. The test (Listing 9.27) and application code (Listing 9.28) are both straightforward.

 
 
 
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)