readme. trying to get multiple objects in form

This commit is contained in:
Espen Antonsen 2009-06-10 01:22:48 +02:00
parent 69936b9622
commit b42910636b
5 changed files with 20 additions and 8 deletions

4
README
View file

@ -9,13 +9,13 @@ Made by Espen Antonsen
* Read and writes EXIF
* Organize in albums (events in iPhoto)
* Combine albums in collections (albums in iPhoto)
* Upload multiple photos (using uploadify)
* Upload multiple photos
* Tag photos. Can also tag albums (actually all photos in album is tagged)
* User management with roles and permissions.
== Requirements
Tested with Ruby 1.8.6 and Rails 2.3
Rails 2.3
Software
- FreeImage (required for Image_Science)

View file

@ -98,9 +98,10 @@ class PhotosController < ApplicationController
end
def update_multiple
@photos = Photo.find(params[:photo_ids])
@photos.each do |photo|
photo.update_attributes!(params[:photo].reject { |k,v| v.blank? })
@photos = params[:photos][:photo]
@photos.each do |photo_id|
photo = Photo.find( photo_id )
photo.update_attributes!(params[:photos][:photo][photo_id].reject { |k,v| v.blank? })
end
flash[:notice] = "Updated photos!"
redirect_to photos_path

View file

@ -1,3 +1,13 @@
<ul><%= render :partial => @photos %></ul>
<% form_for :photos, :url => update_multiple_photos_path, :html => { :method => :put } do |f| %>
<% for photo in @photos %>
<p>
<% f.fields_for photo do |p|%>
<%= p.text_field :title, :index => photo.id %>
<%= p.text_field :tags, :index => photo.id, :value => photo.tag_list %>
<% end%>
</p>
<% end%>
<p><%= f.submit "Submit" %></p>
<% end %>
<br /><%= link_to "Back to #{@album.title}", @album %>

View file

@ -34,4 +34,5 @@ $(document).ready(function() {
<div id="thumbs"></div>
</form>
<br /><%= link_to "Edit uploaded photos", untouched_album_photos_path( @album ) %>
<br /><%= link_to "Back to #{@album.title}", @album %>

View file

@ -7,10 +7,10 @@ ActionController::Routing::Routes.draw do |map|
map.resources :photos,
:collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get }
map.resources :albums, :collection => { :untouched => :get} do |album|
album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }, :shallow => true
end
map.resources :collections
map.resources :tags, :has_many => [ :photos, :albums ]
map.resources :tags, :has_many => [ :photos, :albums ], :shallow => true
map.resources :users, :controller => "admin/users"