Skip to content

@czepluch /photos.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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
Something went wrong with that request. Please try again.