Friday, 15 April 2011

ruby on rails - How can i remove blank nested form field? -



ruby on rails - How can i remove blank nested form field? -

how can reject blank nested field in nested form in rails using code:

class award < activerecord::base attr_accessible :category, :country_iso,:title, :year,:status ,:nomination_awards_attributes,:sponsor_awards_attributes,:city has_many :nomination_awards, dependent: :destroy has_many :sponsor_awards, dependent: :destroy accepts_nested_attributes_for :nomination_awards, :allow_destroy => true accepts_nested_attributes_for :sponsor_awards, :allow_destroy => true#,:reject_if => lambda { |a| a[:sponsor_id].blank? } validates :title,:category,:country_iso,:year,:city, :presence => true end

reject blank field using code :reject_if => lambda { |a| a[:sponsor_id].blank? }

and check in in edit info nowadays or not, if info nowadays or build no need build in edit page if not nowadays or build have build on edit page ....

ruby-on-rails

No comments:

Post a Comment