Search code examples
ruby-on-railsruby-on-rails-4helperactivescaffold

Active Scaffold 3.4 Rails 4 override method helper


I have a rails project test

Ruby 2.2
Rails 4.0
Active Scaffold 3.4

I have a strange problem with active scaffold when two fields in a different model but with the same name, check the model

class Event < ActiveRecord::Base  
   has_many :tickets  
end 

class Ticket < ActiveRecord::Base
    belongs_to :event
end

Two model have a field 'active' is a boolean

now check the controller for this models

  active_scaffold :event do |conf|
    conf.list.columns = [ :name, :active ]
    conf.create.columns = [ :name, :active, :date ]
    conf.nested.add_link(:tickets, :label => "Tickets")
  end

  active_scaffold :ticket do |conf|
    conf.label = 'Tickets For Events  '
    conf.list.columns = [ :name, :active ]
  end

this is the problem, in the helper of the model.

I need to override the field active, but it has a malfunction

Helper Events
  def active_column(record, input_name)
    "Active column Events"
  end

Helper Tickets
  def active_column(record, input_name)
    "Active column Tickets"
  end

regardless of which controller is calling, always going to call the helper ticket, in both cases

how can fix this, some idea??


Solution

  • I can fixed this, only add config.action_controller.include_all_helpers = false in application.rb, and the override helper work fine