Don Schenck
2013-Jan-18 21:44 UTC
Newbie: I just want to exclude two attributes when I call update_attributes
I have two virtual attributes in my model. Let''s call them "hours_worked" and "minutes_worked". I use them to calculate "work_time", which is an integer I store -- it''s the total minutes worked (e.g. 3.5 hours is 210). I want :hours_worked and :minutes_worked to NEVER appear in the database. But when @foo.update_attributes(params[:foo]) is called, it bombs. Any help would be appreciated. Thirty years software development experience and I just can''t seem to pick up Rails. ARGH!!! -- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HS4bF1ZeZZ0J. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Jan-19 09:17 UTC
Re: Newbie: I just want to exclude two attributes when I call update_attributes
On 18 January 2013 21:44, Don Schenck <don.schenck-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have two virtual attributes in my model. Let''s call them "hours_worked" > and "minutes_worked". > > I use them to calculate "work_time", which is an integer I store -- it''s the > total minutes worked (e.g. 3.5 hours is 210). > > I want :hours_worked and :minutes_worked to NEVER appear in the database. > > But when @foo.update_attributes(params[:foo]) is called, it bombs.What do you mean it bombs? Show us what is in params[:foo] and the error you get. Colin -- 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 https://groups.google.com/groups/opt_out.
Don Schenck
2013-Jan-19 15:44 UTC
Re: Newbie: I just want to exclude two attributes when I call update_attributes
Colin -- I ended up using .slice(:field1, :field2, :field4) in my update. Works fine. -- Don On Saturday, January 19, 2013 4:17:26 AM UTC-5, Colin Law wrote:> > On 18 January 2013 21:44, Don Schenck <don.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <javascript:>> > wrote: > > I have two virtual attributes in my model. Let''s call them > "hours_worked" > > and "minutes_worked". > > > > I use them to calculate "work_time", which is an integer I store -- it''s > the > > total minutes worked (e.g. 3.5 hours is 210). > > > > I want :hours_worked and :minutes_worked to NEVER appear in the > database. > > > > But when @foo.update_attributes(params[:foo]) is called, it bombs. > > What do you mean it bombs? Show us what is in params[:foo] and the > error you get. > > Colin >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/HtCX7arX0jQJ. For more options, visit https://groups.google.com/groups/opt_out.
Don Schenck
2013-Jan-20 18:37 UTC
Re: Newbie: I just want to exclude two attributes when I call update_attributes
And in the Create method as well. This FEELS wrong, but it works. On Saturday, January 19, 2013 10:44:21 AM UTC-5, Don Schenck wrote:> > Colin -- > > I ended up using > > > .slice(:field1, :field2, :field4) > > > in my update. Works fine. > > -- Don > > > > On Saturday, January 19, 2013 4:17:26 AM UTC-5, Colin Law wrote: >> >> On 18 January 2013 21:44, Don Schenck <don.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > I have two virtual attributes in my model. Let''s call them >> "hours_worked" >> > and "minutes_worked". >> > >> > I use them to calculate "work_time", which is an integer I store -- >> it''s the >> > total minutes worked (e.g. 3.5 hours is 210). >> > >> > I want :hours_worked and :minutes_worked to NEVER appear in the >> database. >> > >> > But when @foo.update_attributes(params[:foo]) is called, it bombs. >> >> What do you mean it bombs? Show us what is in params[:foo] and the >> error you get. >> >> Colin >> >-- 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 To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/JEc4oPvWtiUJ. For more options, visit https://groups.google.com/groups/opt_out.
Dheeraj Kumar
2013-Jan-20 18:50 UTC
Re: Newbie: I just want to exclude two attributes when I call update_attributes
You still haven''t shown us what''s in params[:foo] and the exact error you get. -- Dheeraj Kumar On Monday 21 January 2013 at 12:07 AM, Don Schenck wrote:> > And in the Create method as well. > > This FEELS wrong, but it works. > > > On Saturday, January 19, 2013 10:44:21 AM UTC-5, Don Schenck wrote: > > Colin -- > > > > I ended up using > > > > > > .slice(:field1, :field2, :field4) > > > > > > in my update. Works fine. > > > > -- Don > > > > > > > > On Saturday, January 19, 2013 4:17:26 AM UTC-5, Colin Law wrote: > > > On 18 January 2013 21:44, Don Schenck <don.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I have two virtual attributes in my model. Let''s call them "hours_worked" > > > > and "minutes_worked". > > > > > > > > I use them to calculate "work_time", which is an integer I store -- it''s the > > > > total minutes worked (e.g. 3.5 hours is 210). > > > > > > > > I want :hours_worked and :minutes_worked to NEVER appear in the database. > > > > > > > > But when @foo.update_attributes(params[:foo]) is called, it bombs. > > > > > > What do you mean it bombs? Show us what is in params[:foo] and the > > > error you get. > > > > > > Colin > -- > 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 (mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org (mailto:rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org). > To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/JEc4oPvWtiUJ. > 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 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 https://groups.google.com/groups/opt_out.
Jim Ruther Nill
2013-Jan-21 00:16 UTC
Re: Newbie: I just want to exclude two attributes when I call update_attributes
On Mon, Jan 21, 2013 at 2:50 AM, Dheeraj Kumar <a.dheeraj.kumar-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> You still haven''t shown us what''s in params[:foo] and the exact error you > get. > > -- > Dheeraj Kumar > > On Monday 21 January 2013 at 12:07 AM, Don Schenck wrote: > > > And in the Create method as well. > > This FEELS wrong, but it works. > > You may want to look at strong_parametershttps://github.com/rails/strong_parameters> > > On Saturday, January 19, 2013 10:44:21 AM UTC-5, Don Schenck wrote: > > Colin -- > > I ended up using > > > .slice(:field1, :field2, :field4) > > > in my update. Works fine. > > -- Don > > > > On Saturday, January 19, 2013 4:17:26 AM UTC-5, Colin Law wrote: > > On 18 January 2013 21:44, Don Schenck <don.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I have two virtual attributes in my model. Let''s call them > "hours_worked" > > and "minutes_worked". > > > > I use them to calculate "work_time", which is an integer I store -- it''s > the > > total minutes worked (e.g. 3.5 hours is 210). > > > > I want :hours_worked and :minutes_worked to NEVER appear in the > database. > > > > But when @foo.update_attributes(params[**:foo]) is called, it bombs. > > What do you mean it bombs? Show us what is in params[:foo] and the > error you get. > > Colin > > -- > 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 > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/JEc4oPvWtiUJ. > 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 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 https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- 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 https://groups.google.com/groups/opt_out.