The column already exists with the association, how to add explicitly new one with the same association?

45 views
Skip to first unread message

Tsyren

unread,
Apr 10, 2012, 10:05:39 AM4/10/12
to actives...@googlegroups.com
Hi, everyone.

I need to add one more column to ActiveScaffold via association, but here is problem: the same column already exists with the same association

Env Rails 2.1.1, ActiveScaffold for Rails 2.1

Basical model

class Context < ActiveRecord::Base
  has_many :descendant_associations, :class_name => 'ContextsRelation', :foreign_key => 'ancestor_context_id'
  has_many :descendant_contexts, :through => :descendant_associations, :source => :context, :uniq => true

  named_scope :countries, lambda {|*args| self.options_for_contexts_filter(COUNTRIES_CONTEXT, args.first == :wi ? :country : nil)}
  named_scope :regions, lambda {self.options_for_contexts_filter(REGIONS_CONTEXT)}
end

And AS controller:

class Manage::CountryContextsController < ManageAreaController
  active_scaffold :context do |config|
    config.columns[:descendant_contexts].label = 'Countries'
    config.columns[:descendant_contexts].sort_by :method => "descendant_contexts.cities.sorted.collect{ |v| v.name }.join(', ')"
   
    config.columns[:descendant_contexts].label = 'Regions'
    config.columns[:descendant_contexts].sort_by :method => "descendant_contexts.regions.sorted.collect{ |v| v.name }.join(', ')"
  end
end

How to resolve this issue? I have no idea. For any idea or approaches will be very appreciated.

Hernan Astudillo

unread,
Apr 12, 2012, 4:49:03 PM4/12/12
to actives...@googlegroups.com
wooaaa 2.1 that's old... like atari... :)

that's kinda complex thing, i think AS from that age wasn't able to handle scoping, or even "has_many :through" feature
any chance of upgrading?



--
You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" group.
To view this discussion on the web visit https://groups.google.com/d/msg/activescaffold/-/Lfm6zPpZmMkJ.
To post to this group, send email to actives...@googlegroups.com.
To unsubscribe from this group, send email to activescaffol...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/activescaffold?hl=en.

Tsyren

unread,
Apr 16, 2012, 9:42:15 AM4/16/12
to actives...@googlegroups.com
Hernán, no change

I solved that problem using helper method
To post to this group, send email to activescaffold@googlegroups.com.
To unsubscribe from this group, send email to activescaffold+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages