0

1.Installed gem "Instagram"

2.config/initializers/ instagram.rb

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

3. In 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. In views : (home/index.html.haml)

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

Can anyone help me with this? I am new to ruby.

Cliff_Cleet
  • 201
  • 1
  • 3
  • 14
  • Just for clarification, have you added `require "sinatra"` and `require "instagram"` in your controller? – Sagar Apr 11 '17 at 13:10
  • Where i have to add those ? i have added "require instagram" in initializers/instagram.rb – Cliff_Cleet Apr 12 '17 at 03:58
  • You have to use those in all controllers/models where you use its respective methods. Doing so on config file will not work. – Sagar Apr 12 '17 at 06:14
  • ok..can you please tell me which link you have followed to do this? so that i can access those library files and all – Cliff_Cleet Apr 12 '17 at 06:29
  • Not followed any links and stuff. I am checking it out on their official github page. https://github.com/facebookarchive/instagram-ruby-gem – Sagar Apr 12 '17 at 06:31
  • Ok... In that the sample application given have to be given in instagram.rb {config/initializer} ? So how to display it on the view page (.haml file) – Cliff_Cleet Apr 12 '17 at 06:40
  • Use the `require` in your controllers where you are using `Instagram.user_recent_media('xxxxx', {:count => 15})` aka in your application_controller.rb – Sagar Apr 12 '17 at 06:59
  • https://github.com/facebookarchive/instagram-ruby-gem . I have added the lib as given in this github....But now shows error "cannot load such file -- faraday" . – Cliff_Cleet Apr 12 '17 at 09:33

0 Answers0