Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # POST /photos
- # POST /photos.json
- def create
- @photo = Photo.new(params[:photo])
- @photo.lat = params["photo%5Blat%5D"].to_s
- @photo.lng = params["photo%5Blng%5D"].to_s
- @photo.description = params[:description]
- @photo.takenby = params[:takenby].to_s
- @photo.save
- puts "photos/create photos.inspect= #{@photo.inspect}"
- end
- class Photo < ActiveRecord::Base
- attr_accessible :lat, :lng, :image
- vendor = params[:description]
- owner = params[:owner]
- Paperclip.interpolates :prefix do |attachment, style|
- "#{owner}/#{Date.today.to_s }/#{vendor}"
- end
- has_attached_file :image,
- :path => ":prefix/:basename.:extension",
- :styles => { :thumbnail => "57x57", :original => "100x100" },
- :storage => :s3,
- :s3_credentials => S3_CREDENTIALS
- Started GET "/photos?lat=37.785834&lng=-122.406417" for 127.0.0.1 at 2012-09-26
- 21:08:57 -0700
- 21:08:57 web.1 | Processing by PhotosController#index as JSON
- 21:08:57 web.1 | Parameters: {"lat"=>"37.785834", "lng"=>"-122.406417"}
- 21:08:57 web.1 | Completed 500 Internal Server Error in 4ms
- 21:08:57 web.1 | NameError (undefined local variable or method `params' for #<Class:0x007fb7d4fa3320>):
- 21:08:57 web.1 | app/models/photo.rb:23:in `<class:Photo>'
- 21:08:57 web.1 | app/models/photo.rb:18:in `<top (required)>'
- 21:08:57 web.1 | app/controllers/photos_controller.rb:14:in `index'
- photo.rb
- Paperclip.interpolates :prefix do |attachment, style|
- "#{attachment.instance.takenby}/#{Date.today.to_s }/#{attachment.instance.description}"
- end
- vendor = params[:description]
- owner = params[:owner]
- Paperclip.interpolates :description do |attachment, style|
- attachment.instance.description # or other attribute
- end
- has_attached_file :image,
- :path => ":description/:basename.:extension",
- :styles => { :thumbnail => "57x57", :original => "100x100" },
- :storage => :s3,
- :s3_credentials => S3_CREDENTIALS
- obj.set_values(params)
- def set_values(params)
- self.vendor = params[:description]
- self.owner = params[:owner]
- end
- <%= form_for (@post) do |f| %>
- <%= form_for @post, :html => { :multipart => true } do |f| %>
- <p>
- <%= f.file_field :photo %>
- </p>
Add Comment
Please, Sign In to add comment