消息中的NoMethodError#new#undefined方法`simple_form_for'用于#&lt;#<class:0x0000000d639ba8>:0x0000000ed05cd8&gt;

时间:2017-11-15 04:42:24

标签: ruby-on-rails rubymine

帮助我不知道我做错了什么。我已经安装了gem,将它们放在我的gem文件中,安装了bundle,然后使用rails s重新启动了服务器。为什么我会收到此错误?

_form.html.erb:

<% simple_form_for @message do |f| %>
  <%= f.input :title, label: "Message Title" %>
  <%= f.input :description %>
  <%= f.button :submit %>
<% end %>

messages_controller.rb:

class MessagesController < ApplicationController


  def index
  end

  def new
    @message = Message.new
  end

  def create
    @message = Message.new(message_params)
  end

  private

    def message_params
      params.require(:message).permit(:title, :description)
    end

end

gem文件:

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end

gem 'rails', '~> 5.1.4'
gem 'sqlite3'
gem 'puma', '~> 3.7'
gem 'sass-rails', '~> 5.0'
gem 'simple_form', '~> 3.5'
gem 'bootstrap-sass', '~> 3.3', '>= 3.3.7'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.2'
gem 'turbolinks', '~> 5'
gem 'jbuilder', '~> 2.5'

group :development, :test do
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'
end

group :development do
  gem 'web-console', '>= 3.3.0'
end

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

0 个答案:

没有答案