ユーザ側から管理画面へのURLをフルパスで表示したいのだが、
意外とハマったので、備忘録としてメモ。
routes.rb
scope :admin do
resources :inquiries, only: [:show]
end
管理画面へのroutes
# rake routes | grep inquiries
admin_inquiry_path GET /admin/inquiries/:id(.:format) admin/inquiries#show
ユーザ側で表示するには、下記でOK
<%= url_for(admin_inquiry_path @id, host: 'localhost', only_path: false, protocol: :http, port: (Rails.env.development? ? 3000 : nil)) %>
[参考URL]
http://stackoverflow.com/questions/20057910/rails-url-for-behaving-differently-when-using-namespace-based-on-current-cont
http://apidock.com/rails/ActionController/Base/url_for