Sunday, 25 August 2013

Activeadmin has_many form for show and edit only

Activeadmin has_many form for show and edit only

First please note that i am working with rails 4 and activeadmin rails 4
branch. https://github.com/gregbell/active_admin/tree/rails4
I have two models pictue which is ploymorphic
class Picture < ActiveRecord::Base
belongs_to :picture_category
belongs_to :imageable, polymorphic: true
mount_uploader :image, ImageUploader
end
And ship
class Ship < ActiveRecord::Base
has_many :pictures, as: :imageable
accepts_nested_attributes_for :pictures
end
And activeadmin ship.rb
ActiveAdmin.register Ship do
form do |f|
f.inputs do
f.inputs
f.has_many :pictures, :sortable => :picture_categories do |ff|
ff.input :name
end
end
f.actions
end
controller do
def permitted_params
params.permit(:ship => [:name, :title, :short_desc, :description,
:position, :pictures, :enabled, :ship_provider_id,
:picture_category_id, :picture_id])
end
end
end
but the result is this:

How can get rid of delete button and have submit
how can i show this form only on show and edit form because thats not make
sense having child before parents
Please point what are mistakes in code.

No comments:

Post a Comment