URLに表示せずにlink_to呼び出しでパラメーターを渡す方法はありますか?私は単純な星評価システムを作成しており、基本的に各星を、同じページの新しいレンダリングにパラメーターとしてその値を渡す画像リンクにしています。ヘルパーコードは次のようになります。
def stars_generator(edit_mode = false)
@rating = params[:stars].to_i #takes rating from page param, so :star must be defined first!
@stars = Array.new(5) {|i| i+1} #change array size for more stars
output = "<div class = 'star_container'>"
case edit_mode #checks whether to display static stars or clickable stars
when true
@stars.each do |star| #this block generates empty or colored stars depending the value of @rating and the position of the star evaluated
if star <= @rating
output += link_to image_tag('star_rated.png', :mouseover => 'star_hover.png'), review_new_url(:stars => star)
else
output += link_to image_tag('star_empty.png', :mouseover => 'star_hover.png'), review_new_url(:stars => star)
end
end
when false #static stars are displayed if edit_mode is false
@stars.each do |star|
if star <= @rating
output += image_tag('star_rated.png')
else
output += image_tag('star_empty.png')
end
end
end
output += "</div>"
return output
end
完全に機能しますが、現在、星の評価はURLのパラメータとして表示されます。理想的には、その情報を何らかの方法で非表示にしたいのですが、hidden_field_tagとhidden_tagの両方を試しましたが、どちらも機能しません。これを行う方法はありませんか、それとも私は完全に初心者ですか?