代码之家  ›  专栏  ›  技术社区  ›  Hemanth

帮助需要:试图将form\u for的操作方法强制为特定方法时出现语法错误

  •  0
  • Hemanth  · 技术社区  · 15 年前
     <%= form_for([@post, @post.bids.build]),  
     :url => { :action => "offer_bid" } do |f| %>  
        <%= f.submit "Offer Post to this user" %>  
     <% end %>    
    

    我正试图使用上述表单更新bid模型的一个特定列(bid是post下嵌套的模型):-

    resources :posts do
        resources :bids
    end
    

    我已经有一个新的表格创建一行投标模型。

    但是在尝试使用上面的表单时出现了以下语法错误。:-

    compile error
    /home/saran/work_space/rails_apps/incomplete_bid_excercise/app/views  
    /bids/_offer_bid.html.erb:1: syntax error, unexpected tASSOC, expecting kEND  
    ...st, @post.bids.build]),:url => { :action => "offer_bid" } do...  
                              ^
    /home/saran/work_space/rails_apps/incomplete_bid_excercise/app/views  
    /bids/_offer_bid.html.erb:1: syntax error, unexpected kDO, expecting kEND  
    ... { :action => "offer_bid" } do |f| @output_buffer.safe_conca...
                              ^
    /home/saran/work_space/rails_apps/incomplete_bid_excercise/app/views  
    /bids/_offer_bid.html.erb:7: syntax error, unexpected kENSURE, expecting $end  
    

    提前谢谢:)。

    1 回复  |  直到 15 年前
        1
  •  0
  •   Jordan Running    15 年前

    你的右括号 form_for 方法调用位于错误的位置。这应该可以解决它:

    <%= form_for([@post, @post.bids.build], { :url => { :action => "offer_bid" } }) do |f| %> 
      <%= f.submit "Offer Post to this user" %>
    <% end %>