save new album to current collection

This commit is contained in:
Espen Antonsen 2009-06-30 22:41:27 +02:00
parent 0fb47748db
commit 07493aaaad
2 changed files with 5 additions and 0 deletions

View file

@ -45,6 +45,9 @@ class AlbumsController < ApplicationController
@album = Album.new(params[:album]) @album = Album.new(params[:album])
@album.path = @album.title @album.path = @album.title
if @album.save if @album.save
if params[:collection_id]
@album.collections << Collection.find( params[:collection_id] )
end
flash[:notice] = "Album created!" flash[:notice] = "Album created!"
redirect_to @album redirect_to @album
else else

View file

@ -3,9 +3,11 @@
<% end %> <% end %>
<%= hidden_field_tag :all_tags, "'#{Tag.find(:all).map { |tag| tag.title }.join('\',\'')}'" %> <%= hidden_field_tag :all_tags, "'#{Tag.find(:all).map { |tag| tag.title }.join('\',\'')}'" %>
<%= hidden_field_tag :collection_id, params[:collection_id] %>
<%= form.label :title, :Title, {:class => 'big'} %><br /> <%= form.label :title, :Title, {:class => 'big'} %><br />
<%= form.text_field :title, {:class => 'big'} %><br /> <%= form.text_field :title, {:class => 'big'} %><br />
<%= form.label :description %><br /> <%= form.label :description %><br />
<%= form.text_area :description %><br /> <%= form.text_area :description %><br />