使用Instagram获取媒体。显示错误“未初始化的常量Instagram”

时间:2017-04-11 13:04:05

标签: ruby-on-rails rubygems instagram instagram-api ruby-2.3

1.安装宝石“Instagram”

2.config / initializers / instagram.rb

Instagram.configure do |config|
config.client_id = "XXXXXXXXXXXXXXXXXXXXXXXXXX"
config.client_secret = "XXXXXXXXXXXXXXXXXXXXXXX"
config.access_token = "XXXXXXXXXXXXXXXXXXXXXXxXX"
end

3。在application_controller.rb中:( app / controllers /)

class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
def index
@instagram = ::Instagram.user_recent_media('xxxxx', {:count => 15})
end
end

4。在视图中:(home / index.html.haml)

 <% @instagram.each do |instagram| %>
 <%= image_tag instagram.images.standard_resolution.url %>
 <% end %>

任何人都可以帮我吗?我是红宝石的新手。

0 个答案:

没有答案