2013-07-09 50 views
0

我是新來的Ruby-on-軌道simple_form_for並試圖重構以下的form_tag到simple_form_for代碼和我得到一個奇怪的錯誤日誌說明:試圖做下面的示例代碼

"customers_customers_customers_path' no methods found. 

對代碼的哪一部分有錯誤的想法?

<%= form_tag projects_path, :method => 'get', :id => "ajax_search_form" do %> 
... 
<% end %> 

我重構它分爲:

<%= simple_form_for @projects, :html => { :id => 'ajax_search_form' }, :method => 'get' do |f| %> 

... 
<% end %> 

我在做什麼錯?

+0

您可以請分享您的完整日誌,這種錯誤提升?路由.rb也會有所幫助 –

回答

0

simple_form_for主要用於將form與form_for關聯起來。在你的代碼中,你使用了form_tag來關聯到一個路徑,而不是一個模型。在這裏實現simple_form_for的正確方法是:

<%= simple_form_for :projects, :url => projects_path, :method => 'get', :id => "ajax_search_form" do $> 
... 
<% end %>