Topic: not working after renaming .rjs to .js.erb (solved)

I renamed my files from .rjs to .js.erb, but it doesn't seem to work.  I'm sure I'm missing something pretty basic.

This is what I have in my controller:
    respond_to do |format|
      format.html
      format.js
    end

I also renamed .rhtml files to .html.erb which works fine... Anyone have issues with .js.erb naming?

Last edited by sthapit (2007-12-07 13:17:55)

Re: not working after renaming .rjs to .js.erb (solved)

I believe that you will need to name your files to .js.rjs not .js.erb. I had this same problem. When named ".js.erb" all of my js templates rendered as strings.

Re: not working after renaming .rjs to .js.erb (solved)

thanks.  renaming to .js.rjs works.  but it doesn't make sense to me...

i can understand how renaming from .rhtml to .html.erb makes sense.  but i don't understand why the switch was made to rename .rjs to .js.rjs to begin with.

Re: not working after renaming .rjs to .js.erb (solved)

well the switch is just done to keep stuff in the same format as other templates.

*.html.erb -> response format HTML, Parsed with ERB
*.html.haml -> response format HTML, Parsed with HAML
*.js.rjs -> response format JavaScript, "parsed" with RJS (making page object avaliable to the code etc.)
someone could write a plugin to do some crazy javascript tricks and this could be handled with:
*.js.crazystuff

Rails is all about convention, so it wouldn't make sense to make an exception from the naming scheme for RJS templates.

Re: not working after renaming .rjs to .js.erb (solved)

thanks duplex smile  makes sense now.