# Strange routing(?) Issue

**URL:** <https://www.ruby-forum.com/t/strange-routing-issue/183547>\
**Category:** Rails\
**Created:** [February 16, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/strange-routing-issue/183547 "2010-02-16T12:04:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![badnaam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e36b37/32.png) [@badnaam](https://www.ruby-forum.com/u/badnaam)\
**Post date:** [February 16, 2010, 12:04pm UTC](https://www.ruby-forum.com/t/strange-routing-issue/183547/1 "2010-02-16T12:04:38Z")

</div>

I have a Model event and the following two lines in routes.rb

1 - map.connect “events/:action”, :controller =\> ‘events’, :action =\> /  
[a-z\_]+/i  
2 - map.resources :events, :has\_many =\> :comments, :has\_one  
=\> :address #, :collection =\> {:mapit =\> :get}

I have #1 so that I can call custom actions from a link\_to\_remote link  
from my index page t0 update a div.

\<%= link\_to\_remote “Map”, :method =\> “get”, :url =\> {:action =\>  
“mapit”, :controller =\> “events”} %\>

Please see controller and rake routes output below.

Here is the problem,

With both #1 and #2 line in routes.rb active, if I click the Map link  
nothing happens,  
I get a 404 ActiveRecord::RecordNotFound in EventsController#mapit

```
Couldn't find Event without an ID
```
 AND when I create a new

event i just get redirected back to events index page, no record gets  
saved.

If I uncomment the regular event route i.e. #1, then I still get the  
same error with the map link but now I can create and save new event  
records.

Any ideas?

the events controller

* * *

def mapit  
# render :text =\> “asit”  
respond\_to do  
format.js {  
render :update do |page|  
page.replace\_html “div\_map”, “

Map here

”  
end  
}  
end

```
end

def new
    @event = Event.new
    address = @event.build_address
    respond_to do |format|
        format.html # new.html.erb
        format.xml { render :xml => @event }
    end
end

# GET /events/1/edit
def edit
    @event = Event.find(params[:id])

end

def create
    @event = Event.new(params[:event])
    # @event.address = Address.new(params[:address])
    # @event.address.cr
    @event.user_id = current_user.id;
    respond_to do |format|
        if @event.save
            flash[:notice] = 'Event was successfully created.'
            format.html { redirect_to(@event) }
            format.xml { render :xml => @event, :status

```

=\> :created, :location =\> @event }  
else  
format.html { render :action =\> “new” }  
format.xml { render :xml =\> @event.errors, :status  
=\> :unprocessable\_entity }  
end  
end  
end

* * *

rake:routes output

* * *

