# Javascripts controller Not Called

**URL:** <https://www.ruby-forum.com/t/javascripts-controller-not-called/138845>\
**Category:** Rails\
**Created:** [May 28, 2008, 9:59am UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845 "2008-05-28T09:59:19Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 28, 2008, 9:59am UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/1 "2008-05-28T09:59:19Z")

</div>

I am trying to make a javascripts controller work. The only resource I  
can find on this is here : [#88 Dynamic Select Menus - RailsCasts](http://railscasts.com/episodes/88)

I have tried everything in the tutorial and the comments including May  
22 08 comment by “pi\_p master” for respond\_to do format etc. and here  
is my predicament; my application works on my development machine just  
fine; when I transport the application to my production environment it  
does not call the javascripts controller; I have the following error :

1 2 3404 Not Found 4 5
# Not Found
6

The requested URL /javascripts/dynamic\_units.js was not found on this server.

7 Now I have even tried putting in explicitly map.connect ':controller/:action.:format' as well as : map.js '/javascripts/ dynamic\_units.js' , :controller=\>'javascripts', :action =\>'dynamic\_units' and whatever permutation I could fathom but to no avail. I know the dynamic\_units method in javascripts\_controller is not called because the logger never outputs any lines.

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 28, 2008, 10:44am UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/2 "2008-05-28T10:44:13Z")

</div>

On 28 May 2008, at 05:00, A. Shiraz wrote:

> does not call the javascripts controller; I have the following error :  
> What is your production environment (eg are there some rewrite rules  
> (explicit, or implicit (mod\_rails does do this, although I don’t know  
> exactly what rewrites it adds) that mean that your rails code is never  
> called?)

Fred

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 28, 2008, 11:17pm UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/3 "2008-05-28T23:17:43Z")

</div>

Frederick C. wrote:

> On 28 May 2008, at 05:00, A. Shiraz wrote:
> 
> > does not call the javascripts controller; I have the following error :  
> > What is your production environment (eg are there some rewrite rules  
> > (explicit, or implicit (mod\_rails does do this, although I don’t know  
> > exactly what rewrites it adds) that mean that your rails code is never  
> > called?)
> 
> Fred

Ok it was an issue with Apache configuration. I had to comment out a  
line in its httpd ssl conf file that was causing apache to serve a  
javascript directory statically and bypassing the appserver (mongrel).

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 29, 2008, 5:27am UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/4 "2008-05-29T05:27:01Z")

</div>

I’m trying to do this now as well. Even in my development machine it  
says that the js file doesn’t exist. Ryan B. said in the podcast  
though that if it doesn’t find the static file, it will then go to the  
controller. So, it shouldn’t have been because of the apache config  
right?

On Thu, May 29, 2008 at 5:17 AM, Ather S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > Fred
> 
> Ok it was an issue with Apache configuration. I had to comment out a  
> line in its httpd ssl conf file that was causing apache to serve a  
> javascript directory statically and bypassing the appserver (mongrel).

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 29, 2008, 12:38pm UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/5 "2008-05-29T12:38:00Z")

</div>

On 29 Mai, 05:26, “Ramon Miguel M. Tayag” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m trying to do this now as well. Even in my development machine it  
> says that the js file doesn’t exist. Ryan B. said in the podcast  
> though that if it doesn’t find the static file, it will then go to the  
> controller. So, it shouldn’t have been because of the apache config  
> right?

Nope. What Ryan meant was that the Rails Application server will serve  
the static file if it exists, and if not, go to the controller. This  
decision is done by Rails, so it has to be done on the acutal app  
server like mongrel.

If you let apache serve the static files, and proxy all other requests  
to mongrel, the call for this URL will never reach your mongrel as  
apache sees it as a requests to a static file. Long story cut short:  
If you would run on mongrel directly, it should work. if you have a  
frontend server that serves static content, it won’t.

You can easily circumvent it by not naming the controller  
JavascriptsController, but something else e.g.  
DynjavascriptsController. That way, apache can still serve the real  
static js files, while the dynamic js files are handled by rails.

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 29, 2008, 3:59pm UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/6 "2008-05-29T15:59:15Z")

</div>

I see. It’s working now in development environment, i had to add a  
route for it! I must’ve missed that his in screencast.

Thanks for the clarification!

You’re suggestion sounds right, and I’ll change the name of my  
controller so I won’t run into problems while in production.

On Thu, May 29, 2008 at 6:37 PM, Thorsten [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> You can easily circumvent it by not naming the controller  
> JavascriptsController, but something else e.g.  
> DynjavascriptsController. That way, apache can still serve the real  
> static js files, while the dynamic js files are handled by rails.
> 
> >

–  
Ramon T.

---

<div class="post-metadata">

**Author:** ![ror\_arch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e19adc/32.png) [@ror\_arch](https://www.ruby-forum.com/u/ror_arch)\
**Post date:** [May 29, 2008, 10:42am UTC](https://www.ruby-forum.com/t/javascripts-controller-not-called/138845/7 "2008-05-29T10:42:23Z")

</div>

On 29 May 2008, at 04:26, Ramon Miguel M. Tayag wrote:

> I’m trying to do this now as well. Even in my development machine it  
> says that the js file doesn’t exist. Ryan B. said in the podcast  
> though that if it doesn’t find the static file, it will then go to the  
> controller. So, it shouldn’t have been because of the apache config  
> right?

Who is saying the file doesn’t exist (apache, mongrel, something  
else?) what is your development setup

Fred
