2014-08-30 58 views
0

我意識到與使用簡單形式(至少有這種性質)有關的大多數問題都沒有答案。我真的很難理解基礎知識。這些文檔是以太多的知識爲前提的,因爲我沒有弄明白。簡單形式選擇與導軌引導

這是我試圖理解的簡單形式文檔的概述。一個有效的例子可以幫助我學習。

#attribute_name, #column, #html_classes, #input_html_classes, #input_html_options, #input_type, #options, #reflection 

我真的很感謝在Simple Form中使用選擇選項的一些幫助。

下面是簡單表格概述的摘錄。

f.input :age, collection: 18..60, prompt: "Select your age" 

我試圖使用爲例(與在簡單形式概略示例所示的國家優先事項一起)使元素之間的選擇在我的陣列的工作。任何人都可以看到我做錯了什麼。我在下面的嘗試(和其他許多人)沒有奏效。我卡住了。

<div class="question-project"> 
    <%= f.input :expense_type, collection: [Incidental, Less than $500, More than $500 ], prompt: "Are the expenses:"%></div> 

謝謝

+0

還檢查了這一點:https://github.com/rafaelfranca/simple_form-b​​ootstrap,一個簡單的形式和Twitter的Bootstrap 2&3示例應用程序。 – juanitofatas 2014-08-30 03:09:53

回答

1

的陣列需要有一個字符串,像這樣:

<%= f.input :expense_type, collection: ["Incidental", "Less than $500", "More than $500" ], prompt: "Are the expenses:"%></div>

+0

謝謝艾哈邁德。我應該能夠得到那一個......謝謝 – Mel 2014-08-30 02:04:12

+0

這是一個常見的錯誤。總是問自己 - 這個詞是在什麼地方定義的?即這是一個變量嗎?如果不是,那麼它應該是一個字符串。 – Ahmed 2014-08-30 02:05:10