Search code examples
ruby-on-rails-3formtasticactiveadmin

ActiveAdmin Formtasic DSL add a link inside a nested set


I have ActiveAdmin + Rails 3.1 and everything works fine except one thing i have a nested model inside of my Products. and once i`ve added an image i cant remove it from my product!!! the only way i can find is to add a custom link inside the form to a custom action tha will remove this association.

form do |f|
    f.inputs "Options:" do
      f.input:price
      f.input:about

      f.has_many :pictures do |son|
 #I NEED A LINK_TO REMOVE THIS ASSOCIATION INSIDE OF HERE
      son.input :photo, :as => :file, :label => "pic",:hint => son.object.nil? ? son.template.content_tag(:span, "No Image Yet") : son.template.image_tag(son.object.photo.url(:thumb))
    end

    f.buttons
end

But cant find the way out. Seems like there is no such method to output custom html!!!!


Solution

  • Solved with a dirty hook:

     :label =>(son.object.new_record? ? "Изображение" : son.template.link_to