Javascript requests not being routed properly

I have a file in views/admin/contents/new.js that I would like to be
returned on a request from a script tag ex:

If I test out the js request manually, ie entering the js url in the
browser, I get the error shown below:

Template is missing

Missing layout layouts/admin.js.erb in view path
/Users/chris/Documents/Projects/Rails/test_proj/app/views


It is Missing layout layouts/admin.js.erb that I don’t understand.
Why is this being routed in this way? It should be
admin/views/contents/new.js.

Thanks for the help.

iso … wrote:

I have a file in views/admin/contents/new.js that I would like to be
returned on a request from a script tag ex:

If I test out the js request manually, ie entering the js url in the
browser, I get the error shown below:

Template is missing

Missing layout layouts/admin.js.erb in view path
/Users/chris/Documents/Projects/Rails/test_proj/app/views


It is Missing layout layouts/admin.js.erb that I don’t understand.
Why is this being routed in this way? It should be
admin/views/contents/new.js.

Thanks for the help.

I should add that I have no problem obtaining the js files if they are
not nested in a route, ie.

map.namespace do |admin|
admin.resources :content_files
end

allows me to fetch the new js template file from
views/admin/content_files/new.js.erb

Has anyone else had this problem?

Hi,

I have a similar problem when I use
layout “alternative_layout”
in one of my controllers that needs to call ajax with a template like
“mytemplate.js.erb”.

Then when running from localhost:3000, it tells me that
“alternative_layout.js.erb” is missing. I think the correct template
should be “mytemplate.js.erb”, and it is there. I can’t figure out why
it tells me that “alternative_layout.js.erb” is missing.

My ugly solution is just copy “mytemplate.js.erb” to
“alternative_layout.js.erb”, and then it works fine.

Have you found a better solution?

Thanks.

On Mar 15, 11:50 pm, __iso __ [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs