Devise Routing Error on Gem Update (Rails 3, Devise + Omniauth)
I am using Devise + Omniauth (Facebook) and recently updated my gems (Rails 3.0.5, Ruby 1.9.2). Upon starting my app server the following line in routes.rb:
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks", :registrations => "registrations" }
has begun raising the following error:
/Users/myname/.rvm/gems/ruby-1.9.2-p0/gems/rack-mount-0.6.14/lib/rack/mount/route_set.rb:62:in `add_route': conditions may only include [:auth_type, :gateway_interface, :path_translated, :remote_host, :remote_ident, :remote_user, :remote_addr, :server_name, :server_protocol, :accept, :accept_charset, :accept_encoding, :accept_language, :cache_control, :from, :negotiate, :pragma, :key?, :request_method, :request_method_symbol, :method, :method_symbol, :get?, :post?, :put?, :delete?, :head?, :headers, :fullpath, :forgery_whitelisted?, :forgery_whitelisted_with_deprecation?, :forgery_whitelisted_without_deprecation?, :media_type, :content_length, :xml_http_request?, :xhr?, :ip, :remote_ip, :server_software, :raw_post, :body, :form_data?, :body_stream, :reset_session, :session=, :session_options=, :GET, :query_parameters, :POST, :request_parameters, :authorization, :local?, :cookie_jar, :flash, :url, :scheme, :protocol, :ssl?, :raw_host_with_port, :host, :host_with_port, :port, :standard_port, :standard_port?, :port_string, :server_port, :domain, :subdomains, :subdomain, :request_uri, :filtered_parameters, :filtered_env, :parameters, :params, :path_parameters=, :symbolized_path_parameters, :path_parameters, :content_mime_type, :content_type, :accepts, :format, :formats, :format=, :negotiate_mime, :if_modified_since, :if_none_match, :not_modified?, :etag_matches?, :fresh?, :env, :script_name, :path_info, :query_string, :session, :session_options, :logger, :media_type_params, :content_charset, :script_name=, :p开发者_如何学Pythonath_info=, :options?, :trace?, :parseable_data?, :[], :[]=, :values_at, :referer, :referrer, :user_agent, :cookies, :path, :location, :taguri=, :taguri, :to_yaml_style, :to_yaml_properties, :syck_to_yaml, :to_yaml, :blank?, :present?, :presence, :duplicable?, :acts_like?, :try, :html_safe?, :to_json, :instance_values, :instance_variable_names, :copy_instance_variables_from, :as_json, :with_options, :to_param, :to_query, :friendly_id?, :unfriendly_id?, :to_html, :dclone, :`, :returning, :require_or_load, :require_dependency, :require_association, :load_dependency, :load, :require, :unloadable, :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup, :initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?, :to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods, :instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?, :instance_of?, :kind_of?, :is_a?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend, :display, :public_method, :define_singleton_method, :__id__, :object_id, :to_enum, :enum_for, :gem, :silence_warnings, :enable_warnings, :with_warnings, :silence_stderr, :silence_stream, :suppress, :class_eval, :suppress_warnings, :require_library_or_gem, :debugger, :breakpoint, :==, :equal?, :!, :!=, :instance_eval, :instance_exec, :__send__] (ArgumentError)
Is there a new a syntax for routes named in this way?
You can hack it by changing line 338 in devise-1.4.2/lib/devise/rails/routes.rb to:
match "#{path_prefix}/:action/callback", #:action => Regexp.union(mapping.to.omniauth_providers.map(&:to_s)),
Be warned that this is only an ugly hack not a final solution to the problem!
Make sure you have set
devise :omniauthable, :omniauth_providers => [:twitter]
in your devise model (e.g. User).
Upgrade to forgery-0.4.0 if you're using it with with Devise/Omniauth. We were extending some base ruby classes (always a great idea, I know) and this somehow caused issues in Devise. Version 0.4.0 no longer extends any ruby base classes and should be completely safe to include. Let us know if you have any issues at http://github.com/sevenwire/forgery. Thanks!
精彩评论