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: <td><%= member.primary_telephone %></td>
38: <td><%= member.primary_mobile %></td>
39:
40: <td><%= link_to "Show", member_path(member.club,
member) %></td>
41: <td><%= link_to "Edit", edit_member_path(member.club,
member) %></td>
42: <td><%= button_to "Deactivate",
member_path(member.club,
member), :method => :delete %></td>
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."
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---