我创建了一个邮件程序,用于在创建对象时发送电子邮件。电子邮件发送正常。
这是模板:
<h4>A new poll was created, <%= @poll.question %></h4>
Check it at <%= polls_url(@poll) %>
<p>Have a great day!</p>
我收到的电子邮件的结果是:
A new poll was created, Question?
Check it at http://example.com/polls.88
Have a great day!
下面是我的routes.rb
:
Rails.application.routes.draw do
resources :bugs
resources :projects do
resources :project_lines do
post 'accept', :on => :member
post 'start', :on => :member
post 'complete', :on => :member
post 'approve', :on => :member
post 'pay', :on => :member
end
end
resources :projects do
resources :project_expenses do
post 'approve', :on => :member
post 'pay', :on => :member
end
end
resources :clients
get 'poll_excluded_users/create'
resources :polls do
resources :comments
collection { post :import }
end
resources :comments do
resources :comments
end
devise_for :users, :path_prefix => 'd'
root to: "polls#open_polls"
end
为什么将网址设置为polls.88
而不是polls/88
?我该如何解决?
答案 0 :(得分:0)
如果您运行rake routes
或rails routes
来查看路由,则显示
poll_comments GET /polls/:poll_id/comments(.:format) comments#index
POST /polls/:poll_id/comments(.:format) comments#create
new_poll_comment GET /polls/:poll_id/comments/new(.:format) comments#new
edit_poll_comment GET /polls/:poll_id/comments/:id/edit(.:format) comments#edit
poll_comment GET /polls/:poll_id/comments/:id(.:format) comments#show
PATCH /polls/:poll_id/comments/:id(.:format) comments#update
PUT /polls/:poll_id/comments/:id(.:format) comments#update
DELETE /polls/:poll_id/comments/:id(.:format) comments#destroy
import_polls POST /polls/import(.:format) polls#import
polls GET /polls(.:format) polls#index
POST /polls(.:format) polls#create
new_poll GET /polls/new(.:format) polls#new
edit_poll GET /polls/:id/edit(.:format) polls#edit
poll GET /polls/:id(.:format) polls#show
PATCH /polls/:id(.:format) polls#update
PUT /polls/:id(.:format) polls#update
DELETE /polls/:id(.:format) polls#destroy
这意味着您的单poll
展示路径位于
poll GET /polls/:id(.:format) polls#show
然后它将是电子邮件模板poll_url
它不是polls_url
,它会显示(poll_url)
这样的内容www.example.com/pools/88