2014-10-17 263 views
0

,我發現了錯誤:RoutingError (No route matches [GET] "/new_invitation"):RoutingError(無路由匹配[GET] Rails中

運行rake routes生產:

... 
    invitations GET /invitations(.:format)    invitations#index 
       POST /invitations(.:format)    invitations#create 
new_invitation GET /invitations/new(.:format)   invitations#new 
edit_invitation GET /invitations/:id/edit(.:format)  invitations#edit 
    invitation GET /invitations/:id(.:format)   invitations#show 
       PUT /invitations/:id(.:format)   invitations#update 
       DELETE /invitations/:id(.:format)   invitations#destroy 
... 

然而,有它在第3行任何想法

編輯

invitations_controller.rb包含...

def new 
    @invitation = Invitation.new (permitted_params.invitation) 
end 

def create 
    @invitation = Invitation.new(permitted_params.invitation) 
    if current_user 
     @invitation.sender = current_user 
     if @invitation.save 
     UserMailer.invitation(@invitation, register_url(@invitation.token)).deliver 
     flash[:notice] = "You have successfully sent the invitation." 
     redirect_to styleguide_path 
     else 
     render :action => 'new' 
     end 
    else 
    @invitation.sender = 0 
    if @invitation.save 
     UserMailer.invitation(@invitation, register_url(@invitation.token)).deliver 
     flash[:notice] = "Your request for an invitation has been processed. Please check your email for your invitation link." 
     redirect_to root_path 
    else 
     render :action => 'new' 
    end 
    end 

    end 

我試圖重命名控制器,模型和視圖模板,無濟於事。有任何想法嗎?

錯誤消息

Started GET "/new_invitation" for 127.0.0.1 at 2014-10-16 19:40:36 -0600 

ActionController::RoutingError (No route matches [GET] "/new_invitation"): 
+0

顯示詳細的錯誤信息.. – 2014-10-17 02:54:54

+0

上面添加.... – Matteo 2014-10-17 03:16:51

+1

你想'/請柬/ new'但你有'/ new_invitation'。你點擊了一個鏈接?你能告訴我一個鏈接嗎? – 2014-10-17 03:24:39

回答

0

試試這個(如果在同一個控制器腳本的位置)

$('#DialogPop').bPopup({ 
    loadUrl: '<%= url_for :action => 'new' %>', 
    modalClose: false 
}); 

或(建議)

$('#DialogPop').bPopup({ 
    loadUrl: '<%= new_invitation_path %>', 
    modalClose: false 
}); 

注:如果自定義在視圖中使用javascript或在使用的javascript文件中使用自定義javascriptextention

reference

+0

這很有效。只需將文件名更改爲: 'filename.js.erb' – Matteo 2014-10-17 03:51:36

相關問題