2012-02-14 2 views
0

때마다 내가 수행이 폼에서 서브 필드 중 하나를 표시하지 않습니다 다음 formtastic을 사용하여 중첩 된 양식을 얻으려면 어떻게해야합니까?

= f.semantic_fields_for :transfers do |g| 

내가 singularize 경우

, 그들은 표시하지만 모델이 :transfer 함께 할 수있는 어떤 단서가 없습니다. accepts_nested_attributes_for가 일치하도록 단 하나를 시도했지만 그 중 하나가 작동하지 않았습니다.

거래 :

has_many :transfers 
accepts_nested_attributes_for :transfers 

전송 :

belongs_to :transaction 

보기 :

= semantic_form_for [@user, @transaction], url: url, style: "width: inherit;" do |f| 
    = f.semantic_fields_for :transfers do |g| 
    = g.inputs do 
     = g.input :amount 
     %li 
     %label 
     = "(#{Transfer::TRANSFER_FEE.format :symbol} transaction fee will be added)" 
    = g.inputs do 
     %li 
     %label 
     Click 
     %input{ type: "image", value: "submit", style: "vertical-align: middle;", 
      src: "https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif" } 
     or fill in your credit card information below 
    = g.inputs do 
     = g.input :first_name 
     = g.input :last_name 
     = g.input :card_type, as: :select, collection: [["Visa", "visa"], ["MasterCard", "master"], ["Discover", "discover"], ["American Express", "american_express"]] 
     = g.input :card_number 
     = g.input :card_verification 
     = g.input :card_expires_month, as: :select, collection: (1..12) 
     - year = Time.now.year 
     = g.input :card_expires_year, as: :select, collection: (year..(year+25)) 
    = f.inputs do 
    %li 
     %label 
     %input{ type: "submit", value: "Buy", name: "use_cc" } 
+0

입력 블록 (3 행)이 semantic_fields_for 블록 외부에 있어야합니까? –

+0

거기있을 필요는 없지만 영향을 미치지 않습니다. – skeemer

+0

죄송합니다. 제 질문에 이상하게 대답했습니다. 단지 명확히하기 위해 입력 블록에 semantic_fields_for 블록을 래핑하면 아무 효과가 없습니까? –

답변

0

문제는 내가 전송 객체를 구축하지 않은 것이 었습니다. 제어기는 I 번째 행을 첨가하지 않은

@transaction = current_user.transactions.build 
@transaction.transfers.build 

에서

.

관련 문제