Hi all, I've got a feeling from other posts that this should be very
simple, but believe me I've looked around many tutorials / blogs, but
still cant even get the most basic setup working with paperclip and s3.
I am however pretty new to Rails, so could be doing something dumb.

-------

Firstly, to install and use paperclip and aws-s3 I've got them both in
by Gemfile:

gem 'paperclip', :git => 'git://github.com/thoughtbot/paperclip.git'
gem 'aws-s3', :require => 'aws/s3'

from directory of rails app I then type "Bundle install" (enter)

I've got require 'aws/s3' in the model and the controller, and neither
throws up an error.

I've registered with aws-s3, and tested that from console

Is this all I need to do to install them both?

-----------

Assuming I've got them installed correctly how do I use them...


I keep getting the error message: undefined method `stringify_keys' for
#<String:0x1035803c8> when I try to save and then view the image.

This goes away when I remove the line   :storage => :s3 from the model.


My model looks like this:
---------
class EdTenEvent < ActiveRecord::Base

require 'aws/s3'

has_attached_file :photo,

  :styles => { :thumb => "100x100#", :small => "150x150>" },
  :storage => :s3,
  :s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
  :path => ":attachment/:id/:style.:extension",
  :bucket => 'tenevent'

end
---------


When I create a new 'EdTenEvent' the controller looks like this:
-----------
  def create

    @ed_ten_event = EdTenEvent.new(params[:ed_ten_event])

    if @ed_ten_event.save

    flash[:success] = "new event created"
      redirect_to ed_ten_events_path
    else
      @title = "New Event"
      render 'new'
    end
  end
-----------


and the form for adding new 'EdTenEvents' looks like this:
-----------
<%= form_for @ed_ten_event , :html => { :multipart => true } do |f| %>
  <%= render 'shared/error_messages', :object => f.object %>

  <div class="field">
    <%= f.label :photo %>
    <%= f.file_field :photo%>
  </div>

  <div class="actions">
    <%= f.submit "Add Event" %>
  </div>

<% end %>



Index.html.erb looks like this:
---------

#... make table

<% @ed_ten_events.each do |event| %>
  <tr>
  <td><%= image_tag event.photo.url(:thumb) %>

#... add more things to table

</table>
---------


I've got my s3.yml setup in config
----------
access_key_id:MYKEYHERE
secret_access_key:MySuperSecretKeyHere
bucket:tenevents
-----------


As I said before, I keep getting the error message: undefined method
`stringify_keys' for #<String:0x1035803c8>

This goes away when I remove the line   :storage => :s3 from the model.

Not sure what I'm doing wrong, just trying to do the most basic thing,
store 1 photo!

Any pointers to turorials would be great although I've read about 10 and
they all seem to think this should work!

Any help appreciated

Mike B

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to