{"id":1045,"date":"2022-08-30T15:11:28","date_gmt":"2022-08-30T15:11:28","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/09\/nomethoderror-in-authenticationscontrollercreate-undefined-method-randomstring-for-stringclass-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:11:28","modified_gmt":"2022-08-30T15:11:28","slug":"nomethoderror-in-authenticationscontrollercreate-undefined-method-randomstring-for-stringclass-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/nomethoderror-in-authenticationscontrollercreate-undefined-method-randomstring-for-stringclass-collection-of-common-programming-errors\/","title":{"rendered":"NoMethodError in AuthenticationsController#create undefined method `RandomString&#39; for String:Class-Collection of common programming errors"},"content":{"rendered":"<p>I follow this tutorial for install omniauth in devise+mongoid:<\/p>\n<p>https:\/\/github.com\/fertapric\/rails3-mongoid-devise-omniauth\/wiki\/OmniAuth-Installation-Tutorial<\/p>\n<p>I have devise 1.4.5 + omniauth 0.3.0 + rails 3.1.0.<\/p>\n<p>I have in my <strong>devise.rb<\/strong> the next information:<\/p>\n<pre><code>config.omniauth :facebook, 'My_CONSUMER_KEY', 'MY_CONSUMER_SECRET', :scope =&gt; 'user_hometown, user_about_me, email'\n<\/code><\/pre>\n<p>In the tutorial, this configuration have that create a initializers\/omniauth.rb file.<\/p>\n<p>When I come back of facebook callback I catch this error:<\/p>\n<pre><code>NoMethodError in AuthenticationsController#create\n\nundefined method `RandomString' for String:Class\n\napp\/models\/user.rb:39:in `apply_trusted_services'\napp\/models\/user.rb:23:in `apply_omniauth'\napp\/controllers\/authentications_controller.rb:33:in `create_new_omniauth_user'\napp\/controllers\/authentications_controller.rb:16:in `create'\n<\/code><\/pre>\n<p>I have create too a file in <strong>lib\/string_extensions.rb<\/strong> with this code:<\/p>\n<pre><code>module StringExtensions\n  def self.included(base) \n    String.extend StringExtensions::ClassMethods\n  end\n  module ClassMethods\n    RAND_CHARS = \"ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789\"\n    def RandomString(len)\n      rand_max = RAND_CHARS.size\n      ret = \"\"\n      len.times{ ret<\/code><\/pre>\n<p id=\"rop\"><small>Originally posted 2013-11-09 23:18:36. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I follow this tutorial for install omniauth in devise+mongoid: https:\/\/github.com\/fertapric\/rails3-mongoid-devise-omniauth\/wiki\/OmniAuth-Installation-Tutorial I have devise 1.4.5 + omniauth 0.3.0 + rails 3.1.0. I have in my devise.rb the next information: config.omniauth :facebook, &#8216;My_CONSUMER_KEY&#8217;, &#8216;MY_CONSUMER_SECRET&#8217;, :scope =&gt; &#8216;user_hometown, user_about_me, email&#8217; In the tutorial, this configuration have that create a initializers\/omniauth.rb file. When I come back of facebook callback [&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-1045","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1045","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=1045"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1045\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}