Ruby on rails 使用“渲染”或“重定向到”

Ruby on rails 使用“渲染”或“重定向到”,ruby-on-rails,ruby,ruby-on-rails-3,Ruby On Rails,Ruby,Ruby On Rails 3,我有一张表格 <%= form_tag update_path do %> <%= text_field_tag :test_input, @text %> <%= submit_tag "update" %> <% end %> #mycontroller def update @text= 'abcde' render :max_channel #redirect_to :max_chan

我有一张表格

<%= form_tag update_path do %>
         <%= text_field_tag :test_input, @text %>
         <%= submit_tag "update" %>
<% end %>

#mycontroller
def update
    @text= 'abcde'
    render  :max_channel #redirect_to :max_channel
end

#霉菌控制者
def更新
@text='abcde'
渲染:最大通道#重定向#到:最大通道
结束
如果我使用render,它会更新我的text\u field\u标记,但会将我的url更改为localhost:3000/update。
重定向_以不更新我的文本,我不知道为什么。如何使用redirect_更新文本_字段_标记

如果使用redirect_to,则需要将参数与请求一起传递,因为redirect_to指向不同的URL。有关重定向和渲染的一些良好背景信息在问题中给出,因此问题

重定向到
将使浏览器请求一个新页面(这是您的max_频道),并且当前上下文将丢失。这就是为什么您不能在
max\u频道
页面中更新
@text

渲染
将使用当前上下文渲染
最大频道
页面

你可以从中得到更多

您可以将
@text
保存到某个地方(比如说您的
sqlite
),并使用与
max\u频道
对应的方法检索它