我不明白
在 routes.rb 我写过
match 'promotions/:id/purchase' => 'promotions#purchase', :as => :purchase_promo
在promotions_controller.rb 我添加了:
def purchase
@promotion = Promotion.find(params[:id])
respond_to do |format|
format.html # purchase.html.erb
format.json { render json: @promotion }
end
end
并在视图促销中创建一个文件 purchase.erb.html
<div data-role="page" id="acquisto">
<div data-role="header" data-theme="e">
<h1>Purchase?</h1>
</div><!-- /header -->
<div data-role="content" data-theme="d">
<h4>This promo costs <%= @promotion.price %> .</h4>
<p>bla bla bla bla bla bla bla bla bla.</p>
<a href="index.html" data-role="button" data-rel="back" data-theme="b">Purchase album</a>
<a href="index.html" data-role="button" data-rel="back">No thanks</a>
</div>
</div><!-- /page -->
在另一页写
<%= link_to 'Buy Promo',:purchase_promo ,'data-rel'=>'dialog',' data-transition'=>'slideup' %>
怎么了?
我收到路由错误
没有路线匹配 {:controller=>"promotions", :action=>"purchase"}