Created
November 15, 2012 22:08
-
-
Save czepluch/4081673 to your computer and use it in GitHub Desktop.
File not assigned
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
#/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