Ruby 2.0 / Rails 4 respond_to produces ActionController::UnknownFormat

Hello all,

I am stumped by this issue I am having. I have created a new method in
routes file that I want to have accessible via javascript. Right now, I
getting the following error when I try to access the action:

ActionController::UnknownFormat (ActionController::UnknownFormat

Here is my environment:


resources :homes do
collection do
get ‘set_active’


def set_active
@home = Home.find(params[:id])
respond_to do |format|

index page:

<%= link_to home.status, set_active_homes_path(id:, remote:
true %>

If i take out the respond to in the set_active action, it complains of a
missing template even though I have a set_active.js file in the
views/homes. This leads me to believe the respond_to block is the issue
not the fact that I am sending the JS format from the URL. It looks like
this action is only responding to html even though i have put remote:
in the link_to. I am trying to understand what I am missing.

I did google around and the only thing I saw was that the js mime-type
not available by default and to add it to the mime-types initializer.
when i did that, rails said that it was already initialized.

Am I missing something to be able to add JS/JQuery support?

Thanks in advance

I have traced this down to cucumber not knowing how to follow a
link. Or that my step definition is not setup correctly to following a
javascript link.

I decided to test that things were working as they should in the browser
and they work as expected. So its something with using click_on that
working right. Maybe there is something else I can use besides click_on
that is created for javascript.

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