This project is archived and is in readonly mode.

#6076 ✓wontfix
Neeraj Singh

.js files fallback on .html if view is missing

Reported by Neeraj Singh | November 28th, 2010 @ 02:45 AM | in 3.x

Notice that in the below given case I do NOT have index.js.erb.

  def index
    @users = User.all
    respond_to do |format|
      format.js  { render }
    end
  end

  #views
  index.html.erb (present)
  index.js.erb (not present)

Now if I request http://localhost:3000/users.js then I do not get template missing error. Rather I get index.html.erb file. And that is because of this code https://github.com/rails/rails/blob/master/actionpack/lib/action_vi...

Any particular reason why the code is the way it is. There is a corresponding test also for that line of code.

Comments and changes to this ticket

  • José Valim

    José Valim November 28th, 2010 @ 08:53 AM

    • State changed from “new” to “wontfix”

    This is a backward compatibility schema because some people were used to return a full html page for xhr? or js? requests. I am glad you are looking at this and getting more and more familiar with the code. :)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages