# No route found to match "/search" with {:method=\>:get}

**URL:** <https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563>\
**Category:** Rails\
**Created:** [September 1, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563 "2007-09-01T20:26:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 1, 2007, 8:26pm UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/1 "2007-09-01T20:26:42Z")

</div>

Hi,

I have posted this before on another site with no help so I’m hoping I  
will get it here:

am a bit new to the whole RoR thing and have faced small problem,  
but was not able to fine related answer to my specific condition. I am  
writing an application called site which I want to be the default root  
application. I did the required configuration in routes.rb file.

Problem is, on the main page, I have a GET form that does not wrap  
object model, and has an id. I tried manual HTML and it didn’t work  
when I am visiting the site from [http://localhost:3000](http://localhost:3000) because the  
action ‘search’ will point to non-existing action on that level,  
yielding error:

no route found to match “/search” with {:method=\>:get}

if I go to [http://localhost:300/site/index](http://localhost:300/site/index) and do the search it works  
fine. I tried the form\_tag and it also didn’t help. Any idea how I can  
overcome this issue?

---

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 1, 2007, 10:04pm UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/2 "2007-09-01T22:04:57Z")

</div>

Salam Bashar,

I dont exactly understand your problem, but show us some code from your  
main controller which would be in this case.

site / index

---

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 2, 2007, 6:43am UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/3 "2007-09-02T06:43:58Z")

</div>

Salam Jamal,

There is nothing much to see in the controller, but rather here is a  
snippet from the view index generating the GET request:

```
 <form id="searchbox_012963" action="search">
  <input name="q" type="text" size="40" />
  <input type="submit" name="sa" value="Search" />
</form>

```

Now problem is when I visit the index page on  
[http://localhost:3000/site/index](http://localhost:3000/site/index) the action works just fine. But if I  
use the root mapping, [http://localhost:3000](http://localhost:3000) and then do the search, it  
will complain that there is no route found for GET on /search.

---

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 2, 2007, 1:56pm UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/4 "2007-09-02T13:56:54Z")

</div>

you are missing the slash in front of search, it should be:

not

/Jonas

On 2 Sep, 06:43, Bashar A. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 2, 2007, 9:16am UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/5 "2007-09-02T09:16:59Z")

</div>

Bashar A. wrote:

> Salam Jamal,
> 
> There is nothing much to see in the controller, but rather here is a  
> snippet from the view index generating the GET request:
> 
> ```
> <form id="searchbox_012963" action="search">
> <input name="q" type="text" size="40" />
> <input type="submit" name="sa" value="Search" />
> </form>
> 
> ```
> 
> Now problem is when I visit the index page on  
> [http://localhost:3000/site/index](http://localhost:3000/site/index) the action works just fine. But if I  
> use the root mapping, [http://localhost:3000](http://localhost:3000) and then do the search, it  
> will complain that there is no route found for GET on /search.

Well, you need to point it in the right direction.

did you create route for /search?

or you could do this

action=“site/search”

---

<div class="post-metadata">

**Author:** ![bashar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/b9bd4f/32.png) [@bashar](https://www.ruby-forum.com/u/bashar)\
**Post date:** [September 2, 2007, 2:18pm UTC](https://www.ruby-forum.com/t/no-route-found-to-match-search-with-method-get/113563/6 "2007-09-02T14:18:56Z")

</div>

Thanks Jonas. I tried that before it didn’t work. The solution from  
Jamal and Alexey worked.
