简体   繁体   中英

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

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?

您的文件必须命名为test.js.erb才能在其中包含Ruby代码。

Problem was file had to be named

file.js.erb

not

file.erb.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM