new.html.erb
在我的 Rails 3.2 项目中,我有一个表单可以在其中创建一个新站点app/views/sites/
<%= form_for(@site) do |site_form| %>
...
<div class="field">
<%= site_form.label :hash_name %><br />
<%= site_form.text_field :hash_name %>
</div>
...
<div class="actions">
<%= site_form.submit %>
</div>
<% end %>
然后create
函数在sites_controller.rb
def create
@site = Site.new(params[:site])
respond_to do |format|
if @site.save
format.html { redirect_to @site }
else
format.html { render action: "new" }
end
end
end
然后在用户提交后,我想显示hash_name
用户刚刚提交的,在show.html.erb
You just put in <%= params[:hash_name] %>.
但是访问params[:hash_name]
不起作用。我怎样才能访问它?