如何在rails项目中设置Wistia ruby​​ gem

时间:2023-02-06 07:42:22

The wistia-api gem (https://github.com/wistia/wistia-api) says that I have to set the Wistia password like so:

wistia-api gem(https://github.com/wistia/wistia-api)说我必须像这样设置Wistia密码:

Wistia.password = 'your-api-password-here'

Where do I add this line of code in my rails project?

我在rails项目中添加这行代码的位置在哪里?

I've added it to environment.rb but when I run rails console it gives me an unknown constant error.

我已经将它添加到environment.rb但是当我运行rails console时它会给我一个未知的常量错误。

3 个解决方案

#1


2  

you have to make sure you install the right gem first, in gemfile put

你必须先确保在gemfile中安装正确的gem

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:

gem wistia-api然后运行bundle install如果你使用rails 4,在/ config / initializers文件夹中创建一个名为wistia_api.rb的文件,写:

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

那么你应该在rails控制台中使用它

#2


1  

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.

您将获得一个未知的常量错误,因为尚未加载Wistia模块。在尝试调用它之前,你需要'wistia'。

Generally it's best to do things like this in an initializer, so you could create config/initializers/wistia.rb and put in it:

通常最好在初始化程序中执行此类操作,因此您可以创建config / initializers / wistia.rb并将其放入其中:

require 'wistia'

Wistia.password = 'your-api-password-here'

#3


0  

If you read the documentation of the wistia gem, there is an option to put these credentials into a yml config file: https://github.com/wistia/wistia-api#configuration-options

如果您阅读了wistia gem的文档,可以选择将这些凭据放入yml配置文件中:https://github.com/wistia/wistia-api#configuration-options

#1


2  

you have to make sure you install the right gem first, in gemfile put

你必须先确保在gemfile中安装正确的gem

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:

gem wistia-api然后运行bundle install如果你使用rails 4,在/ config / initializers文件夹中创建一个名为wistia_api.rb的文件,写:

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

那么你应该在rails控制台中使用它

#2


1  

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.

您将获得一个未知的常量错误,因为尚未加载Wistia模块。在尝试调用它之前,你需要'wistia'。

Generally it's best to do things like this in an initializer, so you could create config/initializers/wistia.rb and put in it:

通常最好在初始化程序中执行此类操作,因此您可以创建config / initializers / wistia.rb并将其放入其中:

require 'wistia'

Wistia.password = 'your-api-password-here'

#3


0  

If you read the documentation of the wistia gem, there is an option to put these credentials into a yml config file: https://github.com/wistia/wistia-api#configuration-options

如果您阅读了wistia gem的文档,可以选择将这些凭据放入yml配置文件中:https://github.com/wistia/wistia-api#configuration-options