Created
January 28, 2011 00:16
-
-
Save vinniefranco/799580 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= form_for @gallery, :html => { :multipart => true }, :remote => true do |f| | |
%ol.dialog.form | |
%li.text | |
= f.label :title | |
= f.text_field :title | |
%li.select | |
= f.label :parent_id, 'Parent' | |
= f.select :parent_id , @galleries.collect {|g| [g.title, g.id]}, { :include_blank => 'Pick a parent' } | |
%li.file | |
- f.fields_for :image do |image| | |
= image.label :asset, 'Thumbnail' | |
= image.file_field :asset | |
%li.submit | |
= f.submit | |
#form_wait |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhotoGalleriesController < ApplicationController | |
respond_to :html, :json, :js | |
... | |
def new | |
@galleries = PhotoGallery.current_clients_galleries(current_client.id) | |
@gallery = PhotoGallery.new | |
@gallery.build_image | |
@form = render_to_string :partial => 'form' | |
respond_with(@gallery) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PhotoGallery < ActiveRecord::Base | |
# Poster image for gallery | |
has_one :image, | |
:conditions => { :table_name => :galleries }, | |
:foreign_key => "table_id" | |
accepts_nested_attributes_for :image, :reject_if => proc { |attributes| attributes['asset'].blank? } | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Image < ActiveRecord::Base | |
... | |
belongs_to :photo_gallery, :foreign_key => 'table_id', :inverse_of => :image | |
has_attached_file :asset, | |
:storage => :s3, | |
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml", | |
:path => "/media/:class/:attachment/:style.:filename", | |
:bucket => '******' | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment