Skip to content

Instantly share code, notes, and snippets.

@kivanio
Forked from robertjwhitney/film.rb
Last active August 29, 2015 14:16
Show Gist options
  • Save kivanio/05f1d0aa4bea3997b587 to your computer and use it in GitHub Desktop.
Save kivanio/05f1d0aa4bea3997b587 to your computer and use it in GitHub Desktop.
# active_admin and formtastic seem kinda picky about displaying both the
# image and the file input together here... in fact, it seems like this
# is the ONLY way to do this? Adding anything else after the image_tag squashes it.
ActiveAdmin.register Film do
form do |f|
f.inputs "Film" do
f.input :title
end
f.has_many :stills do |film_still_form|
if film_still_form.object.new_record?
film_still_form.input :photo, :as => :file
else
image_tag film_still_form.object.photo.url(:thumbnail)
end
end
f.buttons
end
end
ActiveAdmin.register Still do
belongs_to :film
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment