Home>
error

I am creating an app and I wanted to be able to set a user's profile image using refile and minimagick, but when I wrote the image posting form f.attachment_field, I got the following error It has come out.
NoMethodError in Users # edit

File

gemfile

source'https://rubygems.org'
git_source (: github) {| repo | "https://github.com/#{repo}.git"}
ruby '2.6.3'
# Bundle edge Rails instead: gem'rails', github:'rails/rails'
gem'rails','~>5.2.4','>= 5.2.4.4'
# Use sqlite3 as the database for Active Record
gem'sqlite3'
#Use Puma as the app server
gem'puma','~>3.11'
#Use SCSS for stylesheets
gem'sass-rails','~>5.0'
#Use Uglifier as compressor for JavaScript assets
gem'uglifier','>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem'mini_racer', platforms :: ruby
#Use CoffeeScript for .coffee assets and views
gem'coffee-rails','~>4.2'
#Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem'turbolinks','~>5'
#Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem'jbuilder','~>2.5'
#Use Redis adapter to run Action Cable in production
# gem'redis','~>4.0'
# Use ActiveModel has_secure_password
# gem'bcrypt','~>3.1.7'
# Use ActiveStorage variant
# gem'mini_magick','~>4.8'
#Use Capistrano for deployment
# gem'capistrano-rails', group:: development
#Reduces boot times through caching;required in config/boot.rb
gem'bootsnap','>= 1.1.0', require: false
group: development,: test do
  #Call'byebug' anywhere in the code to stop execution and get a debugger console
  gem'byebug', platforms: [: mri,: mingw,: x64_mingw]
end
group: development do
  #Access an interactive console on exception pages or by calling'console' anywhere in the code.
  gem'web-console','>= 3.3.0'
  gem'listen','>= 3.0.5','<3.2'
  #Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem'spring'
  gem'spring-watcher-listen','~>2.0.0'
end
group: test do
  #Adds support for Capybara system testing and selenium driver
  gem'capybara','>= 2.15'
  gem'selenium-webdriver'
  #Easy installation and use of chromedriver to run system tests with Chrome
  gem'chromedriver-helper'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem'tzinfo-data', platforms: [: mingw,: mswin,: x64_mingw,: jruby]
gem "refile", require: "refile/rails", github:'manfe/refile'
gem "refile-mini_magick"
gem'devise'
gem'font-awesome-rails'
gem'bootstrap','~>4.1.1'
gem'jquery-rails'


devise migration file

#frozen_string_literal: true
class DeviseCreateUsers</pre>
<p><br />
<code>user.rb</code></p>
<pre><code data-language = "Ruby">class User</pre>
<p><br />
<code>application_controller</code></p>
<pre><code data-language = "Ruby">class ApplicationController</pre>
<p><code>users_controller</code></p><pre><code data-language = "Ruby">class UsersController</pre>
<p><br />
<code>views/users/edit.html</code></p>
<pre><code data-language = "Ruby"><section>           Edit       <% = form_with model: @user, local: true do | f |%>          <label for = "name_input">Name</label>    <% = f.text_field: name, class: "form-control", id: "name_input"%>                <label for = "img_input">Image</label>    <!-Location of the problem->    <% = f.attachment_field: profile_image, class: "form-control", id: "img_input"%>                <label for = "introduction_input">Introduction</label>    <% = f.text_area: introduction, class: "form-control", id: "introduction_input"%>          <% = f.submit'update', class: "btn btn-secondary w-100"%><% end%></section>
Layout

views/layout/application.html.erb

<! DOCTYPE html><html><head><title>Books2</title><% = csrf_meta_tags%><% = csp_meta_tag%><% = stylesheet_link_tag'application', media:'all','data-turbolinks-track':'reload'%><% = javascript_include_tag'application','data-turbolinks-track':'reload'%></head><body><% = render partial: "shered/header"%><% = yield%></body></html>


views/shared/_header.html.erb

<header>       Books   <ul><% if user_signed_in?%>  <li>      <!-Home->      <% = link_to user_path (current_user.id), class: "nav-link text-white" do%>          <% = fa_icon "home"%>Home
        <% end%>  </li>  <li>      <!-Users->      <% = link_to users_path, class: "nav-link text-white" do%>          <% = fa_icon "users"%>Users
        <% end%>  </li>  <li>      <!-Books->      <% = link_to books_path, class: "nav-link text-white" do%>          <% = fa_icon "book"%>Books
        <% end%>  </li>  <li>      <!-Log out->      <% = link_to destroy_user_session_path, method:: delete, class: "nav-link text-white" do%>          <% = fa_icon "sign-out"%>log out
        <% end%>  </li></ul><% else%>  <li>      <!-Home->      <% = link_to new_user_session_path, class: "nav-link text-white" do%>          <% = fa_icon "home"%>Home
        <% end%>  </li>  <li>      <!-About->      <% = link_to new_user_session_path, class: "nav-link text-white" do%>          <% = fa_icon "link"%>About
        <% end%>  </li>  <li>      <!-Sign up->      <% = link_to new_user_registration_path, class: "nav-link text-white" do%>          <% = fa_icon "user-plus"%>sign up
        <% end%>  </li>  <li>      <!-Sign in->      <% = link_to new_user_session_path, class: "nav-link text-white" do%>          <% = fa_icon "sign-in"%>login
        <% end%>  </li></ul><% end%></header>

If there are other files that you think are necessary, I will add them, so please comment.

  • Answer # 1

    The private position of user_controller was above edit.
    It's just a mistake. I apologize to you for a fuss over.