• Advertisement
Sign in to follow this  

Ruby on Rails problem

This topic is 4396 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was following the tutorial posted here: http://www.rails4days.pwp.blueyonder.co.uk/Rails4Days.pdf But I got to page #24 where you make a helper method, and the method doesn't work for me. I get this error:
 ArgumentError in Items#list

Showing app/views/items/list.rhtml where line #11 raised:

wrong number of arguments (0 for 1)

Extracted source (around line #11):

8:     <th><%= link_to_image "description", {:action => "list_by_description"}, "alt" => "Sort by Description" %></th>
9:     <th><%= link_to_image "due_date", {:action => "list"}, "alt" => "Sort by Due Date" %></th> 
10:     <th><%= link_to_image "category", {:action => "list_by_category"}, "alt" => "Sory by Category" %></th>
11:     <th><%= show_image "note" %></th>
12:     <th><%= show_image "private" %></th>
13:     <th>&nbsp;</th>
14:     <th>&nbsp;</th>

This is what my list.rhtml file looks like:
<% @heading = "To Do List" %>
<%= start_form_tag :action => 'new' %>

    <th><%= link_to_image "done", {:action => "purge_completed"}, :confirm => "Are you sure you want to permanently delete all completed To Dos?" %></th>
    <th><%= link_to_image "priority", {:action => "list_by_priority"}, "alt" => "Sort by Priority" %></th>
    <th><%= link_to_image "description", {:action => "list_by_description"}, "alt" => "Sort by Description" %></th>
    <th><%= link_to_image "due_date", {:action => "list"}, "alt" => "Sort by Due Date" %></th> 
    <th><%= link_to_image "category", {:action => "list_by_category"}, "alt" => "Sory by Category" %></th>
    <th><%= show_image "note" %></th>
    <th><%= show_image "private" %></th>
<%= render_collection_of_partials "list_stripes", @items %>
<hr />
<%= submit_tag "New To Do..." %>
<%= submit_tag "Categories...", {:type => "button", :onClick => "parent.location = '" + url_for(:controller => "categories", :action => "list") + "'"} %>
<%= end_form_tag %>
<%= "Page: " + pagination_links(@item_pages, :params => {:action => @params["action"] || "index"}) + "<hr />" if @item_pages.page_count > 1 %>

And here's application_helper.rb
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
  def self.append_features(controller)
    controller.ancestors.include?(ActionController::Base) ?
      controller.add_template_helper(self) : super
  def show_image(src)
    img_options = { "src" => src.include?{"/"} ? src : "/images/#{src}"}
    img_options["src"] = img_options["src"] + ".png" unless 
    img_options["border"] = "0"
    tag("img", img_options)

And I included the Application helper in the application controller
# Filters added to this controller will be run for all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
  helper :Application

What am I doing wrong? I can't understand why I'm getting an error about passing the wrong number of arguments.

Share this post

Link to post
Share on other sites
I don't think there are nearly enough Ruby users here to give you a decent answer. Your code looks ok to me but I've only ever written 5 lines of Ruby so what would I know? You could try asking on comp.lang.ruby, perhaps. Good luck!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement