gamov
2010-Sep-08 05:57 UTC
Adding a selected checkbox to a new nested model without polluting the model
Context: I have a GoodsReturn model with many ReturnedItem. For the new view, I create a new GoodsReturn with many new ReturnedItems from a sale (and its SoldItems). Problem: I want to have a Add/Selected checkbox with which the user can pick the items he wants to return. I know I could use a ''selected'' virtual attribute but I don''t want to pollute my model just for this. In fact, there is something that does exactly the opposite that I want, the :_destroy: <%= i_f.check_box :_destroy %> I would like exactly the opposite, :_select. Anybody has figured this out before? Thanks guys, Gam -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2010-Sep-08 15:07 UTC
Re: Adding a selected checkbox to a new nested model without polluting the model
sure is simple, i will tell you what i think you are trying to say and you can confirm it, you have a list of items, and you want the user to be able to make a selection and remove them with checkboxes? is that it? On Wed, Sep 8, 2010 at 1:57 AM, gamov <gamaudruz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Context: > I have a GoodsReturn model with many ReturnedItem. For the new view, I > create a new GoodsReturn with many new ReturnedItems from a sale (and > its SoldItems). > Problem: > I want to have a Add/Selected checkbox with which the user can pick > the items he wants to return. I know I could use a ''selected'' virtual > attribute but I don''t want to pollute my model just for this. In fact, > there is something that does exactly the opposite that I want, > the :_destroy: > <%= i_f.check_box :_destroy %> > I would like exactly the opposite, :_select. > > Anybody has figured this out before? > > Thanks guys, > Gam > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
gamov
2010-Sep-09 04:38 UTC
Re: Adding a selected checkbox to a new nested model without polluting the model
Cool, radhames brito. I have a list of items (all are new_record? = true) that are nested into another new record. I want the user to make a selection and ADD them with checkboxes, not remove. Those without checkboxes will just be discarded and never created. On Sep 8, 11:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> sure is simple, i will tell you what i think you are trying to say and you > can confirm it, > you have a list of items, and you want the user to be able to make a > selection and remove them with checkboxes? > is that it?-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2010-Sep-09 11:07 UTC
Re: Re: Adding a selected checkbox to a new nested model without polluting the model
i think i saw something similar here http://railscasts.com/episodes/196-nested-model-form-part-1 http://railscasts.com/episodes/197-nested-model-form-part-2 it has ajax and eveything On Thu, Sep 9, 2010 at 12:38 AM, gamov <gamaudruz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Cool, radhames brito. > > I have a list of items (all are new_record? = true) that are nested > into another new record. I want the user to make a selection and ADD > them with checkboxes, not remove. Those without checkboxes will just > be discarded and never created. > > On Sep 8, 11:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > sure is simple, i will tell you what i think you are trying to say and > you > > can confirm it, > > you have a list of items, and you want the user to be able to make a > > selection and remove them with checkboxes? > > is that it? > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
gamov
2010-Sep-15 07:19 UTC
Re: Adding a selected checkbox to a new nested model without polluting the model
Yeah, it''s quite similar, but the example uses the _destroy facility, I want the opposite... Anyway, I''m using a virtual attribute in the meantime... On Sep 9, 7:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> i think i saw something similar here > > http://railscasts.com/episodes/196-nested-model-form-part-1 > > http://railscasts.com/episodes/197-nested-model-form-part-2 > > it has ajax and eveything > > On Thu, Sep 9, 2010 at 12:38 AM, gamov <gamaud...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Cool, radhames brito. > > > I have a list of items (all are new_record? = true) that are nested > > into another new record. I want the user to make a selection and ADD > > them with checkboxes, not remove. Those without checkboxes will just > > be discarded and never created. > > > On Sep 8, 11:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > sure is simple, i will tell you what i think you are trying to say and > > you > > > can confirm it, > > > you have a list of items, and you want the user to be able to make a > > > selection and remove them with checkboxes? > > > is that it? > > > -- > > You received this message because you are subscribed to the Google Groups > > "Ruby on Rails: Talk" group. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
radhames brito
2010-Sep-15 12:05 UTC
Re: Re: Adding a selected checkbox to a new nested model without polluting the model
oh i see, you can handle the way the hash is passed so that you can loop true the params and check for the selected one, then only save the selected ones , i did something similar. You can handle the hash by adding [] to the field names in the for helper. for example addin :value[whatever][] associates the items and puts then in an array in the params hash On Wed, Sep 15, 2010 at 3:19 AM, gamov <gamaudruz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Yeah, it''s quite similar, but the example uses the _destroy facility, > I want the opposite... > Anyway, I''m using a virtual attribute in the meantime... > > On Sep 9, 7:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > i think i saw something similar here > > > > http://railscasts.com/episodes/196-nested-model-form-part-1 > > > > http://railscasts.com/episodes/197-nested-model-form-part-2 > > > > it has ajax and eveything > > > > On Thu, Sep 9, 2010 at 12:38 AM, gamov <gamaud...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Cool, radhames brito. > > > > > I have a list of items (all are new_record? = true) that are nested > > > into another new record. I want the user to make a selection and ADD > > > them with checkboxes, not remove. Those without checkboxes will just > > > be discarded and never created. > > > > > On Sep 8, 11:07 pm, radhames brito <rbri...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > sure is simple, i will tell you what i think you are trying to say > and > > > you > > > > can confirm it, > > > > you have a list of items, and you want the user to be able to make a > > > > selection and remove them with checkboxes? > > > > is that it? > > > > > -- > > > You received this message because you are subscribed to the Google > Groups > > > "Ruby on Rails: Talk" group. > > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > <rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%252Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Reasonably Related Threads
- Working in install acts_as_commentable, On create, error: "unknown attribute: book_id"
- Paperclip not executing FFMPEG properly
- How to transform my html form into a rails 3 form
- Rails 3 - Creating a comment and then returning the Partial with JUST the new comment
- Multi-model forms