How do you respond_to another js file in the controller using Ruby on Rails?

前端 未结 1 1238
星月不相逢
星月不相逢 2021-01-07 05:58

I basically have an action that because of logic needs to return with the contents of another js file. How do I go about doing this? Thanks

app/controllers/classro

相关标签:
1条回答
  • 2021-01-07 06:34

    You need to add

     :layout => false 
    

    to avoid the rendering of the html layout for your js file.

    Additionally you could define the different js-file like this

    :template => "classrooms/create_differently.js.erb"
    

    both together:

     format.js { 
        render :template => "classrooms/create_differently.js.erb", 
               :layout => false  
     }
    

    For browser-based testing, please be aware calling js not html!

    0 讨论(0)
提交回复
热议问题