Skip to content Skip to sidebar Skip to footer

Rails: Render A .js.erb From Another Controller?

How can I render a .js.erb from a controller that doesn't belong to the view it is going to be rendered in? For example: How can I render create.js.erb in my pages view, from a pos

Solution 1:

It seems there are several ways to achieve this:

respond_to do |format|
    format.js { :location => path_to_controller_method_url(argument) }
end

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

respond_to do |format|
    format.js {
       :template => "classrooms/create_differently.js.erb", 
       :layout => false
    }
end

Render alternate view in ruby on rails

respond_to do |format|
    format.js { render :file => "/path/to/save.js.erb" }
end

Post a Comment for "Rails: Render A .js.erb From Another Controller?"