Skip to content

beyond2013/many2many

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

many2many

A working example of has_and_belongs_to_many association in Rails 4

This example has two models Student and Project associated using has_and_belongs_to_many.

  1. launch the rails app and go to http://localhost:3000/students/new for adding students
  2. Navigate to http://localhost:3000/projects/new for adding new projects and assign existing students to the project
Views for editing and displaying the projects also functional

Added Devise gem

This example now has user authentication feature using Devise gem.
The root of the app now points to the signup page. The operations of New, Edit, and Destroy for Student and Project resource are only available after signing in. Index, and Show work without signing in.

Testing rails app

The example has been extended to include testing, starting with unit test
test/models/student_test.rb contains a test "test_without_name" run the test by executing rake test test_without_name in console the test will fail if the validation line validates :name, presence: true in app/models/student.rb has been commented. The test will pass if comment symbol # is removed in the model.

About

A working example of many to many relationship in Rails 4

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors