darashi / jpmobile

moved to http://github.com/jpmobile/jpmobile
http://github.com/jpmobile/jpmobile
MIT License
159 stars 26 forks source link

URLの指定が文字列のときに trans_sid が有効にならない #22

Closed rust closed 14 years ago

rust commented 14 years ago

link_to "Link", "/controller/action/id"

のような場合にセッションIDが付加されない

http://d.hatena.ne.jp/t-taira/20100212/1265929726

rust commented 14 years ago

module ActionView module Helpers module UrlHelper alias :url_for_without_jpmobile :url_for def url_for(options = {}) url = url_for_without_jpmobile(options)

    if options.kind_of?(String) and @controller and @controller.trans_sid_mode
      skey = ActionController::Base.session_options.merge(@controller.request.session_options || {})[:key]
      sid  = @controller.request.session_options[:id] rescue session.session_id

      unless options =~ /#{skey}/
        jpmobile_url = URI.parse(url)
        if jpmobile_url.query
          jpmobile_url.query += "&#{skey}=#{sid}"
        else
          jpmobile_url.query = "#{skey}=#{sid}"
        end
        url = jpmobile_url.to_s
      end
    end

    url
  end
end

end end

rust commented 14 years ago

こんな感じで直りますが,どうしましょうか.

rust commented 14 years ago

Rails 3 でなんとかなるかもと言うことで close