简体   繁体   English

活动脚手架3.4 Rails 4覆盖方法助手

[英]Active Scaffold 3.4 Rails 4 override method helper

I have a rails project test 我有一个Rails项目测试

Ruby 2.2 Ruby 2.2
Rails 4.0 Rails 4.0
Active Scaffold 3.4 主动式脚手架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 两个模型都有一个字段“ active”是一个布尔值

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?? 如何解决这个问题,一些想法?

我可以解决此问题,仅在application.rb中添加config.action_controller.include_all_helpers = false ,并且覆盖帮助程序可以正常工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM