Ruby on rails 如何将控制器的方法调用到rails中的视图?
内部控制器Ruby on rails 如何将控制器的方法调用到rails中的视图?,ruby-on-rails,ruby-on-rails-4,Ruby On Rails,Ruby On Rails 4,内部控制器 def test command = 'pwd' result = `#{command}` respond_to do |format| format.html { redirect_to(users_url) } format.js { render :text => "$('#teste').html('#{result}');" } end end 我想显示变量结果 鉴于 <%= link_to 'Testar'
def test
command = 'pwd'
result = `#{command}`
respond_to do |format|
format.html { redirect_to(users_url) }
format.js { render :text => "$('#teste').html('#{result}');" }
end
end
我想显示变量结果
鉴于
<%= link_to 'Testar', test_users_path, :method => :get, :remote => true %>
:get,:remote=>true%>
声明一个helper\u方法
在您的控制器中:
private
def test
...
end
helper_method :test
In your view:
<% test -%>
private
def测试
...
终止
方法:测试
在你看来:
我只想在单击按钮后显示退货。