hi all
i get 401 Unauthorized error each time i try to attach a file to a
model. I use Rails 2.3.4 and restful authentication plugin with
session database. Is anybody already meet this problem ?
Thanks for help.
Here are the initializers used:
---------------------------------------------------
require 'rack/utils'
class FlashSessionCookieMiddleware
def initialize(app, session_key = '_session_id')
@app = app
@session_key = session_key
@session_token = "_session_id"
end
def call(env)
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
env['HTTP_COOKIE'] = [ @session_key, params
[@session_token] ].join('=').freeze unless params[@session_token].nil?
end
@app.call(env)
end
end
class FlexNestedAttributeMiddleware
def initialize(app)
@app = app
end
def call(env)
req = Rack::Request.new(env)
if req && req.path_info =~ /\.fxml$/
if req.put? ||
req.post? || req.delete?
req.params.each do |key,value|
value.select { |k,v| k =~ /\_attributes$/ }.each do |match|
env['rack.request.form_hash'][key][match[0]] =
ActiveSupport::JSON.decode(match[1])
end
end
end
end
@app.call(env)
end
end
ActionController::Base.allow_forgery_protection = true
ActionController::Base.session = {
:key => "xxxxxxxxxx......",
:secret => "xxxxxxxxxxx......"
}
ActionController::Base.session_store = :active_record_store
ActionController::Dispatcher.middleware.use
FlashSessionCookieMiddleware, ActionController::Base.session_options
[:key]
--------------------------------------------------------