Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created February 13, 2009 04:29
Show Gist options
  • Select an option

  • Save batasrki/63047 to your computer and use it in GitHub Desktop.

Select an option

Save batasrki/63047 to your computer and use it in GitHub Desktop.
def create
@album = Album.new(params[:album])
if @album.save
@photo = Photo.new(params[:photo])
@photo.album = @album
@photo.save
end
end
## app/views/albums/new.html.erb
## (This is only sample code and will probably not work for you out of the box)
<% form_for @album do |f| %>
<%= f.text_field :name %>
<%= f.file_field [:photo][:file_name] %> # Suggest you look into Paperclip for uploading files
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment