Does Rails 4 allow ruby code in a .JS view, in rails 3 it was required to have .erb.js in the filename

StackOverflow https://stackoverflow.com/questions/19401001

Вопрос

Does Rails 4 allow ruby code in a .JS view, in rails 3 it was required to have .erb.js in the filename

  def test
    respond_to do |format|
      format.js { Rails.logger.info "in JS handler" }
    end
  end



/app/views/users/test.erb.js <== no longer works in rails 4

and

/app/views/users/test.js <== still works in rails 4 but does it allow ruby inside this file?
Это было полезно?

Решение

Your file must be named test.js.erb to include Ruby code in it.

Другие советы

Problem was file had to be named

file.js.erb

not

file.erb.js
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top