maciej.mietek-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org
2013-Mar-28 13:07 UTC
NoMethodError (undefined method `length='' for #<Tour:0x000000081583f0>):
Hey I have a problem with nomethoderror and have no idea how to solve it. In logs: NoMethodError (undefined method `length='' for #<Book:0x000000081583f0>): 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:13:in `block in find_or_create_by_guide'' 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:9:in `find_or_create_by_guide'' 2013-03-28T12:38:35+00:00 app[web.2]: app/controllers/guide_controller.rb:37:in `find_or_create_book_based_on_guide'' cache: [GET /en/books/planner/preview] miss 2013-03-28T12:38:35+00:00 app[web.2]: Processing by BooksController#preview as */* 2013-03-28T12:38:35+00:00 app[web.2]: Parameters: {"locale"=>"en", "id"=>"planner"} 2013-03-28T12:38:35+00:00 app[web.2]: Unknown label ''www''. Switching label to bookless 2013-03-28T12:38:35+00:00 app[web.2]: Finded book #515439c0e622d90002000019 2013-03-28T12:38:35+00:00 app[web.2]: Completed 500 Internal Server Error in 82ms Book.rb: module ClassMethods def find_or_create_by_guide(guide) book = ::Book.find_or_create_by_document(guide.id.to_s) do |t| t.city_id = guide.city t.host = guide.host t.pace = guide.pace || :normal t.length = guide.length end Later in Book.rb, I have: groups = sorted_points.in_groups_of(length, false) In Book.rb I have attr_accessible :length. I''ve also updated the table with length column: class AddLengthColumnToBooks < ActiveRecord::Migration def change add_column :books, :length, :integer end end I have no idea what''s going on. Can someone please help me with this? -- 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/msg/rubyonrails-talk/-/ANkbPwZDL-MJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Mar-28 15:52 UTC
Re: NoMethodError (undefined method `length='' for #<Tour:0x000000081583f0>):
On 28 March 2013 13:07, <maciej.mietek-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org> wrote:> Hey > > I have a problem with nomethoderror and have no idea how to solve it. > > In logs: > > NoMethodError (undefined method `length='' for #<Book:0x000000081583f0>): > 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:13:in > `block in find_or_create_by_guide'' > 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:9:in > `find_or_create_by_guide'' > 2013-03-28T12:38:35+00:00 app[web.2]: > app/controllers/guide_controller.rb:37:in > `find_or_create_book_based_on_guide'' > > cache: [GET /en/books/planner/preview] miss > 2013-03-28T12:38:35+00:00 app[web.2]: Processing by BooksController#preview > as */* > 2013-03-28T12:38:35+00:00 app[web.2]: Parameters: {"locale"=>"en", > "id"=>"planner"} > 2013-03-28T12:38:35+00:00 app[web.2]: Unknown label ''www''. Switching label > to bookless > 2013-03-28T12:38:35+00:00 app[web.2]: Finded book #515439c0e622d90002000019 > 2013-03-28T12:38:35+00:00 app[web.2]: Completed 500 Internal Server Error in > 82ms > > Book.rb: > module ClassMethods > def find_or_create_by_guide(guide) > book = ::Book.find_or_create_by_document(guide.id.to_s) do |t| > t.city_id = guide.city > t.host = guide.host > t.pace = guide.pace || :normal > t.length = guide.length > end > Later in Book.rb, I have: > > groups = sorted_points.in_groups_of(length, false) > > > In Book.rb I have attr_accessible :length. I''ve also updated the table with > length column: > class AddLengthColumnToBooks < ActiveRecord::Migration > def change > add_column :books, :length, :integer > end > end > > I have no idea what''s going on. Can someone please help me with this?The error refers to book.rb but you refer to Book.rb. Is that just a typing error? What happens if, in the Rails Console you do Book.first.length I presume you have run the migration. Have you checked using a database tool that the column exists? I wonder whether length is a reserved word. If all else fails try a different name. 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
maciej.mietek-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org
2013-Mar-29 09:57 UTC
Re: NoMethodError (undefined method `length='' for #<Tour:0x000000081583f0>):
Hey, thanks for the answer. As for the Book.rb - yes, it''s a typing error. When I run Book.first.length in the rails console, I get: 1.9.3-p327 :001 > Book.first.length Book Load (0.2ms) SELECT "books".* FROM "books" WHERE "books"."label" = ''app LIMIT 1 => nil And yes, I did run the migration. I think the problem can lie in Mongo collections. I''ve added the "length" collection by updating an already working Mongo Document. Maybe that''s the problem? I''ll try to set up another mongo document with the length collection only. class Guide::Document include MongoMapper::Document key :city, Integer key :trips, Array key :themes, Array key :places, Array key :pace, String key :date_from, Time key :date_to, Time key :host, String * key :length, Integer* timestamps! end W dniu czwartek, 28 marca 2013 16:52:13 UTC+1 użytkownik Colin Law napisał:> > On 28 March 2013 13:07, <maciej...-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org <javascript:>> wrote: > > Hey > > > > I have a problem with nomethoderror and have no idea how to solve it. > > > > In logs: > > > > NoMethodError (undefined method `length='' for #<Book:0x000000081583f0>): > > 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:13:in > > `block in find_or_create_by_guide'' > > 2013-03-28T12:38:35+00:00 app[web.2]: app/models/engine/book.rb:9:in > > `find_or_create_by_guide'' > > 2013-03-28T12:38:35+00:00 app[web.2]: > > app/controllers/guide_controller.rb:37:in > > `find_or_create_book_based_on_guide'' > > > > cache: [GET /en/books/planner/preview] miss > > 2013-03-28T12:38:35+00:00 app[web.2]: Processing by > BooksController#preview > > as */* > > 2013-03-28T12:38:35+00:00 app[web.2]: Parameters: {"locale"=>"en", > > "id"=>"planner"} > > 2013-03-28T12:38:35+00:00 app[web.2]: Unknown label ''www''. Switching > label > > to bookless > > 2013-03-28T12:38:35+00:00 app[web.2]: Finded book > #515439c0e622d90002000019 > > 2013-03-28T12:38:35+00:00 app[web.2]: Completed 500 Internal Server > Error in > > 82ms > > > > Book.rb: > > module ClassMethods > > def find_or_create_by_guide(guide) > > book = ::Book.find_or_create_by_document(guide.id.to_s) do |t| > > t.city_id = guide.city > > t.host = guide.host > > t.pace = guide.pace || :normal > > t.length = guide.length > > end > > Later in Book.rb, I have: > > > > groups = sorted_points.in_groups_of(length, false) > > > > > > In Book.rb I have attr_accessible :length. I''ve also updated the table > with > > length column: > > class AddLengthColumnToBooks < ActiveRecord::Migration > > def change > > add_column :books, :length, :integer > > end > > end > > > > I have no idea what''s going on. Can someone please help me with this? > > The error refers to book.rb but you refer to Book.rb. Is that just a > typing error? > > What happens if, in the Rails Console you do > Book.first.length > > I presume you have run the migration. Have you checked using a > database tool that the column exists? > > I wonder whether length is a reserved word. If all else fails try a > different name. > > 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-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/msg/rubyonrails-talk/-/3KVs8mswjlkJ. For more options, visit https://groups.google.com/groups/opt_out.
Colin Law
2013-Mar-29 10:48 UTC
Re: NoMethodError (undefined method `length='' for #<Tour:0x000000081583f0>):
On 29 March 2013 09:57, <maciej.mietek-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org> wrote:> Hey, thanks for the answer. > > As for the Book.rb - yes, it''s a typing error. > > When I run Book.first.length in the rails console, I get: > > 1.9.3-p327 :001 > Book.first.length > Book Load (0.2ms) SELECT "books".* FROM "books" WHERE "books"."label" > ''app LIMIT 1Why does that include a WHERE clause? and why is it looking for label = ''app 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-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
maciej.mietek-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org
2013-Mar-29 11:44 UTC
Re: NoMethodError (undefined method `length='' for #<Tour:0x000000081583f0>):
This is because we have a whitelabel feature in our app, and therefore most columns and tables are labelled to. The label "app" simply means that it loads all the data from our main app. W dniu piątek, 29 marca 2013 11:48:56 UTC+1 użytkownik Colin Law napisał:> > On 29 March 2013 09:57, <maciej...-sGMOnOof0sKrDJvtcaxF/A@public.gmane.org <javascript:>> wrote: > > Hey, thanks for the answer. > > > > As for the Book.rb - yes, it''s a typing error. > > > > When I run Book.first.length in the rails console, I get: > > > > 1.9.3-p327 :001 > Book.first.length > > Book Load (0.2ms) SELECT "books".* FROM "books" WHERE "books"."label" > = > > ''app LIMIT 1 > > Why does that include a WHERE clause? and why is it looking for label = > ''app > > 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-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/msg/rubyonrails-talk/-/-3oavuhx0VcJ. For more options, visit https://groups.google.com/groups/opt_out.