uploadcare / uploadcare-rails

Rails API client that handles uploads and further operations with files by wrapping Uploadcare Upload and REST APIs.
https://uploadcare.com
MIT License
58 stars 70 forks source link

Rails console and Migrations can't run #73

Closed MyklClason closed 3 years ago

MyklClason commented 6 years ago

Not sure if I'm missing something, but the Rails console and Migrations won't run (Server works though) with this gem installed

/usr/local/rvm/gems/ruby-2.4.0/gems/uploadcare-rails-1.2.0/lib/uploadcare/rails/settings.rb:54:in `initialize': Private or public key options were not provided (ArgumentError)
rails -v:  5.2.1
ruby -v: ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]

The environment variables do return the correct values and it works fine when using the upload fields. Possible issue with the private key?

Config:

defaults: &defaults
  public_key: <%= ENV["UPLOADCARE_PUBLIC_KEY"] %> # replace it with your public key
  private_key: <%= ENV["UPLOADCARE_PRIVATE_KEY"] %> # replace it with your private key

  # instances of widget initialized for you on page load
  live: true

  # cache files json dumps to prevent calling to server if it posible
  cache_files: true

  # cache groups json dumps to prevent calling to server if it posible
  cache_groups: true

  # store file or group after model is created or updated
  store_after_save: true

  # deletes file or group after model object is deleted
  delete_after_destroy: true

  # Avaliable options are listed at https://uploadcare.com/documentation/widget/#advanced-configuration
  # please note, that for options marker as Global: N/A - there is no practical meaning
  # of putting this option here, as it will not have any effect.
  # But it also will not break anything.

  # for preview step use:
  # preview_step: false # true or false

  # for clearable option (allows user to remove uploaded file from widget) use:
  # clearable: false # true or false

  # for setting tabs use tabs option:
  # tabs: "url file facebook" # etc
  # read more here: https://uploadcare.com/documentation/widget/#tabs
  #
  #   Full list of tabs:
  # |----------------------------------------|
  # | Code       | File Source     | Default |
  # |------------|-----------------|---------|
  # | url        | Any URL         | On      |
  # | file       | Local disk      | On      |
  # | facebook   | Facebook        | On      |
  # | dropbox    | Dropbox         | Off     |
  # | gdrive     | Google Drive    | On      |
  # | box        | Box             | On      |
  # | skydrive   | SkyDrive        | On      |
  # | instagram  | Instagram       | On      |
  # | evernote   | Evernote        | On      |
  # | vk         | VK              | Off     |
  # |________________________________________|

  # for locale option use:
  # locale: "en"

  # for autostore option use:
  # autostore: true #true or false

  # for manual start (which means you will need to initialize uploaders yourself) use:
  # manual_start: false # true or false

  # for path value use:
  # path_value: true # true or false
  # (important for input values - see https://uploadcare.com/documentation/widget/#input-value)

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults
MyklClason commented 6 years ago

I got this to avoid errors by optionally using the demo keys instead.

  public_key: <%= ENV["UPLOADCARE_PUBLIC_KEY"] || "demopublickey" %>
  private_key: <%= ENV["UPLOADCARE_PRIVATE_KEY"] || "demoprivatekey" %>
dmitrijivanchenko commented 3 years ago

@MyklClason, please, check the issue https://github.com/uploadcare/uploadcare-rails/issues/82 with similar situation.

Thanks!