Ruby On Rails Classroom image

Anil  Bist / Professional / Web Technology

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

(As with Listing 11.4, the test for dependent :destroy is left as an exercise [Section 11.5].) Note that we actually have to include the class name for this association, i.e.,

 

because otherwise Rails would look for a ReverseRelationship class, which doesn’t exist. It’s also worth noting that we could actually omit the :source key in this case, using simply

has many :followers, through: :reverse relationships

 

since, in the case of a :followers attribute, Rails will singularize ‘‘followers’’ and automatically look for the foreign key follower_id in this case. I’ve kept the :source key to emphasizethe parallel structure with the has_many :followed_users association, but you are free to leave it off.

       With the code in Listing 11.16, the following/follower associations are complete, and all the tests should pass:  

$  bundle exec rspec spec/

 

This section has placed rather heavy demands on your data modeling skills, and it’s fine if it takes a while to soak in. In fact, one of the best ways to understand the associations is to use them in the web interface, as seen in the next section.  

 
 
 
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)