开发者

how to check status new in activescaffold

active_scaffold :formats do |config|
    format_order = Format.find(:all, :select => :format_order, :order => :format_order).collect(&:format_order)
    format_order << format_order.size + 1  # I want only implement when new
    config.columns = [:name, :format_order]
    config.columns[:format_order].form_ui = :select
    config.columns[:format_order].op开发者_高级运维tions = {
      :options => format_order
    }
    config.list.columns = [:name, :format_order]
  end

I want if I new format, format_order will add a number as code (format_order.size + 1) but I don't want implement it for edit. please help me. thanks


You will have to implement a callback:

class Format < ActiveRecord::Base
...
  after_validation(:on => :create) do
    self.code = whatever_code_you_want_to_assign #
  end
...
end
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