# Why is map.root not calling action to set vars...?

**URL:** <https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428>\
**Category:** Rails\
**Created:** [June 17, 2009, 3:54pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428 "2009-06-17T15:54:35Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 17, 2009, 3:54pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428/1 "2009-06-17T15:54:35Z")

</div>

Hi All,

I’ve got a small problem with map.root in the following code:

```
 map.root :controller => "site_manager", :action => :index

```

It would appear that, for whatever reason, it isn’t calling the  
“index” action on my controller and my “@sites” var isn’t getting set  
for the view. It simply throws a “nil object” error. In the short  
term I’ve solved it with “@sites ||= Site.find(:all)” inside the  
view. Howevever, I’d like to know why it might be failing in the  
first place. Thoughts?

It is noteworthy that when I manually navigate to “/sitemanager” or “/  
site\_manager” everything works fine. It simply appears to be a  
map.root issue.

Best

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 17, 2009, 4:01pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428/2 "2009-06-17T16:01:03Z")

</div>

Have you deleted the index.html file under the public folder?

- 

Maurício Linhares  
[http://codeshooter.wordpress.com/](http://codeshooter.wordpress.com/) | [http://twitter.com/mauriciojr](http://twitter.com/mauriciojr)

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 17, 2009, 4:04pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428/3 "2009-06-17T16:04:00Z")

</div>

2009/6/17 gberz3 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi All,
> 
> I’ve got a small problem with map.root in the following code:
> 
> Â Â map.root :controller =\> “site\_manager”, :action =\> :index

Try removing the :action =\>:index specification (ie just spec the  
controller), or use “index” instead of :index. I don’t know why these  
would fix it but I have seen suggestions that they may.

Colin

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 17, 2009, 4:56pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428/4 "2009-06-17T16:56:15Z")

</div>

Yeah I deleted the “index” page. From the error it goes beyond that.

On Jun 17, 10:00 am, Maurício Linhares [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![dezrtdude](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f4b2a3/32.png) [@dezrtdude](https://www.ruby-forum.com/u/dezrtdude)\
**Post date:** [June 17, 2009, 4:59pm UTC](https://www.ruby-forum.com/t/why-is-map-root-not-calling-action-to-set-vars/170428/5 "2009-06-17T16:59:46Z")

</div>

Wow! That appears to have fixed it. I _know_ I tried that before.  
Oh well, thanks!
