From 606a507fff5fc179764b8a0f5d26bc33334ebd86 Mon Sep 17 00:00:00 2001 From: José Mota Date: Mon, 22 Oct 2012 12:20:29 +0100 Subject: Remove UFZvalidator post and convert other two to markdown. --- ...-11-05-rails-3-has_many-through-checkboxes.html | 30 ---------------------- 1 file changed, 30 deletions(-) delete mode 100644 _posts/2010-11-05-rails-3-has_many-through-checkboxes.html (limited to '_posts/2010-11-05-rails-3-has_many-through-checkboxes.html') diff --git a/_posts/2010-11-05-rails-3-has_many-through-checkboxes.html b/_posts/2010-11-05-rails-3-has_many-through-checkboxes.html deleted file mode 100644 index 84838a2..0000000 --- a/_posts/2010-11-05-rails-3-has_many-through-checkboxes.html +++ /dev/null @@ -1,30 +0,0 @@ ---- -layout: post -title: Rails 3 has_many :through checkboxes -tags: -- Development -status: publish -type: post -published: true -meta: - _edit_last: '1' - _wp_old_slug: '' ---- -On Twitter I wrote: -
Rails does it for you, just add sheet_ids[] to the form with the checkboxes and it's done! will blog.
-Being a music teacher, my fiance needed to keep record of tests her students perform. Also, each test has several sheets that need mentoring and monitorization through several parameters. I decided to help and reentered the Rails world, and since I have found no answer on this topic, I decided to write it myself. - -This situation is a perfect model for using the so well known HABTM checkboxes. - - -

A closer look at the problem

-

Models

-[gist id=663287] - -A pretty basic setup. The venues (the students' tests) include several sheets for them to study and for the teacher to evaluate, through exhibitions that have several criteria. -

View

-[gist id=663417] - -I simplified the form just so you see what's at stake. The same principle of the HABTM checkboxes applies to a has_many :through association. Instead of new entries in a venues_sheets table, new Exhibitions are created with the respective foreign ids in them. - -The controller needs no mention because it stays the same. It just saves / updates the model. This is why I love Rails: the hard work is done: you just need to focus on what matters. -- cgit v1.2.3-54-g00ecf