Hello All, Controller code --------- @dates = Q.find(:all, :select => ''year(q.approved_at) as y, month(q.approved_at) as m, day (q.approved_at) as d, count(*) as cnt'', other conditions View code --------- <% y = '''' %> <% for d in @dates if y.to_s != d.y.to_s the new rails 2.2.2 says that "Attempt to call private method ....attribute_methods.rb:236:in `method_missing'' How I should write my code, so I can select not only the Q table fields, but also calculated fields ? Regards, Pavel --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What is the full stack trace? On Nov 24, 10:10 pm, se_pavel <pavel.selez...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello All, > > Controller code > --------- > @dates = Q.find(:all, > :select => ''year(q.approved_at) as y, month(q.approved_at) as m, day > (q.approved_at) as d, count(*) as cnt'', > other conditions > > View code > --------- > <% y = '''' %> > <% for d in @dates > if y.to_s != d.y.to_s > > the new rails 2.2.2 says that > > "Attempt to call private method > > ....attribute_methods.rb:236:in `method_missing'' > > How I should write my code, so I can select not only the Q table > fields, but also calculated fields ? > > Regards, > Pavel--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Is this enough ? 4: <% y = '''' %> 5: <% for d in @dates 6: if y.to_s != d.y.to_s c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/ lib/active_record/attribute_methods.rb:236:in `method_missing'' app/views/public/dates.rhtml:6 app/views/public/dates.rhtml:5:in `each'' app/views/public/dates.rhtml:5 c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/renderable.rb:39:in `send'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/renderable.rb:39:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/template.rb:73:in `render_template'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/base.rb:256:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/base.rb:367:in `_render_with_layout'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_view/base.rb:254:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/base.rb:1174:in `render_for_file'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/base.rb:896:in `render_without_benchmark'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/benchmarking.rb:51:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/core_ext/benchmark.rb:8:in `realtime'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/benchmarking.rb:51:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/base.rb:868:in `render_without_benchmark'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ action_controller/benchmarking.rb:51:in `render'' c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/ lib/active_support/core_ext/benchmark.rb:8:in `real --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
in fact the elements in @dates are not real membes of Q, they even have nil value in id. try to use @dates = ActiveRecord::Base.connection.select_values(" --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 4: <% y = '''' %> > 5: <% for d in @dates > 6: if y.to_s != d.y.to_salso if I rewrite line 6 in the following way it works 6: if y != d[''y''].to_s but it requires to change a lot of code Regards. Pavel --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ActiveRecord::Base.connection.select_all i meant --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> in fact the elements in @dates are not real membes of Q, they even > have nil value in id. > try to use @dates = ActiveRecord::Base.connection.select_values("this function doesn''t support :first, :conditions, :joins and etc params Regards, Pavel --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Nov-24 15:50 UTC
Re: Rails 2.1.2 => 2.2.2 Attempt to call private method
On 24 Nov 2008, at 12:10, se_pavel wrote:> > Hello All, > > Controller code > --------- > @dates = Q.find(:all, > :select => ''year(q.approved_at) as y, month(q.approved_at) as m, day > (q.approved_at) as d, count(*) as cnt'', > other conditions > > View code > --------- > <% y = '''' %> > <% for d in @dates > if y.to_s != d.y.to_s > > the new rails 2.2.2 says that > > "Attempt to call private method > > ....attribute_methods.rb:236:in `method_missing'' >Don''t call it y. There''s already a method on object called y (seems to do yaml dumps). You might be able to get round that with class Q < ActiveRecord::Base undef_method :y # rest of that class here end Fred --~--~---------~--~----~------------~-------~--~----~ 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 For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> Don''t call it y. There''s already a method on object called y (seems to > do yaml dumps). You might be able to get round that with > > class Q < ActiveRecord::Base > undef_method :y > # rest of that class here > endyes, you are right .. I have renamed "y" to "year" and it works Regards, Pavel --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---