{"id":7828,"date":"2015-10-30T07:59:11","date_gmt":"2015-10-30T07:59:11","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/10\/30\/actioncontrollerurlgenerationerror-in-homehome-no-route-me-atches-actionedit-controllerusers-idnil-missing-required-keys-id-open-source-projects-route-me-route-me\/"},"modified":"2015-10-30T07:59:11","modified_gmt":"2015-10-30T07:59:11","slug":"actioncontrollerurlgenerationerror-in-homehome-no-route-me-atches-actionedit-controllerusers-idnil-missing-required-keys-id-open-source-projects-route-me-route-me","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/10\/30\/actioncontrollerurlgenerationerror-in-homehome-no-route-me-atches-actionedit-controllerusers-idnil-missing-required-keys-id-open-source-projects-route-me-route-me\/","title":{"rendered":"ActionController::UrlGenerationError in Home#home No route me atches {:action=>&#8221;edit&#8221;, :controller=>&#8221;users&#8221;, :id=>nil} missing required keys: [:id]-open source projects route-me\/route-me"},"content":{"rendered":"<p>I get the error:<\/p>\n<pre><code> ActionController::UrlGenerationError in Home#home  No route matches {:action=&gt;\"edit\", :controller=&gt;\"users\", :id=&gt;nil} missing required keys: [:id] \n<\/code><\/pre>\n<p>in my home controller. When I am sign in, I get errors in the home\/home mostly about<\/p>\n<pre><code>No route matches...:controller=&gt;\"users\", :id=&gt;nil} missing required keys: [:id].\n<\/code><\/pre>\n<p>For some reason, it looks like the sign_in is not working or the current_user is nil .<\/p>\n<p>Any idea on how to solve this error ? I am using devise and omniauth.<\/p>\n<p>Here is my users_model:<\/p>\n<pre><code>class User &lt; ActiveRecord::Base\nTEMP_EMAIL_PREFIX = 'change@me'\nTEMP_EMAIL_REGEX = \/\\Achange@me\/\n# Include default devise modules. Others available are:\n# :lockable, :timeoutable\ndevise :database_authenticatable, :registerable, :confirmable,\n:recoverable, :rememberable, :trackable, :validatable, :omniauthable\nvalidates_format_of :email, :without =&gt; TEMP_EMAIL_REGEX, on: :update\ndef self.find_for_oauth(auth, signed_in_resource = nil)\n# Get the identity and user if they exist\n identity = Identity.find_for_oauth(auth)\n# If a signed_in_resource is provided it always overrides the existing    user\n# to prevent the identity being locked with accidentally created accounts.\n# Note that this may leave zombie accounts (with no associated identity)  which\n# can be cleaned up at a later date.\nuser = signed_in_resource ? signed_in_resource : identity.user\n\n# Create the user if needed\n if user.nil?\n\n # Get the existing user by email if the provider gives us a verified email.\n # If no verified email was provided we assign a temporary email and ask the\n # user to verify it on the next step via UsersController.finish_signup\n email_is_verified = auth.info.email &amp;&amp; (auth.info.verified || auth.info.verified_email)\n email = auth.info.email if email_is_verified\n user = User.where(:email =&gt; email).first if email\n\n# Create the user if it's a new registration\nif user.nil?\nuser = User.new(\n  name: auth.extra.raw_info.name,\n  #username: auth.info.nickname || auth.uid,\n  email: email ? email : \"#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com\",\n  password: Devise.friendly_token[0,20]\n)\n  user.skip_confirmation!\n  user.save!\n  end\n  end\n\n # Associate the identity with the user if needed\n  if identity.user != user\n  identity.user = user\n  identity.save!\n  end\n user\nend\n\ndef email_verified?\nself.email &amp;&amp; self.email !~ TEMP_EMAIL_REGEX\nend\nend\n<\/code><\/pre>\n<p>Here is my shared\/user_info.html.erb:<\/p>\n<pre>\n\n\n\n<\/pre>\n<p><code>Here is my app\/views\/layouts\/header.html.erb:<\/code><\/p>\n<pre><code><code>\n\n\n\n  <\/code><\/code><\/pre>\n<ul class=\"nav navbar-nav navbar-right\">\n<li class=\"dropdown\"><code>Account<\/code>\n<ul class=\"dropdown-menu\"><\/ul>\n<\/li>\n<\/ul>\n<pre>\n        \n           \n<\/pre>\n<p><code>Here is my routes.rb:<\/code><\/p>\n<pre><code><code>Rails.application.routes.draw do\n\n  get 'groups\/new'\n\n  get 'groups\/create'\n\n  get 'groups\/show'\n\n  get 'groups\/edit'\n\n  get 'groups\/update'\n\n  get 'groups\/destroy'\n  get 'groups' =&gt; 'groups#index'\n  get 'groups\/new'\n  get 'signup' =&gt;'users#new'\n  get 'rooms'  =&gt;'home#rooms'\n\n  match '\/users\/:id\/finish_signup' =&gt; 'users#finish_signup', via: [:get, :patch], :as =&gt; :finish_signup\n\n\n  devise_for :users, :controllers =&gt; { omniauth_callbacks: 'omniauth_callbacks' }\n\n  resources :users do\n  member do\n  get :following, :followers\n  end\n  end\n\n\n  root 'home#home' \n  get 'terms' =&gt; 'home#terms'\n  get 'privacy' =&gt; 'home#privacy'\n  get 'about' =&gt; 'home#about'\n\n  get    'login'   =&gt; 'sessions#new'\n  post   'login'   =&gt; 'sessions#create'\n  delete 'logout'  =&gt; 'sessions#destroy'\n\n  resources :posts  do\n  member { post :vote }\n  resources :comments do\n  member { post :vote }\n  end\n  end\n\n  resources :groups\n  resources :relationships,       only: [:create, :destroy]\n<\/code><\/code><\/pre>\n<p>Here is my full trace:<\/p>\n<pre><code>actionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:219:in `raise_generation_error'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:192:in `optimized_helper'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:178:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:270:in `block (2 levels) in define_url_helper'\napp\/views\/layouts\/_header.html.erb:20:in `_app_views_layouts__header_html_erb__4827727_36507960'\nactionview (4.1.8) lib\/action_view\/template.rb:145:in `block in render'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:161:in `instrument'\nactionview (4.1.8) lib\/action_view\/template.rb:339:in `instrument'\nactionview (4.1.8) lib\/action_view\/template.rb:143:in `render'\nactionview (4.1.8) lib\/action_view\/renderer\/partial_renderer.rb:306:in `render_partial'\nactionview (4.1.8) lib\/action_view\/renderer\/partial_renderer.rb:279:in `block in render'\nactionview (4.1.8) lib\/action_view\/renderer\/abstract_renderer.rb:38:in `block in instrument'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:159:in `block in instrument'\nactivesupport (4.1.8)lib\/active_support\/notifications\/instrumenter.rb:20:in `instrument'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:159:in `instrument'\nactionview (4.1.8) lib\/action_view\/renderer\/abstract_renderer.rb:38:in `instrument'\nactionview (4.1.8) lib\/action_view\/renderer\/partial_renderer.rb:278:in `render'\nactionview (4.1.8) lib\/action_view\/renderer\/renderer.rb:47:in `render_partial'\nactionview (4.1.8) lib\/action_view\/helpers\/rendering_helper.rb:35:in `render'\napp\/views\/layouts\/application.html.erb:14:in `_app_views_layouts_application_html_erb__798221577_35492700'\nactionview (4.1.8) lib\/action_view\/template.rb:145:in `block in render'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:161:in `instrument'\nactionview (4.1.8) lib\/action_view\/template.rb:339:in `instrument'\nactionview (4.1.8) lib\/action_view\/template.rb:143:in `render'\nactionview (4.1.8) lib\/action_view\/renderer\/template_renderer.rb:67:in `render_with_layout'\nactionview (4.1.8) lib\/action_view\/renderer\/template_renderer.rb:53:in `render_template'\nactionview (4.1.8) lib\/action_view\/renderer\/template_renderer.rb:17:in `render'\nactionview (4.1.8) lib\/action_view\/renderer\/renderer.rb:42:in `render_template'\nactionview (4.1.8) lib\/action_view\/renderer\/renderer.rb:23:in `render'\nactionview (4.1.8) lib\/action_view\/rendering.rb:99:in `_render_template'\nactionpack (4.1.8) lib\/action_controller\/metal\/streaming.rb:217:in `_render_template'\nactionview (4.1.8) lib\/action_view\/rendering.rb:82:in `render_to_body'\nactionpack (4.1.8) lib\/action_controller\/metal\/rendering.rb:32:in `render_to_body'\nactionpack (4.1.8) lib\/action_controller\/metal\/renderers.rb:32:in `render_to_body'\nactionpack (4.1.8) lib\/abstract_controller\/rendering.rb:25:in `render'\nactionpack (4.1.8) lib\/action_controller\/metal\/rendering.rb:16:in `render'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:41:in `block (2 levels) in render'\nactivesupport (4.1.8) lib\/active_support\/core_ext\/benchmark.rb:12:in `block in ms'\nC:\/RailsInstaller\/Ruby2.0.0\/lib\/ruby\/2.0.0\/benchmark.rb:296:in `realtime'\nactivesupport (4.1.8) lib\/active_support\/core_ext\/benchmark.rb:12:in `ms'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:41:in `block in render'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:84:in `cleanup_view_runtime'\nactiverecord (4.1.8) lib\/active_record\/railties\/controller_runtime.rb:25:in `cleanup_view_runtime'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:40:in `render'\nactionpack (4.1.8) lib\/action_controller\/metal\/implicit_render.rb:10:in `default_render'\nactionpack (4.1.8) lib\/action_controller\/metal\/implicit_render.rb:5:in `send_action'\nactionpack (4.1.8) lib\/abstract_controller\/base.rb:189:in `process_action'\nactionpack (4.1.8) lib\/action_controller\/metal\/rendering.rb:10:in `process_action'\nactionpack (4.1.8) lib\/abstract_controller\/callbacks.rb:20:in `block in process_action'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:113:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:113:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:229:in `block in halting'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:229:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:229:in `block in halting'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `block in halting'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `block in halting'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:166:in `block in halting'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:86:in `call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:86:in `run_callbacks'\nactionpack (4.1.8) lib\/abstract_controller\/callbacks.rb:19:in `process_action'\nactionpack (4.1.8) lib\/action_controller\/metal\/rescue.rb:29:in `process_action'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:31:in `block in process_action'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:159:in `block in instrument'\nactivesupport (4.1.8)lib\/active_support\/notifications\/instrumenter.rb:20:in `instrument'\nactivesupport (4.1.8) lib\/active_support\/notifications.rb:159:in `instrument'\nactionpack (4.1.8) lib\/action_controller\/metal\/instrumentation.rb:30:in `process_action'\nactionpack (4.1.8) lib\/action_controller\/metal\/params_wrapper.rb:250:in `process_action'\nactiverecord (4.1.8) lib\/active_record\/railties\/controller_runtime.rb:18:in `process_action'\nactionpack (4.1.8) lib\/abstract_controller\/base.rb:136:in `process'\nactionview (4.1.8) lib\/action_view\/rendering.rb:30:in `process'\nactionpack (4.1.8) lib\/action_controller\/metal.rb:196:in `dispatch'\nactionpack (4.1.8) lib\/action_controller\/metal\/rack_delegation.rb:13:in `dispatch'\nactionpack (4.1.8) lib\/action_controller\/metal.rb:232:in `block in action'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:82:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:82:in `dispatch'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:50:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/journey\/router.rb:73:in `block in call'\nactionpack (4.1.8) lib\/action_dispatch\/journey\/router.rb:59:in `each'\nactionpack (4.1.8) lib\/action_dispatch\/journey\/router.rb:59:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/routing\/route_set.rb:678:in `call'\nomniauth (1.2.2) lib\/omniauth\/strategy.rb:186:in `call!'\nomniauth (1.2.2) lib\/omniauth\/strategy.rb:164:in `call'\nomniauth (1.2.2) lib\/omniauth\/builder.rb:59:in `call'\nwarden (1.2.3) lib\/warden\/manager.rb:35:in `block in call'\nwarden (1.2.3) lib\/warden\/manager.rb:34:in `catch'\nwarden (1.2.3) lib\/warden\/manager.rb:34:in `call'\nrack (1.5.2) lib\/rack\/etag.rb:23:in `call'\nrack (1.5.2) lib\/rack\/conditionalget.rb:25:in `call'\nrack (1.5.2) lib\/rack\/head.rb:11:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/params_parser.rb:27:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/flash.rb:254:in `call'\nrack (1.5.2) lib\/rack\/session\/abstract\/id.rb:225:in `context'\nrack (1.5.2) lib\/rack\/session\/abstract\/id.rb:220:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/cookies.rb:560:in `call'\nactiverecord (4.1.8) lib\/active_record\/query_cache.rb:36:in `call'\nactiverecord\n(4.1.8)lib\/active_record\/connection_adapters\/abstract\/connection_pool.rb:621:in `call'\nactiverecord (4.1.8) lib\/active_record\/migration.rb:380:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/callbacks.rb:29:in `block in call'\nactivesupport (4.1.8) lib\/active_support\/callbacks.rb:82:in `run_callbacks'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/callbacks.rb:27:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/reloader.rb:73:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/remote_ip.rb:76:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/debug_exceptions.rb:17:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/show_exceptions.rb:30:in `call'\nrailties (4.1.8) lib\/rails\/rack\/logger.rb:38:in `call_app'\nrailties (4.1.8) lib\/rails\/rack\/logger.rb:20:in `block in call'\nactivesupport (4.1.8) lib\/active_support\/tagged_logging.rb:68:in `block in tagged'\nactivesupport (4.1.8) lib\/active_support\/tagged_logging.rb:26:in `tagged'\nactivesupport (4.1.8) lib\/active_support\/tagged_logging.rb:68:in `tagged'\nrailties (4.1.8) lib\/rails\/rack\/logger.rb:20:in `call'\nactionpack (4.1.8) lib\/action_dispatch\/middleware\/request_id.rb:21:in `call'\n rack (1.5.2) lib\/rack\/methodoverride.rb:21:in `call'\n rack (1.5.2) lib\/rack\/runtime.rb:17:in `call'\n activesupport (4.1.8)      lib\/active_support\/cache\/strategy\/local_cache_middleware.rb:26:in `call'\n rack (1.5.2) lib\/rack\/lock.rb:17:in `call'\n actionpack (4.1.8) lib\/action_dispatch\/middleware\/static.rb:84:in `call'\n rack (1.5.2) lib\/rack\/sendfile.rb:112:in `call'\n railties (4.1.8) lib\/rails\/engine.rb:514:in `call'\n railties (4.1.8) lib\/rails\/application.rb:144:in `call'\n rack (1.5.2) lib\/rack\/lock.rb:17:in `call'\n rack (1.5.2) lib\/rack\/content_length.rb:14:in `call'\n rack (1.5.2) lib\/rack\/handler\/webrick.rb:60:in `service'\n C:\/RailsInstaller\/Ruby2.0.0\/lib\/ruby\/2.0.0\/webrick\/httpserver.rb:138:in `service'\n C:\/RailsInstaller\/Ruby2.0.0\/lib\/ruby\/2.0.0\/webrick\/httpserver.rb:94:in `run'\nC:\/RailsInstaller\/Ruby2.0.0\/lib\/ruby\/2.0.0\/webrick\/server.rb:295:in `block in start_thread'\n<\/code><\/pre>\n<p>Here is my omniauth_callbacks_controller.rb:<\/p>\n<pre><code>class OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController\ndef self.provides_callback_for(provider)\nclass_eval %Q{\n  def #{provider}\n    @user = User.find_for_oauth(env[\"omniauth.auth\"], current_user)\n\n    if @user.persisted?\n      sign_in_and_redirect @user, event: :authentication\n      set_flash_message(:notice, :success, kind: \"#{provider}\".capitalize)    if is_navigational_format?\n    else\n      session[\"devise.#{provider}_data\"] = env[\"omniauth.auth\"]\n      redirect_to new_user_registration_url\n    end\n  end\n  }\n end\n\n[:twitter, :facebook, :linked_in].each do |provider|\nprovides_callback_for provider\nend\n\ndef after_sign_in_path_for(resource)\n#if resource.email_verified?\n  super resource\n  current_user = @user\n#else\n # finish_signup_path(resource)\n #end\n end\nend\n<\/code><\/pre>\n<p>And my users controller:<\/p>\n<pre><code>class UsersController &lt; ApplicationController\nbefore_action :set_user, only: [:show, :edit, :update, :destroy, :finish_signup]\n\ndef index\n@users = User.all\nend \n\n# GET \/users\/:id.:format\ndef show\n# authorize! :read, @user\n\n end\n\n# GET \/users\/:id\/edit\ndef edit\n# authorize! :update, @user\nend\ndef new\n@user = User.new\nend\n\n# PATCH\/PUT \/users\/:id.:format\ndef update\n# authorize! :update, @user\nrespond_to do |format|\n  if @user.update(user_params)\n    sign_in(@user == current_user ? @user : current_user, :bypass =&gt; true)\n    format.html { redirect_to @user, notice: 'Your profile was successfully updated.' }\n    format.json { head :no_content }\n  else\n    format.html { render action: 'edit' }\n    format.json { render json: @user.errors, status: :unprocessable_entity }\n  end\n  end\n  end\n\n  # GET\/PATCH \/users\/:id\/finish_signup\n  def finish_signup\n  # authorize! :update, @user \n  if request.patch? &amp;&amp; params[:user] #&amp;&amp; params[:user][:email]\n  if @user.update(user_params)\n    @user.skip_reconfirmation!\n    sign_in(@user, :bypass =&gt; true)\n    redirect_to @user, notice: 'Your profile was successfully updated.'\n  else\n    @show_errors = true\n  end\n  end\n  end\n\n  # DELETE \/users\/:id.:format\n  def destroy\n  # authorize! :delete, @user\n  @user.destroy\n  respond_to do |format|\n  format.html { redirect_to root_url }\n  format.json { head :no_content }\n  end\n  end\n  def set_user\n  @user = User.find(params[:id])\n  end\n\n  def following\n   @title = \"Following\"\n   @user  = User.find(params[:id])\n   @users = @user.following.paginate(page: params[:page])\n   render 'show_follow'\n   end\n\n   def followers\n   @title = \"Followers\"\n   @user  = User.find(params[:id])\n   @users = @user.followers.paginate(page: params[:page])\n   render 'show_follow'\n   end\n\n\n\n  private\n  def user_params\n  accessible = [ :name, :email ] # extend with your own params\n  accessible<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I get the error: ActionController::UrlGenerationError in Home#home No route matches {:action=&gt;&#8221;edit&#8221;, :controller=&gt;&#8221;users&#8221;, :id=&gt;nil} missing required keys: [:id] in my home controller. When I am sign in, I get errors in the home\/home mostly about No route matches&#8230;:controller=&gt;&#8221;users&#8221;, :id=&gt;nil} missing required keys: [:id]. For some reason, it looks like the sign_in is not working or the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7828","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7828"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7828\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}