The wistia-api gem ( https://github.com/wistia/wistia-api ) says that I have to set the Wistia password like so:
Wistia.password = 'your-api-password-here'
Where do I add this line of code in my rails project?
I've added it to environment.rb but when I run rails console it gives me an unknown constant error.
you have to make sure you install the right gem first, in gemfile put
gem wistia-api
then run bundle install
if you are using rails 4, in /config/initializers
folder create a file called wistia_api.rb
, write:
require 'wistia'
Wistia.use_config!(:wistia => {
:api => {
:password => ENV['WISTIA_API_PASSWORD'],
:format => 'json'
}
})
then you should be good to use it in rails console
You're getting an unknown constant error because the Wistia module isn't loaded yet. You need to require 'wistia'
before trying to call it.
Generally it's best to do things like this in an initializer, so you could create config/initializers/wistia.rb and put in it:
require 'wistia'
Wistia.password = 'your-api-password-here'
如果您阅读了wistia gem的文档,可以选择将这些凭据放入yml配置文件中: https : //github.com/wistia/wistia-api#configuration-options
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.