ruby on rails:传递给控制器的参数和cookie之间的关系



我有一个显示问题的应用程序

http://strong-sunrise-4122.herokuapp.com/movies

尝试

  1. 按标题排序
  2. 选择一些评级并刷新
  3. 按日期排序-->无效

传递给控制器的参数不包含"sort=date",但仍然包含"sord=title",这怎么可能?但是,如果我在浏览器中删除cookie链接再次工作。如果这是个愚蠢的问题,我很抱歉。实际上我储存了一些状态在会话中,不要触摸任何cookie结构。附件是"haml"代码

-#  This file is app/views/movies/index.html.haml
%h1 All Movies
=form_tag movies_path, :method => :get do
  Include:
  - @all_ratings.each_pair do |rating, set|
    = rating
    = check_box_tag "ratings[#{rating}]", true, set
  = submit_tag 'Refresh', :id => 'ratings_submit'
%table#movies
  %thead
    %tr
      %th{:class => miohelp("title")}= link_to 'Movie Title' , "/movies?sort=title" , :id => "title_header"
      %th Rating
      %th{:class => miohelp("date")}= link_to 'Release Date' , "/movies?sort=date",:id => "release_date_header"
      %th More Info
  %tbody
    - @movies.each do |movie|
      %tr
        %td= movie.title 
        %td= movie.rating
        %td= movie.release_date
        %td= link_to "More about #{movie.title}", movie_path(movie)
= link_to 'Add new movie', new_movie_path

我想问题在于,在您的控制器中,您给会话内容的优先级高于传入参数。我的意思是,更高的优先级是,您首先检查会话内容,这将使用您在会话中保存的参数将页面重定向到某个url。所以,请出示动作index的控制器代码?

最新更新