Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

Eric Boehs's Profile

GitHub User: ericboehs

Site: http://ericboehs.com

Comments by Eric Boehs

Avatar

It sounds like you don't have your CORS setup right (or at all). Check that you're using the right Origin Domain (as specified in the CORS policy).

Also you should use https://s3.amazonaws.com/xyz instead as you'll get invalid certs for https://xyz.s3.amazonaws.com.

Avatar

How would you go about allowing file uploads to S3 from an API (e.g. I want to allow users of my site to upload images to my service through our API)?

I'd do an upload via fog but we're using Heroku and the connection times out after 30 seconds.

Avatar

I needed to validate permission of a polymorphic association with CanCan.

Hope this helps someone:

ruby
validate :can_comment?

def can_comment?
  if Ability.new(user).cannot?(:comment, commentable_type.classify.constantize.find(commentable_id))
    errors.add(:base, :cannot_comment)
  end
end

Better explanation in this Gist.

Avatar

Make sure you are using the latest homebrew install of postgres (9.1.x) on Mac.

On Ubuntu/Debian you will probably need the postgres-contrib package installed for extensions.

Avatar

scss has a asset-url method you can call.

ruby
    background: asset-url('body-bg.gif', image);