`Undefined method `user_id' for #. What is the problem <meta name="yandex-verification" content="b48eb87065220426" /> <link rel="apple-touch-icon" sizes="57x57" href="/assets/theme/favicon/apple-icon-57x57.png"> <link rel="apple-touch-icon" sizes="60x60" href="/assets/theme/favicon/apple-icon-60x60.png"> <link rel="apple-touch-icon" sizes="72x72" href="/assets/theme/favicon/apple-icon-72x72.png"> <link rel="apple-touch-icon" sizes="76x76" href="/assets/theme/favicon/apple-icon-76x76.png"> <link rel="apple-touch-icon" sizes="114x114" href="/assets/theme/favicon/apple-icon-114x114.png"> <link rel="apple-touch-icon" sizes="120x120" href="/assets/theme/favicon/apple-icon-120x120.png"> <link rel="apple-touch-icon" sizes="144x144" href="/assets/theme/favicon/apple-icon-144x144.png"> <link rel="apple-touch-icon" sizes="152x152" href="/assets/theme/favicon/apple-icon-152x152.png"> <link rel="apple-touch-icon" sizes="180x180" href="/assets/theme/favicon/apple-icon-180x180.png"> <link rel="icon" type="image/png" sizes="192x192" href="/assets/theme/favicon/android-icon-192x192.png"> <link rel="icon" type="image/png" sizes="32x32" href="/assets/theme/favicon/favicon-32x32.png"> <link rel="icon" type="image/png" sizes="96x96" href="/assets/theme/favicon/favicon-96x96.png"> <link rel="icon" type="image/png" sizes="16x16" href="/assets/theme/favicon/favicon-16x16.png"> <link rel="manifest" href="/assets/theme/favicon/manifest.json"> <meta name="msapplication-TileColor" content="#ffffff"> <meta name="msapplication-TileImage" content="/assets/theme/favicon/ms-icon-144x144.png"> <meta name="theme-color" content="#ffffff"> <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8700890447935372" crossorigin="anonymous"></script> <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id=G-N7006N1W94"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'G-N7006N1W94'); </script> </head> <style> .name-color-A {background:#FF8C7C} .name-color-B {background:#ff8cc8} .name-color-C {background:#BE90D4} .name-color-D {background:#BE90D4} .name-color-E {background:#1297e0} .name-color-F {background:#27cbc0} .name-color-G {background:#2ecc71} .name-color-H {background:#F5AB35} .name-color-I {background:#f3825b} .name-color-J {background:#be8c6b} .name-color-K {background:#4c5a69} .name-color-L {background:#657576} .name-color-M {background:#707070} .name-color-N {background:#870000} .name-color-O {background:#9a0038} .name-color-P {background:#3e005d} .name-color-Q {background:#003780} .name-color-R {background:#005b50} .name-color-S {background:#005c01} .name-color-T {background:#a84410} .name-color-U {background:#932210} .name-color-V {background:#5e2c0b} .name-color-W {background:#2c3a49} .name-color-X {background:#d35400} .name-color-Y {background:#2c3e50} .name-color-Z {background:#3498db} .pagination { display: inline-block; padding-left: 0; margin: 20px 0; border-radius: 4px; } .pagination > li { display: inline; } .pagination > li > a, .pagination > li > span { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.42857143; color: #337ab7; text-decoration: none; background-color: #ffffff; border: 1px solid #dddddd; } .pagination > li > a:hover, .pagination > li > span:hover, .pagination > li > a:focus, .pagination > li > span:focus { z-index: 2; color: #23527c; background-color: #eeeeee; border-color: #dddddd; } .pagination > li:first-child > a, .pagination > li:first-child > span { margin-left: 0; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .pagination > li:last-child > a, .pagination > li:last-child > span { border-top-right-radius: 4px; border-bottom-right-radius: 4px; } .pagination > .active > a, .pagination > .active > span, .pagination > .active > a:hover, .pagination > .active > span:hover, .pagination > .active > a:focus, .pagination > .active > span:focus { z-index: 3; color: #ffffff; cursor: default; background-color: #337ab7; border-color: #337ab7; } .pagination > .disabled > span, .pagination > .disabled > span:hover, .pagination > .disabled > span:focus, .pagination > .disabled > a, .pagination > .disabled > a:hover, .pagination > .disabled > a:focus { color: #777777; cursor: not-allowed; background-color: #ffffff; border-color: #dddddd; } .pagination-lg > li > a, .pagination-lg > li > span { padding: 10px 16px; font-size: 18px; line-height: 1.3333333; } .pagination-lg > li:first-child > a, .pagination-lg > li:first-child > span { border-top-left-radius: 6px; border-bottom-left-radius: 6px; } .pagination-lg > li:last-child > a, .pagination-lg > li:last-child > span { border-top-right-radius: 6px; border-bottom-right-radius: 6px; } .pagination-sm > li > a, .pagination-sm > li > span { padding: 5px 10px; font-size: 12px; line-height: 1.5; } .pagination-sm > li:first-child > a, .pagination-sm > li:first-child > span { border-top-left-radius: 3px; border-bottom-left-radius: 3px; } .pagination-sm > li:last-child > a, .pagination-sm > li:last-child > span { border-top-right-radius: 3px; border-bottom-right-radius: 3px; } .pagination .without-link { position: relative; float: left; padding: 6px 12px; margin-left: -1px; line-height: 1.42857143; color: #337ab7; text-decoration: none; background-color: #ffffff; border: 1px solid #dddddd; border-top-left-radius: 4px; border-bottom-left-radius: 4px; } .pagination .page-item:nth-child(1) img { transform: rotate(180deg); } @media only screen and (max-width : 320px) { .content__item-content { width: 100% !important; padding-right: 0px !important; box-sizing: border-box; } } </style> <body> <div class="wrapper"> <!-- Google Tag Manager (noscript) --> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NLLJJ7T" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <!-- End Google Tag Manager (noscript) --> <header class="header"> <div class="header__body"> <div class="header__row container"> <div class="header__left"> <div class="header__button"> <span class="header__button-line"></span></div><a class="header__logo lg" href="/"> <img src="/assets/theme/img/logo.png" style="width: 150px;" alt="" draggable="false" loading="lazy"></a> <a class="header__logo sm" href="index.html"> <img src="/assets/theme/img/logo.png" style="width: 150px;" alt="" draggable="false" loading="lazy"> </a> </div> <ul class="header__list lg"> <li class="header__li drop-container"> <button class="drop header__link" type="button"> <div class="icon icon-category"> </div><span>Categories</span> </button> <div class="drop__content"> <div class="drop__col"> <!--<a class="drop__link strong border">All Project Questions</a>--> <a class="drop__link" href="/category/javascript">JavaScript</a><a class="drop__link" href="/category/php">PHP</a><a class="drop__link" href="/category/html">HTML</a><a class="drop__link" href="/category/css">Css</a><a class="drop__link" href="/category/python">Python</a><a class="drop__link" href="/category/wordpress">WordPress</a><a class="drop__link" href="/category/web-development">Web development</a><a class="drop__link" href="/category/linux">Linux</a><a class="drop__link" href="/category/mysql">MySQL</a><a class="drop__link" href="/category/android">Android</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/windows">Windows</a><a class="drop__link" href="/category/java">Java</a><a class="drop__link" href="/category/c">C++ / C#</a><a class="drop__link" href="/category/layout">Layout</a><a class="drop__link" href="/category/react">React</a><a class="drop__link" href="/category/ubuntu">Ubuntu</a><a class="drop__link" href="/category/yii">Yii</a><a class="drop__link" href="/category/django">Django</a><a class="drop__link" href="/category/programming">Programming</a><a class="drop__link" href="/category/1c-bitrix">1C-Bitrix</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/laravel">Laravel</a><a class="drop__link" href="/category/system-administration">System administration</a><a class="drop__link" href="/category/telegram">Telegram</a><a class="drop__link" href="/category/json">JSON</a><a class="drop__link" href="/category/debian">Debian</a><a class="drop__link" href="/category/postgresql">PostgreSQL</a><a class="drop__link" href="/category/ios">IOS</a><a class="drop__link" href="/category/google">Google</a><a class="drop__link" href="/category/htaccess">Htaccess</a><a class="drop__link" href="/category/windows-server">Windows Server</a> </div> <div class="drop__col"> <a class="drop__link" href="/category/git">Git</a><a class="drop__link" href="/category/macos">MacOS</a><a class="drop__link" href="/category/google-chrome">Google Chrome</a><a class="drop__link" href="/category/cms">CMS</a><a class="drop__link" href="/category/woocommerce">WooСommerce</a><a class="drop__link" href="/category/bootstrap">Bootstrap</a><a class="drop__link" href="/category/nginx">Nginx</a><a class="drop__link" href="/category/sql">SQL</a><a class="drop__link" href="/category/unity">Unity</a><a class="drop__link" href="/category/api">API</a> </div> </div> </li> <li class="header__li"> <a class="header__link" href="#!"> <div class="icon icon-add"> </div><span>Ask </span></a></li> <li class="header__li"> <a class="header__link" href="leaders.html"> <div class="icon icon-stats"> </div><span>Leaders </span></a></li> </ul> <ul class="header__list sm"> <li class="header__list-item"> <a href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M10.91 12.806A6.964 6.964 0 017 14c-3.863 0-7-3.137-7-7s3.137-7 7-7 7 3.137 7 7a6.97 6.97 0 01-1.18 3.889l2.114 2.113a1.354 1.354 0 01-1.914 1.914l-2.11-2.11zM7 2.477A4.524 4.524 0 0111.523 7 4.524 4.524 0 017 11.523 4.524 4.524 0 012.477 7 4.524 4.524 0 017 2.477z"></path></svg></a></li> <li class="header__list-item"> <a href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8.4 1a.6.6 0 01.6.6V7h5.4a.6.6 0 01.6.6v.8a.6.6 0 01-.6.6H9v5.4a.6.6 0 01-.6.6h-.8a.6.6 0 01-.6-.6V9H1.6a.6.6 0 01-.6-.6v-.8a.6.6 0 01.6-.6H7V1.6a.6.6 0 01.6-.6h.8z"></path></svg></a></li> </ul> <div class="header__right"> <form class="header__search search-bar" action="search.html" method="post"> <input name="username" type="text" style="display:none"> <input name="search-question" required minlength="3" class="search-bar__input" type="text" required autocomplete="off" placeholder="Search by questions"> <button class="search-bar__btn" type="submit"> <div class="icon icon-search"> </div> </button> </form> <div class="header__seperator"> <div></div> </div> </div> </div> </div> <div class="header__menu"> <div class="header__menu-body container"> <p class="header__menu-title">Categories </p> <a class="header__menu-link" href="/category/javascript">JavaScript</a><a class="header__menu-link" href="/category/php">PHP</a><a class="header__menu-link" href="/category/html">HTML</a><a class="header__menu-link" href="/category/css">Css</a><a class="header__menu-link" href="/category/python">Python</a><a class="header__menu-link" href="/category/wordpress">WordPress</a><a class="header__menu-link" href="/category/web-development">Web development</a><a class="header__menu-link" href="/category/linux">Linux</a><a class="header__menu-link" href="/category/mysql">MySQL</a><a class="header__menu-link" href="/category/android">Android</a><a class="header__menu-link" href="/category/windows">Windows</a><a class="header__menu-link" href="/category/java">Java</a><a class="header__menu-link" href="/category/c">C++ / C#</a><a class="header__menu-link" href="/category/layout">Layout</a><a class="header__menu-link" href="/category/react">React</a><a class="header__menu-link" href="/category/ubuntu">Ubuntu</a><a class="header__menu-link" href="/category/yii">Yii</a><a class="header__menu-link" href="/category/django">Django</a><a class="header__menu-link" href="/category/programming">Programming</a><a class="header__menu-link" href="/category/1c-bitrix">1C-Bitrix</a><a class="header__menu-link" href="/category/laravel">Laravel</a><a class="header__menu-link" href="/category/system-administration">System administration</a><a class="header__menu-link" href="/category/telegram">Telegram</a><a class="header__menu-link" href="/category/json">JSON</a><a class="header__menu-link" href="/category/debian">Debian</a><a class="header__menu-link" href="/category/postgresql">PostgreSQL</a><a class="header__menu-link" href="/category/ios">IOS</a><a class="header__menu-link" href="/category/google">Google</a><a class="header__menu-link" href="/category/htaccess">Htaccess</a><a class="header__menu-link" href="/category/windows-server">Windows Server</a><a class="header__menu-link" href="/category/git">Git</a><a class="header__menu-link" href="/category/macos">MacOS</a><a class="header__menu-link" href="/category/google-chrome">Google Chrome</a><a class="header__menu-link" href="/category/cms">CMS</a><a class="header__menu-link" href="/category/woocommerce">WooСommerce</a><a class="header__menu-link" href="/category/bootstrap">Bootstrap</a><a class="header__menu-link" href="/category/nginx">Nginx</a><a class="header__menu-link" href="/category/sql">SQL</a><a class="header__menu-link" href="/category/unity">Unity</a><a class="header__menu-link" href="/category/api">API</a> </div> </div> </header> <main class="main"> <div class="main__body container"> <aside class="sidebar"> <a class="sidebar__title" href="#!">Programming </a> <div class="sidebar__list"> <a class="sidebar__item " href="/category/javascript">JavaScript </a><a class="sidebar__item " href="/category/php">PHP </a><a class="sidebar__item " href="/category/html">HTML </a><a class="sidebar__item " href="/category/css">Css </a><a class="sidebar__item " href="/category/python">Python </a><a class="sidebar__item " href="/category/wordpress">WordPress </a><a class="sidebar__item " href="/category/web-development">Web development </a><a class="sidebar__item " href="/category/linux">Linux </a><a class="sidebar__item " href="/category/mysql">MySQL </a><a class="sidebar__item " href="/category/android">Android </a><a class="sidebar__item " href="/category/windows">Windows </a><a class="sidebar__item " href="/category/java">Java </a><a class="sidebar__item " href="/category/c">C++ / C# </a><a class="sidebar__item " href="/category/layout">Layout </a><a class="sidebar__item " href="/category/react">React </a><a class="sidebar__item " href="/category/ubuntu">Ubuntu </a><a class="sidebar__item " href="/category/yii">Yii </a><a class="sidebar__item " href="/category/django">Django </a><a class="sidebar__item " href="/category/programming">Programming </a><a class="sidebar__item " href="/category/1c-bitrix">1C-Bitrix </a><a class="sidebar__item " href="/category/laravel">Laravel </a><a class="sidebar__item " href="/category/system-administration">System administration </a><a class="sidebar__item " href="/category/telegram">Telegram </a><a class="sidebar__item " href="/category/json">JSON </a><a class="sidebar__item " href="/category/debian">Debian </a><a class="sidebar__item " href="/category/postgresql">PostgreSQL </a><a class="sidebar__item " href="/category/ios">IOS </a><a class="sidebar__item " href="/category/google">Google </a><a class="sidebar__item " href="/category/htaccess">Htaccess </a><a class="sidebar__item " href="/category/windows-server">Windows Server </a> </div> <div class="sidebar__list"> </div> </aside> <div class="mid"> <div class="content similar"> <div class="content__header bb-none"> <div class="content__item-wrap"> <div class="content__item p0 b-none"> <div class="content__item-btn dropdown"> <button class="dropdown__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8 11.365a1.817 1.817 0 010 3.632 1.817 1.817 0 010-3.632zm0-5.191a1.826 1.826 0 010 3.65 1.826 1.826 0 010-3.65zm0-5.171a1.81 1.81 0 11-.001 3.617A1.81 1.81 0 018 1.003z"></path></svg></button> <div class="dropdown__content"> <a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M7.919 12.563c-.856.567-2.304 1.504-3.757 2.444-.226.19-.542.237-.858.111-.46-.184-.552-.645-.368-1.105l1.197-4.512L.929 6.567c-.174-.141-.295-.353-.295-.565 0-.46.368-.737.736-.737h4.173l1.683-3.928C7.38.987 7.658.793 8 .793h.008c.338.005.614.196.766.544l1.684 3.928h4.172c.368 0 .737.277.737.737 0 .212-.122.424-.296.565l-3.203 2.934 1.197 4.512c.184.46.092.921-.369 1.105-.315.126-.631.079-.858-.111A503.075 503.075 0 018 12.509l-.081.054z"></path></svg><span>Make a leader</span></a><a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0c4.415 0 8 3.585 8 8s-3.585 8-8 8-8-3.585-8-8 3.585-8 8-8zm.999 11a1 1 0 10-2 0 1 1 0 002 0zm0-6a1 1 0 00-2 0v3a1 1 0 002 0V5z"></path></svg><span>Report </span></a></div> </div> <div class="content__item-img dn name-color-I"> <span>I</span></div> <div class="content__item-content"> <div class="content__item-top sm"> <div class="content__item-top-info"> <div class="content__item-img name-color-I"> <span>I</span></div> <div class="content__item-top-div"> <a class="content__item-top-name" href="#!">IlyaMalyukov</a><span class="content__item-top-p">2020-12-04 23:23:59</span></div> </div> </div> <a class="content__item-top-category" href="/category/ruby-on-rails">Ruby on Rails </a> <div class="content__item-row dn"> <a href="#!"><b>IlyaMalyukov</b>,</a> 2020-12-04 23:23:59</div> <p class="content__item-title large">Undefined method `user_id' for #. What is the problem?</p> <p class="content__item-detail sm"> I need to make sure that only the author of the post can edit it. <br> I just recently started learning Rails and the backend in general. <br> I tried to fix it for a long time, but it did not work. <br> <br> models<br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">Task</span> < ApplicationRecord</span> validates <span class="hljs-symbol">:title</span>, <span class="hljs-symbol">:content</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> has_rich_text <span class="hljs-symbol">:content</span> <span class="hljs-keyword">end</span></code></pre><br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">User</span> < ApplicationRecord</span> <span class="hljs-keyword">attr_accessor</span> <span class="hljs-symbol">:remember_token</span>, <span class="hljs-symbol">:activation_token</span>, <span class="hljs-symbol">:reset_token</span> before_save <span class="hljs-symbol">:downcase_email</span> before_create <span class="hljs-symbol">:create_activation_digest</span> validates <span class="hljs-symbol">:login</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:fullname</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> VALID_EMAIL_REGEX = <span class="hljs-regexp">/\A[\w+\-.][email protected][a-z\d\-.]+\.[a-z]+\z/i</span> validates <span class="hljs-symbol">:email</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span>, <span class="hljs-symbol">format:</span> { <span class="hljs-symbol">with:</span> VALID_EMAIL_REGEX }, <span class="hljs-symbol">uniqueness:</span> { <span class="hljs-symbol">case_sensitive:</span> <span class="hljs-literal">false</span> } has_secure_password validates <span class="hljs-symbol">:password</span>, <span class="hljs-symbol">length:</span> { <span class="hljs-symbol">minimum:</span> <span class="hljs-number">6</span> }, <span class="hljs-symbol">allow_blank:</span> <span class="hljs-literal">true</span> <span class="hljs-comment"># Возвращает дайджест для указанной строки.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">User</span>.<span class="hljs-title">digest</span><span class="hljs-params">(string)</span></span> cost = ActiveModel::SecurePassword.min_cost ? BCrypt::Engine::MIN_COST : BCrypt::Engine.cost BCrypt::Password.create(string, <span class="hljs-symbol">cost:</span> cost) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Возвращает случайный токен.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">User</span>.<span class="hljs-title">new_token</span></span> SecureRandom.urlsafe_base64 <span class="hljs-keyword">end</span> <span class="hljs-comment"># Запоминает пользователя в базе данных для использования в постоянных сеансах.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">remember</span></span> <span class="hljs-keyword">self</span>.remember_token = User.new_token update_attribute(<span class="hljs-symbol">:remember_digest</span>, User.digest(remember_token)) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Возвращает true, если указанный токен соответствует дайджесту.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">authenticated?</span><span class="hljs-params">(remember_token)</span></span> <span class="hljs-keyword">return</span> <span class="hljs-literal">false</span> <span class="hljs-keyword">if</span> remember_digest.<span class="hljs-literal">nil</span>? BCrypt::Password.new(remember_digest).is_password?(remember_token) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Забывает пользователя</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">forget</span></span> update_attribute(<span class="hljs-symbol">:remember_digest</span>, <span class="hljs-literal">nil</span>) <span class="hljs-keyword">end</span> validates <span class="hljs-symbol">:address</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:city</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:state</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:country</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:zip</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> validates <span class="hljs-symbol">:role</span>, <span class="hljs-symbol">presence:</span> <span class="hljs-literal">true</span> <span class="hljs-comment"># Активирует учетную запись.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">activate</span></span> update_attribute(<span class="hljs-symbol">:activated</span>, <span class="hljs-literal">true</span>) update_attribute(<span class="hljs-symbol">:activated_at</span>, Time.zone.now) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Посылает письмо со ссылкой на страницу активации.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">send_activation_email</span></span> UserMailer.account_activation(<span class="hljs-keyword">self</span>).deliver_now <span class="hljs-keyword">end</span> <span class="hljs-comment"># Устанавливает атрибуты для сброса пароля.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_reset_digest</span></span> <span class="hljs-keyword">self</span>.reset_token = User.new_token update_attribute(<span class="hljs-symbol">:reset_digest</span>, User.digest(reset_token)) update_attribute(<span class="hljs-symbol">:reset_sent_at</span>, Time.zone.now) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Посылает письмо со ссылкой на форму ввода нового пароля.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">send_password_reset_email</span></span> UserMailer.password_reset(<span class="hljs-keyword">self</span>).deliver_now <span class="hljs-keyword">end</span> <span class="hljs-comment"># Возвращает true, если время для сброса пароля истекло.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">password_reset_expired?</span></span> reset_sent_at < <span class="hljs-number">2</span>.hours.ago <span class="hljs-keyword">end</span> private <span class="hljs-comment"># Преобразует адрес электронной почты в нижний регистр.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">downcase_email</span></span> <span class="hljs-keyword">self</span>.email = email.downcase <span class="hljs-keyword">end</span> <span class="hljs-comment"># Создает и присваивает токен активации и его дайджест.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create_activation_digest</span></span> <span class="hljs-keyword">self</span>.activation_token = User.new_token <span class="hljs-keyword">self</span>.activation_digest = User.digest(activation_token) <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span></code></pre><br> <br> controllers<br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">TasksController</span> < ApplicationController</span> before_action <span class="hljs-symbol">:set_task</span>, <span class="hljs-symbol">only:</span> [<span class="hljs-symbol">:show</span>, <span class="hljs-symbol">:edit</span>, <span class="hljs-symbol">:update</span>, <span class="hljs-symbol">:destroy</span>] <span class="hljs-comment">#before_action :logged_in_user, only: [:index, :edit, :update, :destroy]</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">index</span></span> @tasks = Task.all <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show</span></span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">new</span></span> @task = Task.new <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">edit</span></span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create</span></span> @task = Task.new(task_params) @task.user_id = current_user.id respond_to <span class="hljs-keyword">do</span> <span class="hljs-params">|format|</span> <span class="hljs-keyword">if</span> @task.save format.html { redirect_to @task, <span class="hljs-symbol">notice:</span> <span class="hljs-string">'Задание опубликовано!'</span> } format.json { render <span class="hljs-symbol">:show</span>, <span class="hljs-symbol">status:</span> <span class="hljs-symbol">:created</span>, <span class="hljs-symbol">location:</span> @task } <span class="hljs-keyword">else</span> format.html { render <span class="hljs-symbol">:new</span> } format.json { render <span class="hljs-symbol">json:</span> @task.errors, <span class="hljs-symbol">status:</span> <span class="hljs-symbol">:unprocessable_entity</span> } <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">update</span></span> <span class="hljs-keyword">if</span> @task.user_id == current_user.id respond_to <span class="hljs-keyword">do</span> <span class="hljs-params">|format|</span> <span class="hljs-keyword">if</span> @task.update(task_params) format.html { redirect_to @task, <span class="hljs-symbol">notice:</span> <span class="hljs-string">'Задание обновлено!'</span> } format.json { render <span class="hljs-symbol">:show</span>, <span class="hljs-symbol">status:</span> <span class="hljs-symbol">:ok</span>, <span class="hljs-symbol">location:</span> @task } <span class="hljs-keyword">else</span> format.html { render <span class="hljs-symbol">:edit</span> } format.json { render <span class="hljs-symbol">json:</span> @task.errors, <span class="hljs-symbol">status:</span> <span class="hljs-symbol">:unprocessable_entity</span> } <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">else</span> redirect_to root_path, <span class="hljs-symbol">notice:</span> <span class="hljs-string">'Нет доступа!'</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">destroy</span></span> @task.destroy respond_to <span class="hljs-keyword">do</span> <span class="hljs-params">|format|</span> format.html { redirect_to tasks_url, <span class="hljs-symbol">notice:</span> <span class="hljs-string">'Задание удалено!'</span> } format.json { head <span class="hljs-symbol">:no_content</span> } <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> private <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">set_task</span></span> @task = Task.find(params[<span class="hljs-symbol">:id</span>]) <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">task_params</span></span> params.<span class="hljs-keyword">require</span>(<span class="hljs-symbol">:task</span>).permit(<span class="hljs-symbol">:title</span>, <span class="hljs-symbol">:content</span>) <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span></code></pre><br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">UsersController</span> < ApplicationController</span> before_action <span class="hljs-symbol">:logged_in_user</span>, <span class="hljs-symbol">only:</span> [<span class="hljs-symbol">:index</span>, <span class="hljs-symbol">:edit</span>, <span class="hljs-symbol">:update</span>, <span class="hljs-symbol">:destroy</span>] before_action <span class="hljs-symbol">:correct_user</span>, <span class="hljs-symbol">only:</span> [<span class="hljs-symbol">:edit</span>, <span class="hljs-symbol">:update</span>] before_action <span class="hljs-symbol">:admin_user</span>, <span class="hljs-symbol">only:</span> <span class="hljs-symbol">:destroy</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">index</span></span> @users = User.paginate(<span class="hljs-symbol">page:</span> params[<span class="hljs-symbol">:page</span>]) <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">show</span></span> @user = User.find(params[<span class="hljs-symbol">:id</span>]) <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">new</span></span> @user = User.new <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">create</span></span> @user = User.new(user_params) <span class="hljs-keyword">if</span> @user.save log_in @user <span class="hljs-comment"># <span class="hljs-doctag">@user</span>.send_activation_email (log_in <span class="hljs-doctag">@user</span> нужно удалить)</span> <span class="hljs-comment"># flash[:info] = "Пожалуйста, проверьте вашу электронную почту для активации аккаунта."</span> redirect_to root_url <span class="hljs-keyword">else</span> render <span class="hljs-string">'new'</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">edit</span></span> @user = User.find(params[<span class="hljs-symbol">:id</span>]) <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">update</span></span> @user = User.find(params[<span class="hljs-symbol">:id</span>]) <span class="hljs-keyword">if</span> @user.update_attributes(user_params) flash[<span class="hljs-symbol">:success</span>] = <span class="hljs-string">"Профиль обновлён!"</span> redirect_to @user <span class="hljs-keyword">else</span> render <span class="hljs-string">'edit'</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">destroy</span></span> User.find(params[<span class="hljs-symbol">:id</span>]).destroy flash[<span class="hljs-symbol">:success</span>] = <span class="hljs-string">"Пользователь удалён"</span> redirect_to users_url <span class="hljs-keyword">end</span> private <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">user_params</span></span> params.<span class="hljs-keyword">require</span>(<span class="hljs-symbol">:user</span>).permit(<span class="hljs-symbol">:login</span>, <span class="hljs-symbol">:fullname</span>, <span class="hljs-symbol">:email</span>, <span class="hljs-symbol">:address</span>, <span class="hljs-symbol">:city</span>, <span class="hljs-symbol">:state</span>, <span class="hljs-symbol">:country</span>, <span class="hljs-symbol">:zip</span>, <span class="hljs-symbol">:role</span>, <span class="hljs-symbol">:password</span>, <span class="hljs-symbol">:password_confirmation</span>) <span class="hljs-keyword">end</span> <span class="hljs-comment"># Предварительные фильтры</span> <span class="hljs-comment"># Подтверждает права пользователя.</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">correct_user</span></span> @user = User.find(params[<span class="hljs-symbol">:id</span>]) redirect_to(root_url) <span class="hljs-keyword">unless</span> current_user?(@user) <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span></code></pre><br> <br> schema<br> <br> <pre><code class="ruby hljs">ActiveRecord::Schema.define(<span class="hljs-symbol">version:</span> <span class="hljs-number">2020_12_02_210215</span>) <span class="hljs-keyword">do</span> <span class="hljs-comment"># These are extensions that must be enabled in order to support this database</span> enable_extension <span class="hljs-string">"plpgsql"</span> create_table <span class="hljs-string">"action_text_rich_texts"</span>, <span class="hljs-symbol">force:</span> <span class="hljs-symbol">:cascade</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-string">"name"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.text <span class="hljs-string">"body"</span> t.string <span class="hljs-string">"record_type"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.bigint <span class="hljs-string">"record_id"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"created_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"updated_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.index [<span class="hljs-string">"record_type"</span>, <span class="hljs-string">"record_id"</span>, <span class="hljs-string">"name"</span>], <span class="hljs-symbol">name:</span> <span class="hljs-string">"index_action_text_rich_texts_uniqueness"</span>, <span class="hljs-symbol">unique:</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">end</span> create_table <span class="hljs-string">"active_storage_attachments"</span>, <span class="hljs-symbol">force:</span> <span class="hljs-symbol">:cascade</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-string">"name"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"record_type"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.bigint <span class="hljs-string">"record_id"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.bigint <span class="hljs-string">"blob_id"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"created_at"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.index [<span class="hljs-string">"blob_id"</span>], <span class="hljs-symbol">name:</span> <span class="hljs-string">"index_active_storage_attachments_on_blob_id"</span> t.index [<span class="hljs-string">"record_type"</span>, <span class="hljs-string">"record_id"</span>, <span class="hljs-string">"name"</span>, <span class="hljs-string">"blob_id"</span>], <span class="hljs-symbol">name:</span> <span class="hljs-string">"index_active_storage_attachments_uniqueness"</span>, <span class="hljs-symbol">unique:</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">end</span> create_table <span class="hljs-string">"active_storage_blobs"</span>, <span class="hljs-symbol">force:</span> <span class="hljs-symbol">:cascade</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-string">"key"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"filename"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"content_type"</span> t.text <span class="hljs-string">"metadata"</span> t.bigint <span class="hljs-string">"byte_size"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"checksum"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"created_at"</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.index [<span class="hljs-string">"key"</span>], <span class="hljs-symbol">name:</span> <span class="hljs-string">"index_active_storage_blobs_on_key"</span>, <span class="hljs-symbol">unique:</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">end</span> create_table <span class="hljs-string">"tasks"</span>, <span class="hljs-symbol">force:</span> <span class="hljs-symbol">:cascade</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-string">"title"</span> t.text <span class="hljs-string">"content"</span> t.datetime <span class="hljs-string">"created_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"updated_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> <span class="hljs-keyword">end</span> create_table <span class="hljs-string">"users"</span>, <span class="hljs-symbol">force:</span> <span class="hljs-symbol">:cascade</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-string">"login"</span> t.string <span class="hljs-string">"fullname"</span> t.string <span class="hljs-string">"email"</span> t.string <span class="hljs-string">"address"</span> t.string <span class="hljs-string">"city"</span> t.string <span class="hljs-string">"state"</span> t.string <span class="hljs-string">"country"</span> t.string <span class="hljs-string">"zip"</span> t.string <span class="hljs-string">"role"</span> t.datetime <span class="hljs-string">"created_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"updated_at"</span>, <span class="hljs-symbol">precision:</span> <span class="hljs-number">6</span>, <span class="hljs-symbol">null:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"password_digest"</span> t.string <span class="hljs-string">"remember_digest"</span> t.boolean <span class="hljs-string">"admin"</span>, <span class="hljs-symbol">default:</span> <span class="hljs-literal">false</span> t.string <span class="hljs-string">"activation_digest"</span> t.boolean <span class="hljs-string">"activated"</span>, <span class="hljs-symbol">default:</span> <span class="hljs-literal">false</span> t.datetime <span class="hljs-string">"activated_at"</span> t.string <span class="hljs-string">"reset_digest"</span> t.datetime <span class="hljs-string">"reset_sent_at"</span> t.index [<span class="hljs-string">"email"</span>], <span class="hljs-symbol">name:</span> <span class="hljs-string">"index_users_on_email"</span>, <span class="hljs-symbol">unique:</span> <span class="hljs-literal">true</span> <span class="hljs-keyword">end</span> add_foreign_key <span class="hljs-string">"active_storage_attachments"</span>, <span class="hljs-string">"active_storage_blobs"</span>, <span class="hljs-symbol">column:</span> <span class="hljs-string">"blob_id"</span> <span class="hljs-keyword">end</span></code></pre><br> <br> migrate<br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CreateTasks</span> < ActiveRecord::Migration[6.0]</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">change</span></span> create_table <span class="hljs-symbol">:tasks</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-symbol">:title</span> t.text <span class="hljs-symbol">:content</span> t.timestamps <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span></code></pre><br> <br> <pre><code class="ruby hljs"><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">CreateUsers</span> < ActiveRecord::Migration[6.0]</span> <span class="hljs-function"><span class="hljs-keyword">def</span> <span class="hljs-title">change</span></span> create_table <span class="hljs-symbol">:users</span> <span class="hljs-keyword">do</span> <span class="hljs-params">|t|</span> t.string <span class="hljs-symbol">:login</span> t.string <span class="hljs-symbol">:fullname</span> t.string <span class="hljs-symbol">:email</span> t.string <span class="hljs-symbol">:address</span> t.string <span class="hljs-symbol">:city</span> t.string <span class="hljs-symbol">:state</span> t.string <span class="hljs-symbol">:country</span> t.string <span class="hljs-symbol">:zip</span> t.string <span class="hljs-symbol">:role</span> t.timestamps <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span> <span class="hljs-keyword">end</span></code></pre> </p> <div class="content__action"> <div class="content__action-left"> <a href="https://askmeplz.com/q/undefined-method-user-id-for-what-is-the-problem#answer" class="content__form-button lg" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="DY2o8"> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>Reply </span> </a> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M7.125 14.998c-.003 0-1.516.026-2.28-.635-.825-.714-.845-1.99-.845-1.99V8.961s-.003-1.885.754-2.756c.757-.872 2.431-1.886 2.96-2.614.529-.729.834-1.722 1.672-1.722.837 0 1.239.521 1.239 1.311 0 .377-.349 1.144-.349 2.193 0 .408.34.625.893.625H13c1.263 0 2 .771 2 2 0 .653-.359 1.223-.889 1.524a1.751 1.751 0 01-.876 1.75 1.751 1.751 0 01-.875 1.75 1.75 1.75 0 01-1.735 1.976h-3.5zM3 7.56c0-.724-.276-1.312-1-1.312S1 6.836 1 7.56v6.125c0 .725.276 1.313 1 1.313s1-.588 1-1.313V7.56z"></path></svg></button> </div> <div class="content__action-right"> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="QKbwC"><path fill-rule="evenodd" d="M13 2.779C13 1.796 12.204 1 11.221 1H4.779C3.796 1 3 1.796 3 2.779v11.192a1 1 0 001.746.667l2.793-3.123a.618.618 0 01.922 0l2.793 3.123A1.001 1.001 0 0013 13.971V2.779zm-2 .82a.6.6 0 00-.601-.601H5.607A.608.608 0 005 3.606v7.272a.232.232 0 00.402.158l2.146-2.292a.619.619 0 01.904 0l2.151 2.298a.23.23 0 10.397-.157V3.599z"></path></svg></button> <button class="content__action-btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8.88 3.37a.3.3 0 00.122-.252A3.001 3.001 0 0115 3a3.001 3.001 0 01-4.951 2.278.292.292 0 00-.366-.017c-.564.407-2.189 1.588-2.649 1.922a.233.233 0 00-.09.234 3.098 3.098 0 01-.001 1.166.234.234 0 00.091.234l2.648 1.924a.295.295 0 00.368-.018A2.978 2.978 0 0112 10a3.001 3.001 0 010 6 3.001 3.001 0 01-2.998-3.118.295.295 0 00-.122-.251l-2.896-2.105a.315.315 0 00-.358-.007A2.968 2.968 0 014 11a3.001 3.001 0 010-6c.599 0 1.158.176 1.627.48.108.072.25.069.355-.007.58-.419 2.392-1.736 2.898-2.103z"></path></svg></button> </div> <a href="https://askmeplz.com/q/undefined-method-user-id-for-what-is-the-problem#answer" class="content__form-button sm" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="DY2o8"><path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>Answer the question</span></a> </div> </div> </div> <a name="answer"></a> </div> </div> </div> <div class="content"> <div class="content__header bb-none"> <p class="content__title dn">Answer the question</p> <div class="content__form"> <p>In order to leave comments, you need to <a href=вход.html>log in</a></p> </div> </div> </div> <div class="content"> <div class="content__header bb-none answer-wrapper"> <a class="content__title mb0 answer-title" href="#!">1 answer(s) </a> <div class="answer"> <div class="content__item-btn dropdown"> <button class="dropdown__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""><path fill-rule="evenodd" d="M8 11.365a1.817 1.817 0 010 3.632 1.817 1.817 0 010-3.632zm0-5.191a1.826 1.826 0 010 3.65 1.826 1.826 0 010-3.65zm0-5.171a1.81 1.81 0 11-.001 3.617A1.81 1.81 0 018 1.003z"></path></svg></button> <div class="dropdown__content"> <a class="dropdown__item" href="#!"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8 0c4.415 0 8 3.585 8 8s-3.585 8-8 8-8-3.585-8-8 3.585-8 8-8zm.999 11a1 1 0 10-2 0 1 1 0 002 0zm0-6a1 1 0 00-2 0v3a1 1 0 002 0V5z"></path></svg><span>Report </span></a></div> </div> <div class="answer__header"> <div class="content__item-img large name-color-N"><span>N</span></div><span class="answer__name"><a href="#!">N. Bekseitov</a>, 2020-12-07 <br/> @nbekseitov</span> </div> <p class="answer__detail">connection between User and Task models is not established: rusrails.ru/active-record-associations#svyaz-belongs_to</p> <div class="answer__action"> <button class="answer__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="qWxAZ YJAqn"><path fill-rule="evenodd" d="M7.125 14.998c-.003 0-1.516.026-2.28-.635-.825-.714-.845-1.99-.845-1.99V8.961s-.003-1.885.754-2.756c.757-.872 2.431-1.886 2.96-2.614.529-.729.834-1.722 1.672-1.722.837 0 1.239.521 1.239 1.311 0 .377-.349 1.144-.349 2.193 0 .408.34.625.893.625H13c1.263 0 2 .771 2 2 0 .653-.359 1.223-.889 1.524a1.751 1.751 0 01-.876 1.75 1.751 1.751 0 01-.875 1.75 1.75 1.75 0 01-1.735 1.976h-3.5zM3 7.56c0-.724-.276-1.312-1-1.312S1 6.836 1 7.56v6.125c0 .725.276 1.313 1 1.313s1-.588 1-1.313V7.56z"></path></svg>Like</button> <button class="answer__btn" type="button"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class="qPhqc"><path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path></svg><span>0 </span>comments</button> </div> </div> </div> </div> <div class="content similar"> <div class="content__header bb-none"> <span class="content__title mb0 w-svg"> Similar questions </span> <div class="content__item-wrap"> <div class="content__item"> <div class="content__item-img name-color-E"> <span>E</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/rails-4-russian-characters-in-base-cause-error">Evgeny Elchev</a><span>2014-10-22 21:09:17</span></div> <a class="content__item-title similar" href="/q/rails-4-russian-characters-in-base-cause-error">Rails 4 Russian characters in base cause error?</a> <a class="content__item-button" href="/q/rails-4-russian-characters-in-base-cause-error"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">4</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-A"> <span>A</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/how-to-split-activeadmin-into-two-parts">Anton</a><span>2016-10-24 20:15:29</span></div> <a class="content__item-title similar" href="/q/how-to-split-activeadmin-into-two-parts">How to split ActiveAdmin into two parts?</a> <a class="content__item-button" href="/q/how-to-split-activeadmin-into-two-parts"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">3</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-N"> <span>N</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/how-to-remove-extra-slashes-from-url-in-rails-app-on-heroku">Nikita</a><span>2014-10-30 01:22:47</span></div> <a class="content__item-title similar" href="/q/how-to-remove-extra-slashes-from-url-in-rails-app-on-heroku">How to remove extra slashes from URL in Rails app on Heroku?</a> <a class="content__item-button" href="/q/how-to-remove-extra-slashes-from-url-in-rails-app-on-heroku"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-R"> <span>R</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/rails-form-for-how-to-make-form-generate-path-without-module">Ruslan Galiev</a><span>2014-10-30 13:48:13</span></div> <a class="content__item-title similar" href="/q/rails-form-for-how-to-make-form-generate-path-without-module">Rails form_for how to make form generate path without module?</a> <a class="content__item-button" href="/q/rails-form-for-how-to-make-form-generate-path-without-module"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">1</span><span class="dn">Reply</span> </a> </div> </div><div class="content__item"> <div class="content__item-img name-color-A"> <span>A</span></div> <div class="content__item-content"> <div class="content__item-row"> <a href="/q/how-to-overcome-rails-cache">Alexander Wolf</a><span>2014-10-31 00:13:57</span></div> <a class="content__item-title similar" href="/q/how-to-overcome-rails-cache">How to overcome rails cache?</a> <a class="content__item-button" href="/q/how-to-overcome-rails-cache"> <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" class=""> <path fill-rule="evenodd" d="M15 14a1.002 1.002 0 01-1.703.71h-.004l-.003-.01-1.704-1.7H3c-1.104 0-2-.9-2-2V3c0-1.1.896-2 2-2h10c1.104 0 2 .9 2 2v11zM5 6c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1zm3 0c.552 0 1 .45 1 1s-.448 1-1 1-1-.45-1-1 .448-1 1-1z"></path> </svg> <span class="dark">3</span><span class="dn">Reply</span> </a> </div> </div> </div> </div> </div> <div class="content find"> <p class="find__p">Didn't find what you were looking for?</p><a class="find__btn" href="#!">Ask your question</a> </div> <div class="find sm"> <p class="find__title">Ask a Question </p> <form class="find__form" action="#!"> <input class="find__input" type="text" placeholder="Ask your question here"> <button class="find__btn" type="submit"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 16 16" class="nBqR1"><path fill-rule="evenodd" d="M12.696 7.256L9.657 4.217a1 1 0 00-1.415 1.414l1.344 1.344H3.949a1.001 1.001 0 000 2h5.637l-1.344 1.343a1.002 1.002 0 000 1.415c.391.39 1.024.39 1.415 0l3.039-3.04A.993.993 0 0013 7.975a.997.997 0 00-.293-.708l-.011-.011z"></path></svg></button> </form> <p class="find__span">731 491 924 answers to any question</p> </div> </div> <aside class="banners"> <p>banners </p> </aside> </div> </main> </div> <script src="/assets/theme/js/highlight/highlight.min.js"></script> <script src="/assets/theme/js/app.min.js?_v=20220404145216"> </script> <script>hljs.highlightAll();</script> </body> </html>