daily pastebin goal
37%
SHARE
TWEET

Untitled

a guest May 16th, 2018 106 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <% form_for :picture, :url => {:action => :upload}, :html => {:multipart => true} do |f| %>
  2.     <div>
  3.         Titolo<br />
  4.         <%= f.text_field :title, :class => "textinput" %>
  5.     </div>
  6.     <div>
  7.         Descrizione<br />
  8.         <%= f.text_area :description, :class => "textinput",:style => "width: 247px; height: 100px;" %>
  9.     </div>
  10.     <div>
  11.         Album<br />
  12.         <%= f.select(:album_id,
  13.                         current_user.photo_albums.collect {|p| [ p.title, p.id ]},
  14.                         :style =>"width: 200px;", :class => "textinput") %>
  15.     </div>
  16.     <%= f.file_field :uploaded_data, :class => "textinput" %>
  17.     &nbsp;&nbsp;&nbsp;<%= submit_tag 'Upload >>' %>
  18. <% end %>
  19.  
  20.  
  21.  
  22.  
  23.   def upload
  24.     return if !request.post?
  25.     if params[:picture] && params[:picture][:uploaded_data].respond_to?(:size) && params[:picture][:uploaded_data].size > 0
  26.  
  27.         current_user.photos << Picture.create(params[:picture])
  28.         redirect_to :action => :show
  29.     else
  30.       flash[:error] = 'Problems uploading your avatar.'
  31.       redirect_to :action => :upload
  32.     end
  33.   end
RAW Paste Data
Top