Forum: Ruby on Rails Failing to render RJS

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Adam T. (Guest)
on 2008-12-29 10:42
My code looks like the following, but for some reason the rjs template
(index.js.erb) is not being rendered.  I've also tried naming the rjs
file index.js.rjs with no luck.

home_controller.rb:

def index
  respond_to do |format|
    format.js
    format.html
  end
end

index.js.erb:

page << "var data = 'Core
Selectors,Attributes,Traversing,Manipulation'.split(',');"
page << "$('#example').autocomplete(data);"

How does rails decide when to render an rjs file in addition to an html
file?
Frederick C. (Guest)
on 2008-12-29 11:29
(Received via mailing list)
On 29 Dec 2008, at 08:42, Adam T. wrote:

>
> My code looks like the following, but for some reason the rjs template
> (index.js.erb) is not being rendered.  I've also tried naming the rjs
> file index.js.rjs with no luck.
>
What does the thing making the request look like ?(index.js.erb will
never work, since it will just try and pass that file through erb even
though that file isn't an erb template at all)

Fred
Andrius C. (Guest)
on 2008-12-29 14:59
(Received via mailing list)
You need to rename it to index.js.rjs. Check in firebug then if you
get response.
This topic is locked and can not be replied to.