我收到此錯誤:Rails:如何解決ActionView :: MissingTemplate錯誤?
Started POST "/submitEmailAddress" for 127.0.0.1 at 2015-03-13 15:29:26 +0100
Processing by OnepagerController#submitEmailAddress as JS
Parameters: {"utf8"=>"✓", "email"=>"[email protected]", "commit"=>"OK, LET'S GO!"}
submitEmailAddress
Completed 500 Internal Server Error in 12ms
ActionView::MissingTemplate (Missing template onepager/submitEmailAddress, application/submitEmailAddress with {:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}. Searched in:
* "/Users/ola/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0/lib/action_dispatch/templates"
* "/Users/ola/Documents/RailsApps/newwp/app/views"
* "/Users/ola/.rvm/gems/ruby-2.2.0/gems/videojs_rails-4.6.1/app/views"
):
app/controllers/onepager_controller.rb:22:in `submitEmailAddress'
Rendered /Users/ola/.rvm/gems/ruby-2.2.0/gems/web-console-2.0.0/lib/action_dispatch/templates/rescues/missing_template.text.erb (0.3ms)
當我嘗試提交電子郵件這種形式:
(內index.html.erb)
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-6 col-sm-offset-3 col-xs-8 col-xs-offset-2">
<%= bootstrap_form_tag url: '/submitEmailAddress', remote: true, html: {class: 'emailForm'} do |f| %>
<%= f.email_field :email, hide_label: true %>
<%= f.submit "OK, LET'S GO!"%>
<% end %>
</div>
</div>
這裏是我的方法:
(在onepager_controller.rb)
def submitEmailAddress
puts "inside submitEmailAddress"
respond_to do |format|
format.html {redirect_to root_path}
format.js
end
end
這是我的路線:
(從我的routes.rb)
root 'onepager#index'
post 'submitEmailAddress', to: 'onepager#submitEmailAddress'
的我怎麼能解決這個錯誤,任何想法?
待辦事項存在onepager/submitEmailAddress模板? – 2015-03-13 14:53:58