我想在rails中创建一个简单的辅助模块,而且我很难从我的新人形式(app/views/people/new.html)中获取以下错误消息。 erb):Rails帮助模块undefined方法`排序'
undefined method `sort' for 97:Fixnum
Extracted source (around line #17):
14: <p>
15: <% nations = { 'United States of America' => 'USA', 'Canada' => 'Canada', 'Mexico' => 'Mexico', 'United Kingdom' => 'UK' } %>
16: <%= f.label :country %><br />
17: <%= radio_buttons(:person, :country, nations) %>
18:
19: </p>
20: <p>
radio_buttons是我为我的视图创建的帮助器模块。这是(应用程序/佣工/ people_helper.rb):
module PeopleHelper
def radio_buttons(model_name, target_property, button_source)
html=''
list = button_source.sort
list.each do |x|
html << radio_buttons(model_name, target_property, x[1])
html << h(x[0])
html << '<br />'
end
return html
end
end
的问题似乎是在“名单= button_source.sort”,但我不知道为什么它说的方法是不确定的。我已经能够直接在我的视图代码中使用它。我不能在辅助模块中使用这样的方法吗?我需要包括什么吗?
感谢您的帮助!
这让我过去了排序错误,所以谢谢!但是,现在我得到了“堆栈太深”的错误。我的递归似乎是有问题的。 – Magicked 2010-04-12 16:26:34