2

Can anyone point me to how to add the prefix_option when dealing with active resource association? I have done the following but with no success:

class League < ActiveResource::Base
   has_many: teams
   self.site = "http://api-yyy.com/"
end

 class Team < ActiveResource::Base
   belongs_to: league
   self.site = "http://api-yyy.com/league/:league_id/"
 end

And in the Team controller, I have :

def index 
  @league = League.find(params[:league_id])
  @teams = @league.teams 
end 

But I'm getting ruby :league_id prefix_option missing when I visit the index page. Any help would be appreciated.

1 Answers1

1

I think your active resource simply should be

class League < ActiveResource::Base
   has_many: teams
end

 class Team < ActiveResource::Base
   belongs_to: league
 end
You should use routes to show how you want to view self.site , you should take a look at this article hope this helps http://guides.rubyonrails.org/routing.html
akhil ranjith
  • 72
  • 2
  • 9
  • @ranjith:Well, how do you set-up the routes? I currently have shallow routes but I did NOT find a way to set-up the routes and includes self.site...Any suggestion? – Rafiki Assumani May 11 '15 at 19:03