在我的Rails 3.2的项目,我有一个表格,以创建一个新的站点new.html.erb
在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]
不起作用。 我怎样才能访问它?