开发者

Help need: Syntax error on trying to force the form_for 's action method to a specific one

开发者 https://www.devze.com 2023-01-23 17:50 出处:网络
<%= form_for([@post, @post.bids.build]), :url => { :action => \"offer_bid\" } do |f| %> <%= f.submit \"Offer Post to this user\" %>
 <%= form_for([@post, @post.bids.build]),  
 :url => { :action => "offer_bid" } do |f| %>  
    <%= f.submit "Offer Post to this user" %>  
 <% end %>    

I'm trying to use the above form to update one particular column of bid model( bid is a model nested under post) :-

resources :posts do
    resources :bids
end

I already have form for creating a new row of bid model.

Now I'm adding one more 开发者_Go百科form for the same model - bid to do some manipulations.

But I'm getting the following syntax error on trying to use the above form. :-

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  

Thanks in advance :).

I'm using Rails 3.0.1.


Your closing parenthesis on your form_for method call was in the wrong place. This should fix it:

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

精彩评论

暂无评论...
验证码 换一张
取 消