Stefan Alder
2010-Nov-19 10:51 UTC
Help: delegated association ''App'' returning ActionDispatch::Integration::Session instead
class Foo < ActiveRecord::Base has_one :bar delegate :app, :to => :bar end class Bar < ActiveRecord::Base belongs_to :app def self.attribute_column_names return @@attr_columns if defined?(@@attr_columns) readers = content_columns.map { |n| n.name.intern } - [:created_at,:updated_at] @@attr_columns ||= readers.map { |k| [k, "#{k}=".to_sym] }.flatten end end This all worked fine until in the console in my staging and production environments, I assigned bar.app to an undefined variable: Bar.all.each do |p| p.update_attribute("app_id", my_undefined_variable) end After doing this, I get: NameError: undefined local variable or method `my_undefined_variable'' for main:Object and for whatever reason Foo.first.app is now returning an ActionDispatch::Integration::Session object -- not only in the console, but through the web, as well. How can I correct this? -- 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.
Stefan Alder
2010-Nov-19 20:47 UTC
Re: Help: delegated association ''App'' returning ActionDispatch::Integration::Session instead
Update- I think the ActionDispatch::Integration::Session is only returned in console. Seems that console believes I''m calling it''s own ''app'' method even though I''ve delegated it to an association. Is this something worth filing a bug report on? Should I just rename App to something else, however unnatural it may be? On Fri, Nov 19, 2010 at 2:51 AM, Stefan Alder <twigbranch-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> class Foo < ActiveRecord::Base > has_one :bar > delegate :app, :to => :bar > end > > class Bar < ActiveRecord::Base > belongs_to :app > > def self.attribute_column_names > return @@attr_columns if defined?(@@attr_columns) > readers = content_columns.map { |n| n.name.intern } - > [:created_at,:updated_at] > @@attr_columns ||= readers.map { |k| [k, "#{k}=".to_sym] }.flatten > end > end > > > This all worked fine until in the console in my staging and production > environments, I assigned bar.app to an undefined variable: > > Bar.all.each do |p| > p.update_attribute("app_id", my_undefined_variable) > end > > After doing this, I get: > NameError: undefined local variable or method > `my_undefined_variable'' for main:Object > > and > for whatever reason Foo.first.app is now returning an > ActionDispatch::Integration::Session object -- not only in the > console, but through the web, as well. > > How can I correct this? >-- 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.
Possibly Parallel Threads
- Looks like an error in docs for ActionDispatch::Routing::Mapper::Resources
- Should to_io be added to ActionDispatch::Http::UploadedFile?
- Can't use ActionDispatch::Request in Rails middleware because path_parameters get lost
- [PATCH] ActionDispatch MemCacheStore violates encapsulation principle
- Error reverse engineering MySQL with RMRE