Make sure the HTTParty gem is in your application's
example.rb and put it in
/app/models/stack_exchange.rb — yes the file name does matter (this isn't the purists place to put this, but for beginners it's fine and perfectly acceptable). Remove the code at the bottom you're using to test it as well.
routes.rb add this route:
get '/test' => 'application#test'
application_controller.rb add this method:
stack_client = StackExchange.new('stackoverflow', 1)
@users = stack_client.users
app/views/application/test.html.erb put the following:
<% @users.each do |user| %><%=user.inspect%><br/><br/><% end %>
Note: I would otherwise recommend adding views to
ApplicationController but because I don't know anything about your application, I'll default to it.
hit http://localhost:3000/test and you should see the expected result.
 Rails does a lot "magic" under the scenes — it's really not magic but metaprogramming — where it tries to assume a lot of things about your application structure and naming conventions. If your class was named
Stackexchange (note the lowercase
stackexchange.rb would be automatically "mapped" to the class
Stackexchange. More info: http://guides.rubyonrails.org/autoloading_and_reloading_constants.html