On Domingo, 30 de Enero de 2011 02:17:59 jerry escribió:
> > > AND Finally view generated output has incorrect controller referenced
> > > (/admin/detail_weeding_lawn/edit/1)  for "formulation" and "contains"
> > > but correct for "fungi" --
> 
> I don't have a clue how this detail_weeding_lawn controller is showing
> up in the middle of AS generated view as shown.
> 
> Any steps to resolve are appreciated on this view generation problem.

Do you have another helper override for formulation column in other 
controller? Do you have helper :all in your application controller? In that 
case, comment that line because you are using all helpers in all controllers, 
so only last formulation override is used.

> 
> Thanks
> jerry
> 
> On Jan 28, 12:56 am, "Sergio Cambra .:: entreCables S.L. ::."
> 
> <[email protected]> wrote:
> > On Viernes, 28 de Enero de 2011 05:13:47 Michael Latta escribió:
> > > The helper methods need to be *_form_column and take 2 arguments:
> > > record, options.
> > > 
> > > If you have a later version the class name is a prefix according to the
> > > documentation, but I have not seen tat as I am using the rails 3
> > > branch.
> > 
> > That's in master branch, but old syntax (without prefix) is supported
> > (with a deprecation warning).
> > 
> > I think you could get links with set_link method in the controller too.
> > Posted model mustn't be full, there is no formulation association or
> > method. Does it exist some formulation association? Then try to call
> > clear_link
> > 
> > Why do you get admin/detail_weeding_select? Are you loading that
> > controller? Admin::DetailFungicideController configuration won't be used
> > when you load another controller, helper only will be used if you have
> > helper :all in application controller.
> > 
> > > Michael
> > > 
> > > On Jan 26, 2011, at 11:47 PM, jerry wrote:
> > > > Appreciate any help on following with rails 2.3.4 and AS.
> > > > 
> > > > Here is model --
> > > > 
> > > > class DetailFungicide < ActiveRecord::Base
> > > > 
> > > >  has_one :product, :as => :detail
> > > >  has_many :df_whens, :order => :position, :dependent => :destroy
> > > >  has_many :df_hows, :order => :position, :dependent => :destroy
> > > >  has_many :df_whats, :order => :position, :dependent => :destroy
> > > >  has_many :df_benefits, :order => :position, :dependent => :destroy
> > > >  has_many :fungicide_ingredients, :as
> > > > 
> > > > => :detail_fungicide, :dependent => :destroy
> > > > 
> > > >  has_many :affected_fungus, :as => :detail_fungicide, :dependent
> > > > 
> > > > => :destroy
> > > > 
> > > >  def product_name
> > > > 
> > > >    self.product.name
> > > > 
> > > >  end
> > > > 
> > > >  def contains
> > > > 
> > > >    if self.fungicide_ingredients.empty?
> > > > 
> > > >      "Contains"
> > > > 
> > > >    else
> > > > 
> > > >      fungicide_ingredients.collect { |fi|
> > > > 
> > > >        [(fi.base_chemical.common_name.nil? ?
> > > > 
> > > > fi.base_chemical.chemical_name :
> > > > fi.base_chemical.common_name ) ]}.uniq.join "; "
> > > > 
> > > >    end
> > > > 
> > > >  end
> > > > 
> > > >  def fungi
> > > > 
> > > >    if self.affected_fungus.empty?
> > > > 
> > > >      "Fungus"
> > > > 
> > > >    else
> > > > 
> > > >      affected_fungus.collect { |af| [af.base_fungus.name]}.join "; "
> > > > 
> > > >    end
> > > > 
> > > >  end
> > > > 
> > > >  def when_count
> > > > 
> > > >    self.df_whens.count
> > > > 
> > > >  end
> > > > 
> > > >  def how_count
> > > > 
> > > >    self.df_hows.count
> > > > 
> > > >  end
> > > > 
> > > >  def what_count
> > > > 
> > > >    self.df_whats.count
> > > > 
> > > >  end
> > > > 
> > > >  def benefit_count
> > > > 
> > > >    self.df_benefits.count
> > > > 
> > > >  end
> > > > 
> > > >  def to_label
> > > > 
> > > >    "#{self.product.name}"
> > > > 
> > > >  end
> > > > 
> > > > end
> > > > 
> > > > Here is controller --
> > > > 
> > > > class Admin::DetailFungicideController < Admin::AdminController
> > > > 
> > > >  active_scaffold :detail_fungicide do |config|
> > > > 
> > > >    config.label = "Product Details"
> > > > 
> > > >    # virtual columns for visibility to count stats.
> > > >    config.columns =
> > > > 
> > > > [:product_name, :formulation, :contains, :fungi, :when_count,
> > > > :how_count,
> > > > 
> > > > :what_count,  :benefit_count]
> > > > 
> > > >    config.columns[:when_count].label = "When #"
> > > >    config.columns[:how_count].label = "How #"
> > > >    config.columns[:what_count].label = "What #"
> > > >    config.columns[:benefit_count].label = "Benefit #"
> > > > 
> > > >    config.list.columns =
> > > > 
> > > > [ :product_name, :formulation, :contains, :fungi, :when_count,
> > > > 
> > > > :how_count, :what_count,  :benefit_count]
> > > > 
> > > >    config.columns[:contains].label = "Contains"
> > > > 
> > > >    # allow separate edit on each count attribute ...
> > > >    columns[:when_count].set_link 'nested', :parameters =>
> > > > 
> > > > {:associations => :df_whens}
> > > > 
> > > >    columns[:how_count].set_link 'nested', :parameters =>
> > > > 
> > > > {:associations => :df_hows}
> > > > 
> > > >    columns[:what_count].set_link 'nested', :parameters =>
> > > > 
> > > > {:associations => :df_whats}
> > > > 
> > > >    columns[:benefit_count].set_link 'nested', :parameters =>
> > > > 
> > > > {:associations => :df_benefits}
> > > > 
> > > >    # ... also allow all count attribute edit at once
> > > >    config.nested.add_link("Product Details",
> > > > 
> > > > [:df_whens, :df_hows, :df_whats, :df_benefits])
> > > > 
> > > >    # no simple attributes to work with
> > > >    config.actions.exclude :show
> > > >    config.actions.exclude :create
> > > >    config.actions.exclude :delete
> > > > 
> > > >    # don't want the explicit Edit button
> > > >    config.update.link.label = ""
> > > > 
> > > >    config.update.columns.exclude
> > > > 
> > > > [:product_name, :contains, :fungi, :when_count, :how_count,
> > > > :what_count,
> > > > 
> > > > :benefit_count]
> > > > 
> > > >  end
> > > > 
> > > >  # This is used by :list action.
> > > >  # Without this condition then all records for this model are
> > > > 
> > > > returned -- and we don't want that since there is only one detail/
> > > > product.
> > > > 
> > > >  def conditions_for_collection
> > > > 
> > > >    ['detail_fungicides.id = (?)', params[:id]]
> > > > 
> > > >  end
> > > > 
> > > > end
> > > > 
> > > > Here are helpers that don't seem to be called --
> > > > 
> > > > module Admin::DetailFungicideHelper
> > > > 
> > > >   def formulation_column(record)
> > > > 
> > > >    link_to((record.formulation.empty? ? "Formulation" :
> > > > record.formulation),
> > > > 
> > > >      {:controller => "admin/detail_fungicide",
> > > > 
> > > >        :action => :edit,
> > > >        :_method => :get,
> > > >        :id => "#{record.id}",
> > > >        :parent_controller => "admin/product" },
> > > > 
> > > >      {:id => "#{action_link_id('edit', record.id) }",
> > > > 
> > > >        :class => "nested action",
> > > >        :position => "after"})
> > > > 
> > > >      end
> > > > 
> > > >   def contains_column(record)
> > > > 
> > > >    link_to(record.contains,
> > > > 
> > > >      {:controller => "admin/detail_fungicide",
> > > > 
> > > >        :action => :nested,
> > > >        :_method => :get,
> > > >        :associations => :fungicide_ingredients,
> > > >        :id => "#{record.id}",
> > > >        :parent_controller => "admin/product" },
> > > > 
> > > >      {:id => "#{action_link_id('edit', record.id) }",
> > > > 
> > > >        :class => "nested action",
> > > >        :position => "after"})
> > > > 
> > > >  end
> > > > 
> > > >  def fungi_column(record)
> > > > 
> > > >    link_to(record.fungi,
> > > > 
> > > >      {:controller => "admin/detail_fungicide",
> > > > 
> > > >        :action => :nested,
> > > >        :_method => :get,
> > > >        :associations => :affected_fungus,
> > > >        :id => "#{record.id}",
> > > >        :parent_controller => "admin/product" },
> > > > 
> > > >      {:id => "#{action_link_id('edit', record.id) }",
> > > > 
> > > >        :class => "nested action",
> > > >        :position => "after"})
> > > > 
> > > >  end
> > > > 
> > > > end
> > > > 
> > > > AND Finally view generated output has incorrect controller referenced
> > > > (/admin/detail_weeding_lawn/edit/1)  for "formulation" and "contains"
> > > > but correct for "fungi" --
> > > > 
> > > > <tr class="record " id="as_admin__detail_fungicide-list-1-row">
> > > > 
> > > >    <td class="product_name-column " >
> > > > 
> > > >      ORTHO RosePride Rose & Shrub Disease Control
> > > > 
> > > >    </td>
> > > > 
> > > >    <td class="formulation-column " >
> > > > 
> > > >      <a href="/admin/detail_weeding_lawn/edit/1?
> > > > 
> > > > _method=get&parent_controller=admin%2Fproduct" class="nested
> > > > action" id="as_admin__detail_fungicide-edit-1-link"
> > > > position="after">Formulation</a>
> > > > 
> > > >    </td>
> > > > 
> > > >    <td class="contains-column " >
> > > > 
> > > >      <a href="/admin/detail_weeding_select/nested/1?
> > > > 
> > > > _method=get&associations=weeding_ingredients&parent_controller=admin
> > > > %2Fproduct" class="nested action" id="as_admin__detail_fungicide-
> > > > edit-1-link" position="after">Triforine</a>
> > > > 
> > > >    </td>
> > > > 
> > > >    <td class="fungi-column " >
> > > > 
> > > >      <a href="/admin/detail_fungicide/nested/1?
> > > > 
> > > > _method=get&associations=affected_fungus&parent_controller=admin
> > > > %2Fproduct" class="nested action" id="as_admin__detail_fungicide-
> > > > edit-1-link" position="after">Black spot; Powdery mildew; Rust</a>
> > > > 
> > > >    </td>
> > 
> > --
> > Sergio Cambra .:: entreCables S.L. ::.
> > Mariana Pineda 23, 50.018 Zaragoza
> > T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
Sergio Cambra .:: entreCables S.L. ::.
Mariana Pineda 23, 50.018 Zaragoza
T) 902 021 404 F) 976 52 98 07 E) [email protected]

-- 
You received this message because you are subscribed to the Google Groups 
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/activescaffold?hl=en.

Reply via email to