# Writing new controllers

**URL:** <https://www.ruby-forum.com/t/writing-new-controllers/147494>\
**Category:** Rails\
**Created:** [September 2, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494 "2008-09-02T14:41:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 2:41pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/1 "2008-09-02T14:41:32Z")

</div>

I have created new rails-project.  
I start Mongrel.

I add to project:

## app/controllers/my\_first\_controller.rb

class MyFirstController \< ApplicationController  
def index  
render :text =\> ‘My First Controller’  
end  
end

[http://192.168.1.1:8080/my\_first/](http://192.168.1.1:8080/my_first/) → all OK!

Then, I add:

## app/controllers/my\_second\_controller.rb

class MySecondController \< ApplicationController  
def index  
render :text =\> ‘My Second Controller’  
end  
end

I open:  
[http://192.168.1.1:8080/my\_second/](http://192.168.1.1:8080/my_second/)

And I have error:  
No route matches “/my\_second/” with {:method=\>:get}

Why?

P.S.: Tested under Mongrel, Thin, Passenger, fastcgi

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 2:51pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/2 "2008-09-02T14:51:31Z")

</div>

## I work in development-mode. My routes.rb:

ActionController::Routing::Routes.draw do |map|  
map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’  
end

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 2:57pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/3 "2008-09-02T14:57:23Z")

</div>

On Tue, Sep 2, 2008 at 2:50 PM, veejar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ## I work in development-mode. My routes.rb:
> 
> ActionController::Routing::Routes.draw do |map|  
> map.connect ‘:controller/:action/:id’  
> map.connect ‘:controller/:action/:id.:format’  
> end  
> –~–~---------~–~----~------------~-------~–~----~

I guess you need to restart your server 😉

–  
Staf Wagemakers - [http://www.wagemakers.be](http://www.wagemakers.be)

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/4 "2008-09-02T15:06:11Z")

</div>

But why? It’s inconveniently!

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 3:25pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/5 "2008-09-02T15:25:32Z")

</div>

But I write not new route. I write new controller.

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 3:20pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/6 "2008-09-02T15:20:16Z")

</div>

routes.rb is cached for performance reasons, this might be the  
problem…

–  
Staf Wagemakers - [http://www.wagemakers.be](http://www.wagemakers.be)

2008/9/2 veejar [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![avanetix](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/838e76/32.png) [@avanetix](https://www.ruby-forum.com/u/avanetix)\
**Post date:** [September 2, 2008, 3:49pm UTC](https://www.ruby-forum.com/t/writing-new-controllers/147494/7 "2008-09-02T15:49:02Z")

</div>

Do you restart your project when you added the “my\_second\_controller” ?

The Route will be initialized at start.

2008-09-02

zheng.cuizh

å‘ä»¶äººï¼š veejar  
å‘é€æ—¶é—´ï¼š 2008-09-02 20:41:24  
æ”¶ä»¶äººï¼š Ruby on Rails: Talk  
æŠ„é€ï¼š  
ä¸»é¢˜ï¼š [Rails] Writing new controllers

I have created new rails-project.  
I start Mongrel.

I add to project:

## app/controllers/my\_first\_controller.rb

class MyFirstController \< ApplicationController  
def index  
render :text = \> ’ My First Controller

' end end

[http://192.168.1.1:8080/my\_first/](http://192.168.1.1:8080/my_first/) - \> all OK!

Then, I add:

## app/controllers/my\_second\_controller.rb

class MySecondController \< ApplicationController  
def index  
render :text = \> ’ My Second Controller

' end end

I open:  
[http://192.168.1.1:8080/my\_second/](http://192.168.1.1:8080/my_second/)

And I have error:  
No route matches “/my\_second/” with {:method= \>:get}

Why?

P.S.: Tested under Mongrel, Thin, Passenger, fastcgi

–~–~---------~–~----~------------~-------~–~----~  
You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en)  
-~----------~----~----~----~------~----~------~–~—
