我目前在View中使用一个link_to帮助程序来传递参数,如title,author,image_url和isbn返回给控制器
<%= link_to 'Sell this item',new_item_path(:title => title,:author => authors,:image_url=>image,:image_url_s=>image_s,:isbn=>isbn,:isbn13=>isbn13 ) %>
然后,控制器会将参数分配给稍后在View中的表单使用的对象(在new.html.erb中)
def new @item = Item.new @item.title = params[:title] @item.author = params[:author] @item.image_url = params[:image_url] @item.image_url_s = params[:image_url_s] @item.isbn = params[:isbn] @item.isbn13 = params[:isbn13] respond_to do |format| format.html # new.html.erb format.xml { render :xml => @item } end end
那么new.html.erb将被调用.
这是一切正常,但网址显示所有的参数
http://localhost:3000/items/new?author=Michael+Harvey&image_url=http://ecx.images-amazon.com/images/I/51vt1uVjvLL._SL160_.jpg&image_url_s=http://ecx.images-amazon.com/images/I/51vt1uVjvLL._SL75_.jpg&isbn13=9780307272508&isbn=0307272508&title=The+Third+Rail
有什么办法可以使参数不显示在URL上吗?