Hi there, i want to use collection_check_boxes (in rails 4) but i am a little bit stuck... okay, first things first: i have 2 models: ---------------- class Supervisioncategory < ActiveRecord::Base has_many :phonenotes end ---------------- and ---------------- class Phonenote < ActiveRecord::Base belongs_to :employee belongs_to :supervisioncategory belongs_to :trainingcategory end ---------------- and i want to use collection_check_box for the categories ---------------- <div class="field"> <%= f.label :supervision %><br> <%= collection_check_boxes :phonenote, :supervision_ids, @supervisions, :id, :name %> </div> ---------------- shows all the categories i want, i can check them, i made the ":supervision_ids" accessible. But then... nothing happend? I think my problem is at the typ of the ":supervision_ids".. integer won''t work, string won''t work. So... can someone help me with this Problem? Regards, Ronny -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c3dd1d9af2a13ccedd6544f111603dd6%40briefkasten.daishi.de. For more options, visit https://groups.google.com/groups/opt_out.
On Dec 3, 2013, at 12:18 PM, Ronny Fauth wrote:> Hi there, > > i want to use collection_check_boxes (in rails 4) but i am a little bit stuck... okay, first things first: > > i have 2 models: > > ---------------- > class Supervisioncategory < ActiveRecord::Base > has_many :phonenotes > end > ---------------- > > and > > ---------------- > class Phonenote < ActiveRecord::Base > belongs_to :employee > belongs_to :supervisioncategory > belongs_to :trainingcategory > end > ---------------- > > and i want to use collection_check_box for the categories > > ---------------- > <div class="field"> > <%= f.label :supervision %><br> > <%= collection_check_boxes :phonenote, :supervision_ids, @supervisions, :id, :name %> > </div> > ---------------- > > shows all the categories i want, i can check them, i made the ":supervision_ids" accessible. But then... > nothing happend? I think my problem is at the typ of the ":supervision_ids".. integer won''t work, string won''t work. So... can someone help me with this Problem?View source as generated by Rails in your browser, and see what these checkboxes look like in HTML. That''s where I would start debugging this. My guess is that you need these to be supervisioncategory_ids, since that''s what the b/t is saying the model is named. But without looking at the HTML, we won''t know if your checkboxes are properly named to post as an array back to your controller. Walter> > Regards, > > Ronny > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c3dd1d9af2a13ccedd6544f111603dd6%40briefkasten.daishi.de. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/E659A7BE-FBB5-4DE7-8FA9-84118E5B76C1%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.
Am 2013-12-03 18:42, schrieb Walter Lee Davis:> View source as generated by Rails in your browser, and see what these > checkboxes look like in HTML. That''s where I would start debugging > this. My guess is that you need these to be supervisioncategory_ids, > since that''s what the b/t is saying the model is named. But without > looking at the HTML, we won''t know if your checkboxes are properly > named to post as an array back to your controller. > > WalterHere you go: <div class="field"> <label for="phonenote_supervision">Supervision</label><br> <input id="phonenote_supervision_ids_1" name="phonenote[supervision_ids][]" value="1" type="checkbox"> <label for="phonenote_supervision_ids_1">TG</label> <input id="phonenote_supervision_ids_2" name="phonenote[supervision_ids][]" value="2" type="checkbox"> <label for="phonenote_supervision_ids_2">P</label> <input id="phonenote_supervision_ids_3" name="phonenote[supervision_ids][]" value="3" type="checkbox"> <label for="phonenote_supervision_ids_3">Fahrdienst</label> <input name="phonenote[supervision_ids][]" value="" type="hidden"> </div> Regards -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3235dd6002254342d2d0cab22997fa9e%40briefkasten.daishi.de. For more options, visit https://groups.google.com/groups/opt_out.
On Dec 3, 2013, at 12:49 PM, Ronny Fauth wrote:> Am 2013-12-03 18:42, schrieb Walter Lee Davis: > >> View source as generated by Rails in your browser, and see what these >> checkboxes look like in HTML. That''s where I would start debugging >> this. My guess is that you need these to be supervisioncategory_ids, >> since that''s what the b/t is saying the model is named. But without >> looking at the HTML, we won''t know if your checkboxes are properly >> named to post as an array back to your controller. >> Walter > > Here you go: > > <div class="field"> > <label for="phonenote_supervision">Supervision</label><br> > <input id="phonenote_supervision_ids_1" name="phonenote[supervision_ids][]" value="1" type="checkbox"> > <label for="phonenote_supervision_ids_1">TG</label> > <input id="phonenote_supervision_ids_2" name="phonenote[supervision_ids][]" value="2" type="checkbox"> > <label for="phonenote_supervision_ids_2">P</label> > <input id="phonenote_supervision_ids_3" name="phonenote[supervision_ids][]" value="3" type="checkbox"> > <label for="phonenote_supervision_ids_3">Fahrdienst</label> > <input name="phonenote[supervision_ids][]" value="" type="hidden"> > </div> > > RegardsOkay, that looks right, as far as it goes. Now what happens in your console if you find a phonenote, and ask for its supervisions? p = Phonenote.first p.supervisions # error, or array? Walter> > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3235dd6002254342d2d0cab22997fa9e%40briefkasten.daishi.de. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5DA1A8C8-0F99-4256-B3E8-E00E93AA363D%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.
Am 2013-12-03 19:26, schrieb Walter Lee Davis:> Okay, that looks right, as far as it goes. Now what happens in your > console if you find a phonenote, and ask for its supervisions? > > p = Phonenote.first > p.supervisions > > # error, or array? >2.0.0-p353 :002 > p.supervisions NoMethodError: undefined method `supervisions'' for #<Phonenote:0xb042698> Ronny -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d6cf0c49ddc480477f5dbc635d9e37b2%40briefkasten.daishi.de. For more options, visit https://groups.google.com/groups/opt_out.
Am 2013-12-03 19:46, schrieb Ronny Fauth:> Am 2013-12-03 19:26, schrieb Walter Lee Davis: > >> Okay, that looks right, as far as it goes. Now what happens in your >> console if you find a phonenote, and ask for its supervisions? >> >> p = Phonenote.first >> p.supervisions >> >> # error, or array? >> > > 2.0.0-p353 :002 > p.supervisions > NoMethodError: undefined method `supervisions'' for > #<Phonenote:0xb042698> > > Ronny2.0.0-p353 :002 > p.supervisions NoMethodError: undefined method `supervisions'' for #<Phonenote:0xb042698> 2.0.0-p353 :003 > p.supervisioncategories NoMethodError: undefined method `supervisioncategories'' for #<Phonenote:0xb042698> 2.0.0-p353 :004 > p.supervisioncategory_id => nil 2.0.0-p353 :005 > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0df05323119ec7bd9fe1442aa1da2703%40briefkasten.daishi.de. For more options, visit https://groups.google.com/groups/opt_out.