私は最近、私のレールアプリに名前空間を追加しました。私は所有者に電子メールを送るフォームを持っていたが、プロセスで壊れているようだ(最下部のエラー)。フォームはモデルを持っていない、それはちょうど電子メールをキックオフ。ここでモデルのないフォーム、名前空間に追加
は私のルートは
scope ":locale", locale: /#{I18n.available_locales.join("|")}/ do
namespace :admin do
resources :email_owners do
collection do
get :email
get :islas
post :email
post :islas
end
end
end
match "*path", to: "sites#not_found" # handles /en/fake/path/whatever
end
root to: redirect("/#{I18n.default_locale}") # handles/
match '*path', to: redirect("/#{I18n.default_locale}/%{path}")
end
すくいルートの出力CONTROLLER =管理者/ email_owners
email_admin_email_owners GET /:locale/admin/email_owners/email(.:format) {:locale=>/en|es/, :action=>"email", :controller=>"admin/email_owners"}
islas_admin_email_owners GET /:locale/admin/email_owners/islas(.:format) {:locale=>/en|es/, :action=>"islas", :controller=>"admin/email_owners"}
POST /:locale/admin/email_owners/email(.:format) {:locale=>/en|es/, :action=>"email", :controller=>"admin/email_owners"}
POST /:locale/admin/email_owners/islas(.:format) {:locale=>/en|es/, :action=>"islas", :controller=>"admin/email_owners"}
admin_email_owners GET /:locale/admin/email_owners(.:format) {:locale=>/en|es/, :action=>"index", :controller=>"admin/email_owners"}
POST /:locale/admin/email_owners(.:format) {:locale=>/en|es/, :action=>"create", :controller=>"admin/email_owners"}
new_admin_email_owner GET /:locale/admin/email_owners/new(.:format) {:locale=>/en|es/, :action=>"new", :controller=>"admin/email_owners"}
edit_admin_email_owner GET /:locale/admin/email_owners/:id/edit(.:format) {:locale=>/en|es/, :action=>"edit", :controller=>"admin/email_owners"}
admin_email_owner GET /:locale/admin/email_owners/:id(.:format) {:locale=>/en|es/, :action=>"show", :controller=>"admin/email_owners"}
PUT /:locale/admin/email_owners/:id(.:format) {:locale=>/en|es/, :action=>"update", :controller=>"admin/email_owners"}
DELETE /:locale/admin/email_owners/:id(.:format) {:locale=>/en|es/, :action=>"destroy", :controller=>"admin/email_owners"}
アプリ/コントローラ/管理/ email_owners.rb
class Admin::EmailOwnersController < Admin::BaseController
def email
owner_type = params[:owner_type]
subject = params[:subject]
message = params[:message]
owners = User.owners
owners.each do |owner|
OwnerMailer.all_owners(owner, subject, message).deliver
end
flash[:notice] = "Email has been sent to all Owners"
redirect_to admin_sites_path
end
end
、ここでファイルであります問題はどこにあるの?
<%= form_tag [:admin, email_admin_email_owners_path] do %>
To:
<%= radio_button_tag "owner_type", "All" %> All Owners |
<%= radio_button_tag "owner_type", "FullTime" %> FullTime |
<%= radio_button_tag "owner_type", "PartTime" %> PartTime<br />
<%= text_field_tag "subject", "Subject" %><br />
<%= text_area_tag "message", "Message" %><br />
<%= submit_tag "Send Email" %>
<% end %>
私はルート/パス
に行くたびます(http:// localhostを:3000/EN /管理/ email_owners /メール)
私は
undefined method `admin_/en/admin/email_owners/email_path' for #<#<Class:0x789db30>:0x789ab78>
エラーが発生します。しかしなぜ私は分からない。何か案は?私は間違った道を呼んでいますか?おかげ
てみてください。<%= form_tag email_admin_email_owners_path DO%> – iverds
undifined方法であるあなたに
admin_/en/admin/email_owners/email_path
を与えますそれはうまくいきました。それを回答として投稿しますか? – ruevaughn