0

I'm getting the error: RoutingError (No route matches [GET] "/new_invitation"):.

Running rake routes produces:

...
    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
...

Yet there it is in line 3. Any ideas?

EDIT

The invitations_controller.rb contains...

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

I have tried renaming the controller, model and view templates, to no avail. Any ideas?

Error Message

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"):
Matteo
  • 1,136
  • 1
  • 16
  • 36
  • Show the detailed error messages.. – rails_id Oct 17 '14 at 02:54
  • 1
    You want to get `/invitations/new` but you got `/new_invitation`. Did you clicked a link? can you show me a link. – rails_id Oct 17 '14 at 03:24
  • The link comes through a custom javascript call to a popup generator that loads the form. The relevant js code is: `$('#DialogPop').bPopup({loadUrl:'/new_invitation', modalClose: false});` – Matteo Oct 17 '14 at 03:28

1 Answers1

0

try this (if the location of script on same controller)

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

Or (recommend)

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

note : If a custom javascript in a view or a custom javascript in javascript file with .js.erb extention

reference

Community
  • 1
  • 1
rails_id
  • 8,120
  • 4
  • 46
  • 84