change\_authorization\_rules GET /authorization\_rules/  
change(.:format)  
{:action=\>“change”, :controller=\>“authorization\_rules”}  
graph\_authorization\_rules GET /authorization\_rules/  
graph(.:format)  
{:action=\>“graph”, :controller=\>“authorization\_rules”}  
suggest\_change\_authorization\_rules GET /authorization\_rules/  
suggest\_change(.:format)  
{:action=\>“suggest\_change”, :controller=\>“authorization\_rules”}  
authorization\_rules GET /  
authorization\_rules(.:format)  
{:action=\>“index”, :controller=\>“authorization\_rules”}  
authorization\_usages GET /  
authorization\_usages(.:format)  
{:action=\>“index”, :controller=\>“authorization\_usages”}  
/  
events/:action  
{:controller=\>“events”}  
event\_comments GET /events/:event\_id/  
comments(.:format)  
{:action=\>“index”, :controller=\>“comments”}  
POST /events/:event\_id/  
comments(.:format)  
{:action=\>“create”, :controller=\>“comments”}  
new\_event\_comment GET /events/:event\_id/comments/  
new(.:format) {:action=\>“new”, :controller=\>“comments”}  
edit\_event\_comment GET /events/:event\_id/  
comments/:id/edit(.:format)  
{:action=\>“edit”, :controller=\>“comments”}  
event\_comment GET /events/:event\_id/  
comments/:id(.:format)  
{:action=\>“show”, :controller=\>“comments”}  
PUT /events/:event\_id/  
comments/:id(.:format)  
{:action=\>“update”, :controller=\>“comments”}  
DELETE /events/:event\_id/  
comments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“comments”}  
new\_event\_address GET /events/:event\_id/address/  
new(.:format) {:action=\>“new”, :controller=\>“addresses”}  
edit\_event\_address GET /events/:event\_id/address/  
edit(.:format) {:action=\>“edit”, :controller=\>“addresses”}  
event\_address GET /events/:event\_id/  
address(.:format)  
{:action=\>“show”, :controller=\>“addresses”}  
PUT /events/:event\_id/  
address(.:format)  
{:action=\>“update”, :controller=\>“addresses”}  
DELETE /events/:event\_id/  
address(.:format)  
{:action=\>“destroy”, :controller=\>“addresses”}  
POST /events/:event\_id/  
address(.:format)  
{:action=\>“create”, :controller=\>“addresses”}  
events GET /  
events(.:format)  
{:action=\>“index”, :controller=\>“events”}  
POST /  
events(.:format)  
{:action=\>“create”, :controller=\>“events”}  
new\_event GET /events/  
new(.:format)  
{:action=\>“new”, :controller=\>“events”}  
edit\_event GET /events/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“events”}  
event GET /  
events/:id(.:format)  
{:action=\>“show”, :controller=\>“events”}  
PUT /  
events/:id(.:format)  
{:action=\>“update”, :controller=\>“events”}  
DELETE /  
events/:id(.:format)  
{:action=\>“destroy”, :controller=\>“events”}  
login /  
login  
{:action=\>“new”, :controller=\>“user\_sessions”}  
logout /  
logout  
{:action=\>“destroy”, :controller=\>“user\_sessions”}  
user\_sessions GET /  
user\_sessions(.:format)  
{:action=\>“index”, :controller=\>“user\_sessions”}  
POST /  
user\_sessions(.:format)  
{:action=\>“create”, :controller=\>“user\_sessions”}  
new\_user\_session GET /user\_sessions/  
new(.:format)  
{:action=\>“new”, :controller=\>“user\_sessions”}  
edit\_user\_session GET /user\_sessions/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“user\_sessions”}  
user\_session GET /  
user\_sessions/:id(.:format)  
{:action=\>“show”, :controller=\>“user\_sessions”}  
PUT /  
user\_sessions/:id(.:format)  
{:action=\>“update”, :controller=\>“user\_sessions”}  
DELETE /  
user\_sessions/:id(.:format)  
{:action=\>“destroy”, :controller=\>“user\_sessions”}  
role\_users GET /roles/:role\_id/  
users(.:format)  
{:action=\>“index”, :controller=\>“users”}  
POST /roles/:role\_id/  
users(.:format)  
{:action=\>“create”, :controller=\>“users”}  
new\_role\_user GET /roles/:role\_id/users/  
new(.:format) {:action=\>“new”, :controller=\>“users”}  
edit\_role\_user GET /roles/:role\_id/users/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“users”}  
role\_user GET /roles/:role\_id/  
users/:id(.:format)  
{:action=\>“show”, :controller=\>“users”}  
PUT /roles/:role\_id/  
users/:id(.:format)  
{:action=\>“update”, :controller=\>“users”}  
DELETE /roles/:role\_id/  
users/:id(.:format)  
{:action=\>“destroy”, :controller=\>“users”}  
role\_assignments GET /roles/:role\_id/  
assignments(.:format)  
{:action=\>“index”, :controller=\>“assignments”}  
POST /roles/:role\_id/  
assignments(.:format)  
{:action=\>“create”, :controller=\>“assignments”}  
new\_role\_assignment GET /roles/:role\_id/assignments/  
new(.:format) {:action=\>“new”, :controller=\>“assignments”}  
edit\_role\_assignment GET /roles/:role\_id/  
assignments/:id/edit(.:format)  
{:action=\>“edit”, :controller=\>“assignments”}  
role\_assignment GET /roles/:role\_id/  
assignments/:id(.:format)  
{:action=\>“show”, :controller=\>“assignments”}  
PUT /roles/:role\_id/  
assignments/:id(.:format)  
{:action=\>“update”, :controller=\>“assignments”}  
DELETE /roles/:role\_id/  
assignments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“assignments”}  
roles GET /  
roles(.:format)  
{:action=\>“index”, :controller=\>“roles”}  
POST /  
roles(.:format)  
{:action=\>“create”, :controller=\>“roles”}  
new\_role GET /roles/  
new(.:format)  
{:action=\>“new”, :controller=\>“roles”}  
edit\_role GET /roles/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“roles”}  
role GET /  
roles/:id(.:format)  
{:action=\>“show”, :controller=\>“roles”}  
PUT /  
roles/:id(.:format)  
{:action=\>“update”, :controller=\>“roles”}  
DELETE /  
roles/:id(.:format)  
{:action=\>“destroy”, :controller=\>“roles”}  
user\_roles GET /users/:user\_id/  
roles(.:format)  
{:action=\>“index”, :controller=\>“roles”}  
POST /users/:user\_id/  
roles(.:format)  
{:action=\>“create”, :controller=\>“roles”}  
new\_user\_role GET /users/:user\_id/roles/  
new(.:format) {:action=\>“new”, :controller=\>“roles”}  
edit\_user\_role GET /users/:user\_id/roles/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“roles”}  
user\_role GET /users/:user\_id/  
roles/:id(.:format)  
{:action=\>“show”, :controller=\>“roles”}  
PUT /users/:user\_id/  
roles/:id(.:format)  
{:action=\>“update”, :controller=\>“roles”}  
DELETE /users/:user\_id/  
roles/:id(.:format)  
{:action=\>“destroy”, :controller=\>“roles”}  
user\_friendships GET /users/:user\_id/  
friendships(.:format)  
{:action=\>“index”, :controller=\>“friendships”}  
POST /users/:user\_id/  
friendships(.:format)  
{:action=\>“create”, :controller=\>“friendships”}  
new\_user\_friendship GET /users/:user\_id/friendships/  
new(.:format) {:action=\>“new”, :controller=\>“friendships”}  
edit\_user\_friendship GET /users/:user\_id/  
friendships/:id/edit(.:format)  
{:action=\>“edit”, :controller=\>“friendships”}  
user\_friendship GET /users/:user\_id/  
friendships/:id(.:format)  
{:action=\>“show”, :controller=\>“friendships”}  
PUT /users/:user\_id/  
friendships/:id(.:format)  
{:action=\>“update”, :controller=\>“friendships”}  
DELETE /users/:user\_id/  
friendships/:id(.:format)  
{:action=\>“destroy”, :controller=\>“friendships”}  
user\_friends GET /users/:user\_id/  
friends(.:format)  
{:action=\>“index”, :controller=\>“friends”}  
POST /users/:user\_id/  
friends(.:format)  
{:action=\>“create”, :controller=\>“friends”}  
new\_user\_friend GET /users/:user\_id/friends/  
new(.:format) {:action=\>“new”, :controller=\>“friends”}  
edit\_user\_friend GET /users/:user\_id/friends/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“friends”}  
user\_friend GET /users/:user\_id/  
friends/:id(.:format)  
{:action=\>“show”, :controller=\>“friends”}  
PUT /users/:user\_id/  
friends/:id(.:format)  
{:action=\>“update”, :controller=\>“friends”}  
DELETE /users/:user\_id/  
friends/:id(.:format)  
{:action=\>“destroy”, :controller=\>“friends”}  
user\_events GET /users/:user\_id/  
events(.:format)  
{:action=\>“index”, :controller=\>“events”}  
POST /users/:user\_id/  
events(.:format)  
{:action=\>“create”, :controller=\>“events”}  
new\_user\_event GET /users/:user\_id/events/  
new(.:format) {:action=\>“new”, :controller=\>“events”}  
edit\_user\_event GET /users/:user\_id/events/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“events”}  
user\_event GET /users/:user\_id/  
events/:id(.:format)  
{:action=\>“show”, :controller=\>“events”}  
PUT /users/:user\_id/  
events/:id(.:format)  
{:action=\>“update”, :controller=\>“events”}  
DELETE /users/:user\_id/  
events/:id(.:format)  
{:action=\>“destroy”, :controller=\>“events”}  
user\_articles GET /users/:user\_id/  
articles(.:format)  
{:action=\>“index”, :controller=\>“articles”}  
POST /users/:user\_id/  
articles(.:format)  
{:action=\>“create”, :controller=\>“articles”}  
new\_user\_article GET /users/:user\_id/articles/  
new(.:format) {:action=\>“new”, :controller=\>“articles”}  
edit\_user\_article GET /users/:user\_id/articles/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“articles”}  
user\_article GET /users/:user\_id/  
articles/:id(.:format)  
{:action=\>“show”, :controller=\>“articles”}  
PUT /users/:user\_id/  
articles/:id(.:format)  
{:action=\>“update”, :controller=\>“articles”}  
DELETE /users/:user\_id/  
articles/:id(.:format)  
{:action=\>“destroy”, :controller=\>“articles”}  
user\_comments GET /users/:user\_id/  
comments(.:format)  
{:action=\>“index”, :controller=\>“comments”}  
POST /users/:user\_id/  
comments(.:format)  
{:action=\>“create”, :controller=\>“comments”}  
new\_user\_comment GET /users/:user\_id/comments/  
new(.:format) {:action=\>“new”, :controller=\>“comments”}  
edit\_user\_comment GET /users/:user\_id/comments/:id/  
edit(.:format) {:action=\>“edit”, :controller=\>“comments”}  
user\_comment GET /users/:user\_id/  
comments/:id(.:format)  
{:action=\>“show”, :controller=\>“comments”}  
PUT /users/:user\_id/  
comments/:id(.:format)  
{:action=\>“update”, :controller=\>“comments”}  
DELETE /users/:user\_id/  
comments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“comments”}  
user\_assignments GET /users/:user\_id/  
assignments(.:format)  
{:action=\>“index”, :controller=\>“assignments”}  
POST /users/:user\_id/  
assignments(.:format)  
{:action=\>“create”, :controller=\>“assignments”}  
new\_user\_assignment GET /users/:user\_id/assignments/  
new(.:format) {:action=\>“new”, :controller=\>“assignments”}  
edit\_user\_assignment GET /users/:user\_id/  
assignments/:id/edit(.:format)  
{:action=\>“edit”, :controller=\>“assignments”}  
user\_assignment GET /users/:user\_id/  
assignments/:id(.:format)  
{:action=\>“show”, :controller=\>“assignments”}  
PUT /users/:user\_id/  
assignments/:id(.:format)  
{:action=\>“update”, :controller=\>“assignments”}  
DELETE /users/:user\_id/  
assignments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“assignments”}  
new\_user\_address GET /users/:user\_id/address/  
new(.:format) {:action=\>“new”, :controller=\>“addresses”}  
edit\_user\_address GET /users/:user\_id/address/  
edit(.:format) {:action=\>“edit”, :controller=\>“addresses”}  
user\_address GET /users/:user\_id/  
address(.:format)  
{:action=\>“show”, :controller=\>“addresses”}  
PUT /users/:user\_id/  
address(.:format)  
{:action=\>“update”, :controller=\>“addresses”}  
DELETE /users/:user\_id/  
address(.:format)  
{:action=\>“destroy”, :controller=\>“addresses”}  
POST /users/:user\_id/  
address(.:format)  
{:action=\>“create”, :controller=\>“addresses”}  
users GET /  
users(.:format)  
{:action=\>“index”, :controller=\>“users”}  
POST /  
users(.:format)  
{:action=\>“create”, :controller=\>“users”}  
new\_user GET /users/  
new(.:format)  
{:action=\>“new”, :controller=\>“users”}  
edit\_user GET /users/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“users”}  
deactivate\_user PUT /users/:id/  
deactivate(.:format)  
{:action=\>“deactivate”, :controller=\>“users”}  
activate\_user PUT /users/:id/  
activate(.:format)  
{:action=\>“activate”, :controller=\>“users”}  
user GET /  
users/:id(.:format)  
{:action=\>“show”, :controller=\>“users”}  
PUT /  
users/:id(.:format)  
{:action=\>“update”, :controller=\>“users”}  
DELETE /  
users/:id(.:format)  
{:action=\>“destroy”, :controller=\>“users”}  
comments GET /  
comments(.:format)  
{:action=\>“index”, :controller=\>“comments”}  
POST /  
comments(.:format)  
{:action=\>“create”, :controller=\>“comments”}  
new\_comment GET /comments/  
new(.:format)  
{:action=\>“new”, :controller=\>“comments”}  
edit\_comment GET /comments/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“comments”}  
comment GET /  
comments/:id(.:format)  
{:action=\>“show”, :controller=\>“comments”}  
PUT /  
comments/:id(.:format)  
{:action=\>“update”, :controller=\>“comments”}  
DELETE /  
comments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“comments”}  
article\_comments GET /articles/:article\_id/  
comments(.:format)  
{:action=\>“index”, :controller=\>“comments”}  
POST /articles/:article\_id/  
comments(.:format)  
{:action=\>“create”, :controller=\>“comments”}  
new\_article\_comment GET /articles/:article\_id/  
comments/new(.:format) {:action=\>“new”, :controller=\>“comments”}  
edit\_article\_comment GET /articles/:article\_id/  
comments/:id/edit(.:format) {:action=\>“edit”, :controller=\>“comments”}  
article\_comment GET /articles/:article\_id/  
comments/:id(.:format) {:action=\>“show”, :controller=\>“comments”}  
PUT /articles/:article\_id/  
comments/:id(.:format)  
{:action=\>“update”, :controller=\>“comments”}  
DELETE /articles/:article\_id/  
comments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“comments”}  
articles GET /  
articles(.:format)  
{:action=\>“index”, :controller=\>“articles”}  
POST /  
articles(.:format)  
{:action=\>“create”, :controller=\>“articles”}  
new\_article GET /articles/  
new(.:format)  
{:action=\>“new”, :controller=\>“articles”}  
edit\_article GET /articles/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“articles”}  
article GET /  
articles/:id(.:format)  
{:action=\>“show”, :controller=\>“articles”}  
PUT /  
articles/:id(.:format)  
{:action=\>“update”, :controller=\>“articles”}  
DELETE /  
articles/:id(.:format)  
{:action=\>“destroy”, :controller=\>“articles”}  
friendships GET /  
friendships(.:format)  
{:action=\>“index”, :controller=\>“friendships”}  
POST /  
friendships(.:format)  
{:action=\>“create”, :controller=\>“friendships”}  
new\_friendship GET /friendships/  
new(.:format)  
{:action=\>“new”, :controller=\>“friendships”}  
edit\_friendship GET /friendships/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“friendships”}  
friendship GET /  
friendships/:id(.:format)  
{:action=\>“show”, :controller=\>“friendships”}  
PUT /  
friendships/:id(.:format)  
{:action=\>“update”, :controller=\>“friendships”}  
DELETE /  
friendships/:id(.:format)  
{:action=\>“destroy”, :controller=\>“friendships”}  
assisgnments GET /  
assisgnments(.:format)  
{:action=\>“index”, :controller=\>“assisgnments”}  
POST /  
assisgnments(.:format)  
{:action=\>“create”, :controller=\>“assisgnments”}  
new\_assisgnment GET /assisgnments/  
new(.:format)  
{:action=\>“new”, :controller=\>“assisgnments”}  
edit\_assisgnment GET /assisgnments/:id/  
edit(.:format)  
{:action=\>“edit”, :controller=\>“assisgnments”}  
assisgnment GET /  
assisgnments/:id(.:format)  
{:action=\>“show”, :controller=\>“assisgnments”}  
PUT /  
assisgnments/:id(.:format)  
{:action=\>“update”, :controller=\>“assisgnments”}  
DELETE /  
assisgnments/:id(.:format)  
{:action=\>“destroy”, :controller=\>“assisgnments”}

root /  
{:action=\>“index”, :controller=\>“home”}  
/:controller/:action/:id  
/:controller/:action/:id(.:format)

* * *
