我有一个简单的应用程序,其中用户A可以添加优惠,用户B可以为这些优惠生成优惠券,我对编码和东西一无所知所以我雇用了一个为我创建了这个系统的程序员,一切正常很棒,但后来我在我的应用程序中集成了AWS,突然生成优惠券按钮停止工作,它在Localhost上工作正常,但在heroku上没有,我的程序员现在不在这里。
每当我点击按钮为此优惠生成优惠券时 它带我到一个页面说:
The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
我检查了heroku日志:
2016-05-06T04:10:50.409337+00:00 heroku[router]: at=info method=GET path="/offer
s/3/generate_coupon" host=www.taponomics.com request_id=e130f6c2-62c6-4a68-a4b8-
97daba3653ac fwd="103.51.151.184" dyno=web.1 connect=1ms service=8ms status=404
bytes=1829
2016-05-06T04:10:50.406339+00:00 app[web.1]: Started GET "/offers/3/generate_cou
pon" for 103.51.151.184 at 2016-05-06 04:10:50 +0000
2016-05-06T04:10:50.408178+00:00 app[web.1]: ActionController::RoutingError (No
route matches [GET] "/offers/3/generate_coupon"):
2016-05-06T04:10:50.408164+00:00 app[web.1]:
2016-05-06T04:10:50.408181+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:20:in `block in call'
2016-05-06T04:10:50.408184+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:20:in `call'
2016-05-06T04:10:50.408181+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:38:in `call_app'
2016-05-06T04:10:50.408186+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/runtime.rb:18:in `call'
2016-05-06T04:10:50.408184+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `tagged'
2016-05-06T04:10:50.408180+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2016-05-06T04:10:50.408187+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/static.rb:116:in `call'
2016-05-06T04:10:50.408179+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
2016-05-06T04:10:50.408189+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/engine.rb:518:in `call'
2016-05-06T04:10:50.408185+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2016-05-06T04:10:50.408188+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/sendfile.rb:113:in `call'
2016-05-06T04:10:50.408182+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2016-05-06T04:10:50.408183+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:26:in `tagged'
2016-05-06T04:10:50.408186+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/methodoverride.rb:22:in `call'
2016-05-06T04:10:50.408192+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
2016-05-06T04:10:50.408190+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/lock.rb:17:in `call'
2016-05-06T04:10:50.408194+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/server.rb:294:in `block in start_thread'
2016-05-06T04:10:50.408189+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/application.rb:165:in `call'
2016-05-06T04:10:50.408191+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/content_length.rb:15:in `call'
2016-05-06T04:10:50.408192+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/httpserver.rb:138:in `service'
2016-05-06T04:10:50.408193+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/httpserver.rb:94:in `run'
2016-05-06T04:10:50.408195+00:00 app[web.1]:
2016-05-06T04:10:50.408195+00:00 app[web.1]:
我的应用模态 offers.rb
class Offer < ActiveRecord::Base
has_attached_file :image, styles: { medium: "1280x720#" }, :default_url => "missing.jpg"
validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/
def generate_coupon
coupon = random_coupon
loop do
break unless Offer.match_coupon?(coupon)
coupon = random_coupon
end
coupon
end
private
def self.match_coupon?(coupon)
where(coupon: coupon).present?
end
def random_coupon
'CODE' + rand((1111..9999)).to_s
end
end
我的应用控制器 offers_controller.rb
class OffersController < InheritedResources::Base
def generate_coupon
@offer = Offer.find(params[:id])
@offer.update_attributes(coupon: @offer.generate_coupon) if @offer.coupon.blank?
end
private
def offer_params
params.require(:offer).permit(:name, :deal, :services, :address, :coupon, :image)
end
end
我的应用索引页 index.html.erb
<head>
<link href="/assets/bootstrap.min.css" rel="stylesheet">
<link href="/assets/font-awesome.min.css" rel="stylesheet">
<link href="/assets/offers.css" rel="stylesheet">
</head>
<body>
<div class="container-fluid">
<div class="text-center">
<h1>offers Around You</h1>
</div>
<p id="notice"><%= notice %></p>
<% @offers.each do |offer| %>
<div class="wrap ">
<h1><%= offer.name %></h1>
<h6><%= image_tag offer.image.url(:medium)%></h6>
<div class="text-center">
<h6> <%= offer.deal %></h6>
<%= button_to "View Details", offer, :method => "get", class: "btn btn-success" %>
</div>
<%klass = offer.coupon.blank? ? '' : 'offer-display'%>
<div class="row <%=klass%>" id="offer-<%=offer.id%>">
<% if offer.coupon.blank?%>
<%= link_to "Generate Coupon For This Offer", generate_coupon_offer_path(offer), method: :post, class: "btn btn-success", style: "margin-top: 20px; color: #fff", remote: true %>
<% else %>
<%= offer.coupon %>
<% end %>
</div>
</div>
<% end %>
</div>
</body>
generate_coupon.js.erb
$("#offer-<%=@offer.id%>").addClass('offer-display')
$("#offer-<%=@offer.id%>").html("<%=@offer.coupon%>")
我的路线
Rails.application.routes.draw do
resources :offers do
get '/offers/:id', to: 'offers#show'
member do
post 'generate_coupon'
end
end
end
dkp回答后更新日志
2016-05-06T04:28:59.463133+00:00 app[web.1]: ActionView::MissingTemplate (Missin
g template offers/generate_coupon, inherited_resources/base/generate_coupon, app
lication/generate_coupon with {:locale=>[:en], :formats=>[:html], :variants=>[],
:handlers=>[:erb, :builder, :raw, :ruby, :coffee, :arb, :jbuilder]}. Searched i
n:
2016-05-06T04:28:59.463134+00:00 app[web.1]: * "/app/app/views"
2016-05-06T04:28:59.463135+00:00 app[web.1]: * "/app/vendor/bundle/ruby/2.2.0/
gems/activeadmin-1.0.0.pre2/app/views"
2016-05-06T04:28:59.463136+00:00 app[web.1]: * "/app/vendor/bundle/ruby/2.2.0/
gems/mailboxer-0.13.0/app/views"
2016-05-06T04:28:59.463137+00:00 app[web.1]: * "/app/vendor/bundle/ruby/2.2.0/
gems/devise-3.5.9/app/views"
2016-05-06T04:28:59.463136+00:00 app[web.1]: * "/app/vendor/bundle/ruby/2.2.0/
gems/kaminari-0.16.3/app/views"
2016-05-06T04:28:59.463140+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/lookup_context.rb:121:in `find'
2016-05-06T04:28:59.463138+00:00 app[web.1]: ):
2016-05-06T04:28:59.463139+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/path_set.rb:46:in `find'
2016-05-06T04:28:59.463148+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/renderer/template_renderer.rb:8:in `render'
2016-05-06T04:28:59.463149+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/renderer/renderer.rb:42:in `render_template'
2016-05-06T04:28:59.463141+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/renderer/abstract_renderer.rb:18:in `find_template
'
2016-05-06T04:28:59.463141+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/renderer/template_renderer.rb:40:in `determine_tem
plate'
2016-05-06T04:28:59.463152+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/rendering.rb:32:in `render_to_body'
2016-05-06T04:28:59.463151+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/streaming.rb:217:in `_render_template'
2016-05-06T04:28:59.463150+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/renderer/renderer.rb:23:in `render'
2016-05-06T04:28:59.463150+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/rendering.rb:100:in `_render_template'
2016-05-06T04:28:59.463152+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/rendering.rb:83:in `render_to_body'
2016-05-06T04:28:59.463153+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/renderers.rb:37:in `render_to_body'
2016-05-06T04:28:59.463153+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/abstract_controller/rendering.rb:25:in `render'
2016-05-06T04:28:59.463155+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:44:in `block (2 lev
els) in render'
2016-05-06T04:28:59.463154+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/rendering.rb:16:in `render'
2016-05-06T04:28:59.463156+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
2016-05-06T04:28:59.463156+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
benchmark.rb:303:in `realtime'
2016-05-06T04:28:59.463157+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/core_ext/benchmark.rb:12:in `ms'
2016-05-06T04:28:59.463158+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view
_runtime'
2016-05-06T04:28:59.463157+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:44:in `block in ren
der'
2016-05-06T04:28:59.463159+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
iverecord-4.2.3/lib/active_record/railties/controller_runtime.rb:25:in `cleanup_
view_runtime'
2016-05-06T04:28:59.463159+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:43:in `render'
2016-05-06T04:28:59.463160+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/implicit_render.rb:10:in `default_rend
er'
2016-05-06T04:28:59.463161+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/abstract_controller/base.rb:198:in `process_action'
2016-05-06T04:28:59.463160+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
2016-05-06T04:28:59.463162+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
2016-05-06T04:28:59.463163+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
2016-05-06T04:28:59.463162+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/abstract_controller/callbacks.rb:20:in `block in process_actio
n'
2016-05-06T04:28:59.463168+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:553:in `block (2 levels) in com
pile'
2016-05-06T04:28:59.463168+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:115:in `call'
2016-05-06T04:28:59.463169+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
2016-05-06T04:28:59.463169+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:503:in `call'
2016-05-06T04:28:59.463174+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/abstract_controller/callbacks.rb:19:in `process_action'
2016-05-06T04:28:59.463174+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:88:in `run_callbacks'
2016-05-06T04:28:59.463175+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/rescue.rb:29:in `process_action'
2016-05-06T04:28:59.463175+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:32:in `block in pro
cess_action'
2016-05-06T04:28:59.463177+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrum
ent'
2016-05-06T04:28:59.463176+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/notifications.rb:164:in `block in instrument
'
2016-05-06T04:28:59.463177+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/notifications.rb:164:in `instrument'
2016-05-06T04:28:59.463178+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/instrumentation.rb:30:in `process_acti
on'
2016-05-06T04:28:59.463178+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/params_wrapper.rb:250:in `process_acti
on'
2016-05-06T04:28:59.463179+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
iverecord-4.2.3/lib/active_record/railties/controller_runtime.rb:18:in `process_
action'
2016-05-06T04:28:59.463180+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/abstract_controller/base.rb:137:in `process'
2016-05-06T04:28:59.463180+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionview-4.2.3/lib/action_view/rendering.rb:30:in `process'
2016-05-06T04:28:59.463181+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal.rb:196:in `dispatch'
2016-05-06T04:28:59.463181+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
2016-05-06T04:28:59.463182+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_controller/metal.rb:237:in `block in action'
2016-05-06T04:28:59.463182+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:76:in `call'
2016-05-06T04:28:59.463183+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:76:in `dispatch'
2016-05-06T04:28:59.463183+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:45:in `serve'
2016-05-06T04:28:59.463184+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/journey/router.rb:43:in `block in serve'
2016-05-06T04:28:59.463184+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:in `each'
2016-05-06T04:28:59.463185+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/journey/router.rb:30:in `serve'
2016-05-06T04:28:59.463185+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/routing/route_set.rb:821:in `call'
2016-05-06T04:28:59.463186+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/war
den-1.2.6/lib/warden/manager.rb:35:in `block in call'
2016-05-06T04:28:59.463187+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/war
den-1.2.6/lib/warden/manager.rb:34:in `catch'
2016-05-06T04:28:59.463188+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/etag.rb:24:in `call'
2016-05-06T04:28:59.463188+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/conditionalget.rb:25:in `call'
2016-05-06T04:28:59.463187+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/war
den-1.2.6/lib/warden/manager.rb:34:in `call'
2016-05-06T04:28:59.463189+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/head.rb:13:in `call'
2016-05-06T04:28:59.463190+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2016-05-06T04:28:59.463190+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/flash.rb:260:in `call'
2016-05-06T04:28:59.463191+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/session/abstract/id.rb:220:in `call'
2016-05-06T04:28:59.463191+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/session/abstract/id.rb:225:in `context'
2016-05-06T04:28:59.463192+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
iverecord-4.2.3/lib/active_record/query_cache.rb:36:in `call'
2016-05-06T04:28:59.463193+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
iverecord-4.2.3/lib/active_record/connection_adapters/abstract/connection_pool.r
b:653:in `call'
2016-05-06T04:28:59.463192+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/cookies.rb:560:in `call'
2016-05-06T04:28:59.463194+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2016-05-06T04:28:59.463194+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/callbacks.rb:84:in `run_callbacks'
2016-05-06T04:28:59.463195+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2016-05-06T04:28:59.463195+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
2016-05-06T04:28:59.463204+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2016-05-06T04:28:59.463206+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:38:in `call_app'
2016-05-06T04:28:59.463205+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2016-05-06T04:28:59.463206+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:20:in `block in call'
2016-05-06T04:28:59.463207+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:26:in `tagged'
2016-05-06T04:28:59.463207+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `block in tagged'
2016-05-06T04:28:59.463209+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2016-05-06T04:28:59.463209+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/rack/logger.rb:20:in `call'
2016-05-06T04:28:59.463208+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ivesupport-4.2.3/lib/active_support/tagged_logging.rb:68:in `tagged'
2016-05-06T04:28:59.463210+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/methodoverride.rb:22:in `call'
2016-05-06T04:28:59.463210+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/runtime.rb:18:in `call'
2016-05-06T04:28:59.463211+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/act
ionpack-4.2.3/lib/action_dispatch/middleware/static.rb:116:in `call'
2016-05-06T04:28:59.463211+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/sendfile.rb:113:in `call'
2016-05-06T04:28:59.463212+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/engine.rb:518:in `call'
2016-05-06T04:28:59.463212+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rai
lties-4.2.3/lib/rails/application.rb:165:in `call'
2016-05-06T04:28:59.463213+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/lock.rb:17:in `call'
2016-05-06T04:28:59.463215+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/httpserver.rb:138:in `service'
2016-05-06T04:28:59.463214+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/handler/webrick.rb:88:in `service'
2016-05-06T04:28:59.463214+00:00 app[web.1]: vendor/bundle/ruby/2.2.0/gems/rac
k-1.6.4/lib/rack/content_length.rb:15:in `call'
2016-05-06T04:28:59.463220+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/httpserver.rb:94:in `run'
2016-05-06T04:28:59.463221+00:00 app[web.1]: vendor/ruby-2.2.4/lib/ruby/2.2.0/
webrick/server.rb:294:in `block in start_thread'
2016-05-06T04:28:59.463222+00:00 app[web.1]:
2016-05-06T04:28:59.463221+00:00 app[web.1]:
的application.js
//= require bootstrap
//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require jquery-1.11.1
//= require jquery.easing.min
//= require_tree .
答案 0 :(得分:1)
<强>日志:强>
2016-05-06T04:10:50.406339+00:00 app[web.1]: Started GET "/offers/3/generate_cou
pon" for 103.51.151.184 at 2016-05-06 04:10:50 +0000
2016-05-06T04:10:50.408178+00:00 app[web.1]: ActionController::RoutingError (No
route matches [GET] "/offers/3/generate_coupon"):
您正在发出GET
个请求,但您已在路由中指定提供POST
请求。
修改强>
您的OffersController
generate_coupon
操作实际更新了属性,因此请将您的路线更改为put
(请参阅下面的路线更改):
<强>路由强>
resources :offers do
get '/offers/:id', to: 'offers#show'
member do
put 'generate_coupon'
end
end
将method: :put
添加到link_to
:
<%= link_to "Generate Coupon For This Offer", generate_coupon_offer_path(offer), method: :put, class: "btn btn-success", style: "margin-top: 20px; color: #fff", remote: true %>
为了处理ActionView::MissingTemplate (Missin
g template offers/generate_coupon
问题,
确保您在views/offers/generate_coupon.js.erb
<强>的application.js 强>
//= require jquery
//= require jquery_ujs
//= require bootstrap
//= require jquery.turbolinks
//= require jquery.easing.min
//= require_tree .
答案 1 :(得分:0)
用两种不同的方法完成工作。一个用于显示数据,另一个用于更新记录。
def show
@offer = Offer.find(params[:id])
end
def create
@offer.update_attributes(coupon: @offer.generate_coupon) if
@offer.coupon.blank?
end
将该js文件更改为create.js.erb
。
只需明确并将方法与资源分开,看看它是否完美运行。让我知道进展情况。