update query

10 views
Skip to first unread message

Joe Guerra

unread,
Mar 3, 2017, 9:46:04 AM3/3/17
to Ruby on Rails: Talk

I'm not sure why I'm getting this... I'm trying to update a product in the ruby console (and tried it within my app).








Product.update(122, :funded => true)


  Product Load (1.6ms)  SELECT  "products".* FROM "products" WHERE "products"."id" = ? LIMIT 1  [["id", 122]]


   (0.1ms)  SAVEPOINT active_record_1


  Commontator::Thread Load (1.6ms)  SELECT  "commontator_threads".* FROM "commontator_threads" WHERE "commontator_threads"."commontable_id" = ? AND "commontator_threads"."commontable_type" = ? LIMIT 1  [["commontable_id", 122], ["commontable_type", "Product"]]


   (0.1ms)  ROLLBACK TO SAVEPOINT active_record_1


NoMethodError: undefined method `Startdate' for #<Product:0x007f9588a84330>


Did you mean?  startdate


               startdate?


               startdate=


               startdate_was


               startdate_change


               startdate_changed?


               Startdate=


from /Users/joeguerra/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/attribute_methods.rb:433:in `method_missing'


At one point my table for product had a 'Startdate' column, but I ran a migration to change that column to all lowercase.

any ideas?

Rob Biedenharn

unread,
Mar 3, 2017, 9:51:49 AM3/3/17
to rubyonra...@googlegroups.com
On 2017-Mar-3, at 09:46 , Joe Guerra <JGu...@jginfosys.com> wrote:


I'm not sure why I'm getting this... I'm trying to update a product in the ruby console (and tried it within my app).

NoMethodError: undefined method `Startdate' for #<Product:0x007f9588a84330>


Did you mean?  startdate


               startdate?


               startdate=


               startdate_was


               startdate_change


               startdate_changed?


               Startdate=


from /Users/joeguerra/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/activemodel-4.2.5/lib/active_model/attribute_methods.rb:433:in `method_missing'


At one point my table for product had a 'Startdate' column, but I ran a migration to change that column to all lowercase.

any ideas?

Note that "Startdate=" remains as a suggested alternative. I'd start by searching your code for the case-sensetive 'Startdate'

-Rob


Joe Guerra

unread,
Mar 3, 2017, 9:58:26 AM3/3/17
to Ruby on Rails: Talk
If I'm running the command in the console why would it look thru my code?

Colin Law

unread,
Mar 3, 2017, 10:08:02 AM3/3/17
to Ruby on Rails: Talk
On 3 March 2017 at 14:58, Joe Guerra <JGu...@jginfosys.com> wrote:
> If I'm running the command in the console why would it look thru my code?

Because when you type
Product.update(..)
it uses code from your model to know what to do.

Colin
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/0ba41f44-2020-40f2-9918-8a4f976ec973%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Joe Guerra

unread,
Mar 3, 2017, 10:22:39 AM3/3/17
to rubyonra...@googlegroups.com
ok , I found and corrected it in my model and can't locate any other files that might have the wrong syntax.

Is there no way for rails to pinpoint where it's looking when it crash?

> email to rubyonrails-talk+unsubscribe@googlegroups.com.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
--
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@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLsaV4FFHPcOZr5%2B%3D4ZSwibC-p-_PkEUcYRe774KE3Warw%40mail.gmail.com.

Joe Guerra

unread,
Mar 3, 2017, 10:24:22 AM3/3/17
to rubyonra...@googlegroups.com
ok, for some reason now it works?  maybe I needed to restart the console after i made changes to my code.

Walter Lee Davis

unread,
Mar 3, 2017, 10:37:30 AM3/3/17
to rubyonra...@googlegroups.com

> On Mar 3, 2017, at 10:24 AM, Joe Guerra <jgu...@jginfosys.com> wrote:
>
> ok, for some reason now it works? maybe I needed to restart the console after i made changes to my code.

Yes. In development mode, the Web view does the live reload at each request (of most things -- config files in the config/initializers directory often require a full stop and start of the dev server). But the console needs to either have the reload! command issued, or the whole console stopped and started again (the latter is 100%, while the former can fail in difficult-to-diagnose ways).

Walter

>
> On Fri, Mar 3, 2017 at 10:21 AM, Joe Guerra <jgu...@jginfosys.com> wrote:
> ok , I found and corrected it in my model and can't locate any other files that might have the wrong syntax.
>
> Is there no way for rails to pinpoint where it's looking when it crash?
>
> > email to rubyonrails-ta...@googlegroups.com.
> > To post to this group, send email to rubyonra...@googlegroups.com.
> > To view this discussion on the web visit
> > https://groups.google.com/d/msgid/rubyonrails-talk/0ba41f44-2020-40f2-9918-8a4f976ec973%40googlegroups.com.
> >
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> --
> 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-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAOFgAM%3DD5mUst1WUx%3D9hcDZDWJOjfppLT%3DS5k3ZWueckVt9g0A%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages