I have User model, where user should be able to upload one picture as an avatar. But I don't really know how to implement this in correct REST way. I see two options
First I think of avatar as of member resource that belongs to user, so I add two actions to my Users Controller, one avatar for the upload form, and second action for handling the actual upload avatar_upadte, so my routes look like
map.resources :users, :member => { :avatar => :get, :avatar_update => :post }
Second I can think of avatar as of separate resource and create Avatars Controller instead, which would be like
map.resources :users
map.resources :avatars, :only => [ :new, :create ]
I don't want to handle avatar upload in edit_user
action, since it is already pretty complex.
The third option could be to have only avatar action to display the form and then user REST user update action as upload target, where form would be something like this
<% form_for @user, :url => user_path(@user), :html => { :multipart => true } do |f| %>
<%= f.label :avatar, 'Avatar' %>
<%= f.file_field :avatar %>
<%= f.submit 'Upload' %>
<% end %>
But I don't like this this attitude either, because since my update action already handles another form, it would be pretty ugly to handle redirects etc.