Ruby on rails 使用Rails Ajax呈现不同的.js文件
在使用Ajax时,如何呈现不同的Ruby on rails 使用Rails Ajax呈现不同的.js文件,ruby-on-rails,ajax,ruby-on-rails-3,Ruby On Rails,Ajax,Ruby On Rails 3,在使用Ajax时,如何呈现不同的.js.erb文件 例如: <% form_tag user_path, :method => :get, :remote => true do %> :get,:remote=>true do%> 这将通过UserController#show,然后呈现users/show.js.erb。如何使其通过UserController\show,然后在users\u controller.rb中呈现users/hello.js.erb?:
.js.erb
文件
例如:
<% form_tag user_path, :method => :get, :remote => true do %>
:get,:remote=>true do%>
这将通过
UserController#show
,然后呈现users/show.js.erb
。如何使其通过UserController\show
,然后在users\u controller.rb中呈现users/hello.js.erb
?:
def show
@user = User.find(params[:id])
respond_to do |format|
format.js { render 'hello.js.erb' }
end
end
或更短,因为只有一种响应格式:
def show
@user = User.find(params[:id])
render :hello
end