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> </th>
14: <th> </th>
This is what my list.rhtml file looks like:
<% @heading = "To Do List" %>
<%= start_form_tag :action => 'new' %>
<table>
<tr>
<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>
<th> </th>
<th> </th>
</tr>
<%= render_collection_of_partials "list_stripes", @items %>
</table>
<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
end
def show_image(src)
img_options = { "src" => src.include?{"/"} ? src : "/images/#{src}"}
img_options["src"] = img_options["src"] + ".png" unless
img_options["src"].include?(".")
img_options["border"] = "0"
tag("img", img_options)
end
end
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
end
What am I doing wrong? I can't understand why I'm getting an error about passing the wrong number of arguments.