Method with one argument in page decorator controller

11 views
Skip to first unread message

Juan Mercedes

unread,
Jan 13, 2015, 7:37:00 AM1/13/15
to refine...@googlegroups.com


 have the following method in my decorator:

Refinery::PagesController.class_eval do
before_filter :tournaments_by_discipline

    def books_by_gender(page_title)
      books = Refinery::Books::Book.all
      @books = books.select { |t|  t.gender.name == page_title}
    end
end

page template:

<h1><%= @books(@page.title) %><h1>

error:

wrong number of arguments (0 for 1)

What am I missing parsing the argument?

parndt

unread,
Jan 13, 2015, 3:36:30 PM1/13/15
to refine...@googlegroups.com
Hi Juan,

It seems like you are using the instance variable result of the method, rather than calling the method.  Here's what I'd propose to simply get it working:

Refinery::PagesController.class_eval do
  before_filter
:tournaments_by_discipline

 
def books_by_gender(page_title)
    books
= Refinery::Books::Book.all
   
@books = books.select { |t| t.gender.name == page_title}
 
end

  helper_method
:books_by_gender
end


Then in your view:

<h1><%= books_by_gender(@page.title) %><h1>


Cheers,
Phil

parndt

unread,
Jan 13, 2015, 3:37:05 PM1/13/15
to refine...@googlegroups.com
Supplementary note: I'm not sure what this code is doing:

before_filter :tournaments_by_discipline


Juan Mercedes

unread,
Jan 14, 2015, 8:01:20 AM1/14/15
to refine...@googlegroups.com
Thank you Phil.
Reply all
Reply to author
Forward
0 new messages