AegisSailor
05-07-2006, 01:57 AM
Greetings, all-knowing-ones,
I've been hacking at this error for hours now and I've run out of ideas. Using the component feature, I'm trying to pass two parameters from a view, through a helper, to the target controller, which then in turn passes the parameter to the model for incorporation into a DB query. I keep getting the error:
ArgumentError in Link managerController#show
wrong number of arguments (2 for 1)
I don't understand what is happening here, I'm passing two parameters and I'm using two parameters. Let me walk you through the relevant parts of my code:
<div id="wrapper">
<% if flash[:notice] -%>
<div id="notice"><%= flash[:notice] %></div>
<% end -%>
<%= insert_context_menu%>
<%= @content_for_layout %>
</div>
the call to insert_context_menu is to a helper that looks like this:
def insert_context_menu
if @show_context
render_component(:controller => 'LinkManager',
:action => 'show',
:params =>{"cat" => "admin","sub" =>"user_manager"},
:layout => nil)
end
end
So, I've assigned values to two parameters, cat and sub. The helper calls on the following action:
def show
@local_links = Link.get_links (params[:cat,:sub])
end
I'm now calling on the model to query the database and return data I need to build context-sensitive hyper-links. I think I'm correctly passing the two parameters that orginated in the helper. Here's the method in the model:
def self.get_links
link.find(:first,
:conditions => ["category = ? AND sub_category = ?", cat,sub])
end
This query works fine when I tested by creating and setting two variables locally. But as soon as this whole thing runs, I get the wrong number of arguments error.
Any help in restoring my sanity would be much appreciated!
Thanks!
I've been hacking at this error for hours now and I've run out of ideas. Using the component feature, I'm trying to pass two parameters from a view, through a helper, to the target controller, which then in turn passes the parameter to the model for incorporation into a DB query. I keep getting the error:
ArgumentError in Link managerController#show
wrong number of arguments (2 for 1)
I don't understand what is happening here, I'm passing two parameters and I'm using two parameters. Let me walk you through the relevant parts of my code:
<div id="wrapper">
<% if flash[:notice] -%>
<div id="notice"><%= flash[:notice] %></div>
<% end -%>
<%= insert_context_menu%>
<%= @content_for_layout %>
</div>
the call to insert_context_menu is to a helper that looks like this:
def insert_context_menu
if @show_context
render_component(:controller => 'LinkManager',
:action => 'show',
:params =>{"cat" => "admin","sub" =>"user_manager"},
:layout => nil)
end
end
So, I've assigned values to two parameters, cat and sub. The helper calls on the following action:
def show
@local_links = Link.get_links (params[:cat,:sub])
end
I'm now calling on the model to query the database and return data I need to build context-sensitive hyper-links. I think I'm correctly passing the two parameters that orginated in the helper. Here's the method in the model:
def self.get_links
link.find(:first,
:conditions => ["category = ? AND sub_category = ?", cat,sub])
end
This query works fine when I tested by creating and setting two variables locally. But as soon as this whole thing runs, I get the wrong number of arguments error.
Any help in restoring my sanity would be much appreciated!
Thanks!