Hi,
I am trying to get into this REST thing, I have a nested resource
whith the following route:
ActionController::Routing::Routes.draw do |map|
map.resources :members
map.resources :clubs do |club|
club.resources :members
end
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:id.:format’
end
Everything worked ok for this /clubs/#/members resource, but since I
tried to use the REST url helpers, I get strange errors:
NoMethodError in Members#index
Showing members/index.html.erb where line #40 raised:
undefined method `has_key?’ for #Member:0x243ffd8
Extracted source (around line #40):
37:
38:
39:
40:
41:
%>
42:
member), :method => :delete %>
43:
The index action of the controller is just:
def index
@club = Club.find(params[:club_id])
@members = @club.members.find(:all, :conditions => [“is_active =
?”,true])
@term = get_term
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @members }
end
end
I can use the same code from the console ok, so the models should be
connected properly:
m = Member.find(:first)
=> #<Member id: 1, …m.club
=> #<Club id: 1, club_name: …
What did I do wrong? Any ideas?
/Fredrik
–
“Give up learning, and put an end to your troubles.”