The error message is telling you that you can’t have the following:
<%= form_for nil do |f| %>
<%= form_for [] do |f| %>
My guess here is that your @contact
is set to nil
and that it doesn’t come from your Contact#new
action.
FYI it would simply work if you do this:
<%= form_for Contact.new do |f| %>
Though it is not recommended.
You need to check that the view containing your form is actually rendered by the new
action of your ContactsController
.
Related Contents:
- How to get a random number in Ruby
- How to use concerns in Rails 4
- Rails update_attributes without save?
- Rails I18n validation deprecation warning
- How is attr_accessible used in Rails 4?
- Auto-loading lib files in Rails 4
- Paperclip::Errors::MissingRequiredValidatorError with Rails 4
- Determine what attributes were changed in Rails after_save callback?
- Rails: validate uniqueness of two columns (together)
- How to solve error “Missing `secret_key_base` for ‘production’ environment” (Rails 4.1)
- Rails 4 – Gem::LoadError: Specified ‘mysql2’ for database adapter, but the gem is not loaded
- Nested attributes unpermitted parameters
- How get integer value from a enum in Rails?
- Rails 4: assets not loading in production
- There was an error while trying to load the gem ‘uglifier’. (Bundler::GemRequireError)
- Disable ActiveRecord for Rails 4
- Rails 4 image-path, image-url and asset-url no longer work in SCSS files
- How to override X-Frame-Options for a controller or action in Rails 4
- Rails 4: organize rails models in sub path without namespacing models?
- Why am I asked to run ‘rake db:migrate RAILS_ENV=test’?
- Why Rails 5 uses ApplicationRecord instead of ActiveRecord::Base?
- ActionController::InvalidAuthenticityToken in RegistrationsController#create
- rails console doesn’t start
- Default value for input with simple_form
- Rails 4 Unpermitted Parameters for Array
- Add nullable foreign key in Rails
- Ruby on rails 4 app does not work in iframe
- PG::UndefinedTable: ERROR: missing FROM-clause entry for table when using joins and where
- “bin/rails: No such file or directory” w/ Ruby 2 & Rails 4 on Heroku
- Rails: NameError: uninitialized constant
- Rails: How to use dependent: :destroy in rails?
- Redis raises “NOAUTH Authentication required” error but there is no password setting
- Rails 4 find or create by method doesn’t work
- Running a spec in RubyMine results in “cannot load such file — teamcity/spec/runner/formatter/teamcity/formatter (LoadError)”
- ArgumentError: A copy of ApplicationController has been removed from the module tree but is still active
- How to create a migration to remove an index only if it exists, rather than throwing an exception if it doesn’t?
- expected true to respond to true?
- has_many :through with class_name and foreign_key
- ActionMailer not sending mail in development Rails 4
- In Rails 4.1, how to find records by enum symbol?
- Rails: DEPRECATION WARNING: You didn’t set config.secret_key_base
- Why use ‘reload’ method after saving object? (Hartl Rails Tut 6.30)
- Rails generate has_many association
- Rails 4.2 Server port forwarding on Vagrant does not work
- Rails 4, Capistrano 3.0.0, cannot load such file — deploy
- Possible to specify unique index with NULLs allowed in Rails/ActiveRecord?
- ActionController::InvalidAuthenticityToken when disable JS/Ajax request
- Rails 4 pgsql add_index with type GIN or GiST
- Rails 4 migration: how to reorder columns
- How do I clear my Rails file cache?