Ruby On Rails Classroom image

Anil  Bist / Professional / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2|
Lessons:- Sample Users

 

This defines a task db:populate that creates an example user with name and email address replicating our previous one, and then makes 99 more. The line

task populate: :environment  do

 

ensures that the Rake task has access to the local Rails environment, including the User model (and hence User.create!). Here create! is just like the create method, except it raises an exception (Section 6.1.4) for an invalid user rather than returning false. This noisier construction makes debugging easier by avoiding silent errors. With the :db namespace as in Listing 9.30, we can invoke the Rake task as follows:  

 

 

After running the Rake task, our application has 100 sample users, as seen in Figure 9.9. (I’ve taken the liberty of associating the first few sample addresses with photos so that they’re not all the default Gravatar image.)

 
 
 
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)