メンバーシップコントローラー内にカスタムアクションを作成し、そのreq
ルートを定義しましたが、link_toでそのカスタムアクションへのパスを指定すると、不明なアクション、アクション'show'がMembershipsController.Iで見つかりませんでしたというエラーが表示されます。 dnyは、カスタムアクションへのパスを指定しているときに、showactionが見つかる理由を理解しています。
以下は、メンバーシップコントローラー内のカスタムアクションです
def req
@user =User.find_by_email(params[:email])
@group =params[:group_id]
unless @group.nil?
if Membership.request(@user.id, @group)
redirect_to :back, :notice => 'Joined successfully.'
else
redirect_to :back, :notice => 'couldnot Joine.'
end
end
end
メンバーシップコントローラー内に表示アクションはありません。
以下は私のカスタムアクションのルートです:
resources :memberships do
collection do
post 'req'
end
end
groups/show.html.haml
以下は、カスタムアクションのパスを指定している私の内部のコードです。
- if @collegemates.empty?
%p.info You have no common collegemates ...
- else
%table.datatable
%thead
%tr
...
%tbody
- @collegemates.each do |c|
- unless Membership.group_member(c.id, @group)
%tr
%td= c.full_name
%td= c.email
%td= link_to "request to join",{:controller => :memberships, :action => "req",:email =>c.email,:group_id => @group.id},:method => "post"
参加のリクエストをクリックすると、showactionの不明なアクションエラーが発生します。私はここで何が間違っているのですか?