Skip to content

Instantly share code, notes, and snippets.

@czepluch
Created November 15, 2012 22:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save czepluch/4081673 to your computer and use it in GitHub Desktop.
Save czepluch/4081673 to your computer and use it in GitHub Desktop.
File not assigned
#/model/user.rb
attr_accessible :name, :first_name, :last_name, :email, :password, :password_confirmation, :remember_me,
:provider, :uid, :photos_attributes
has_many :photos
accepts_nested_attributes_for :photos
#/model/photo.rb
class Photo < ActiveRecord::Base
attr_accessible :id, :photo, :user_id
belongs_to :user
mount_uploader :photo, PhotoUploader
end
#/controllers/users_controller.rb
def show
@photos = @user.photos
end
def update
@user.photos.build
end
#/views/devise/registration/edit.html.erb
<%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :class => 'form-vertical', :multipart => true }) do |f| %>
<%= f.error_notification %>
...
<%= f.fields_for :photos do |p| %>
<%= p.file_field :photo %>
<% end %>
...
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment