-
-
Save anonymous/328766c74b20733faafac476f3a7a5fc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Line 4 of this class: | |
class CoursesController < ApplicationController | |
def index | |
@search_term = 'jhu' | |
@courses = Coursera.for(@search_term) | |
end | |
end | |
# Causes: undefined method `for' for Coursera:Module | |
# However it's defined in app/models/coursera.rb shown below: | |
class Coursera | |
include HTTParty | |
base_uri 'https://api.coursera.org/api/catalog.v1/courses' | |
default_params fields: "smallIcon,shortDescription", q: "search" | |
format :json | |
def self.for term | |
get("", query: { query: term })["elements"] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment