Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8158143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:31:03+00:00 2026-06-06T17:31:03+00:00

Currently I am using the Last.fm api to return concert data (returns a hash)

  • 0

Currently I am using the Last.fm api to return concert data (returns a hash) in my controller, and in the view cycling through this hash to return the data I want. I want this concert data to become more dynamic and put everything into a model. How do I do this? Should I do this in the controller or somehow in the model?

Here is an example of my code

# app/controllers/events_controller.rb
class EventsController < ApplicationController
  def index
    @events = @lastfm.geo.get_events("Chicago",0,5)
    respond_with @events
  end
end

# app/views/events/index.html.erb
<% @events.each do |event| %>
  Headliner: <%= event["artists"]["headliner"] %>
<% end %>

In this example I would would want and Event Model with headliner as a parameter, and put all 5 of the events into this model.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:31:04+00:00Added an answer on June 6, 2026 at 5:31 pm

    I believe it’s a good idea to have a model. There are several advantages as I can see

    1 – You could access data as OO way as other objects

    2 – if you have some business logics (Ex: calculations) you could do it in the model itself with out messing up your view

    3 – it’s clean and DRY

    Example model class would be (this is not a working model, but just to give you an idea):

    class Event
      attr_accessor :headliner
    
    
      def self.event_list(limit = 5)
        lastfm.geo.get_events("Chicago",0,limit) 
      end
    
    end
    

    So you can clean-up your view as

    <% Event.each do |event| %>
       Headliner: event.headliner
    <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently struggling with PHP and creating KML from it. I'm using the last.fm API
I'm using Nokogiri to parse an XML response from last.fm. I am currently returning
I have recently built an iPad app using PhoneGap. Currently it saves the last
Currently using MySQL version 5.1.6 This is my first real world build and so
Currently using Xcode 4.2 and I have two view controllers (1 and 2). I
Here is the current Galleria API: http://galleria.aino.se/docs/1.2/api/methods/ Given this API, I want to display
Im trying to append some JSON data from the last.fm API, I have been
Im trying to append some JSON data from the last.fm API, I have been
I'm currently working on an ASP.NET project where I'm using the Google Maps API
I'm using the Last.fm API and I'm trying to get a lot of info

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.