ruby on railsでアプリ作成中にNil location provided. Can't build URI.というエラーが出てしまい解決に困っています。
メッセージで、体温、症状、症状詳細を送信をしたいのですが
エラーが発生
発生している問題・エラーメッセージ
該当のソースコード
routes.rb
Rails.application.routes.draw do devise_for :users # root 'messages#index' root 'groups#index' resources :users, only: [:edit, :update] resources :groups, only: [:index, :new, :create, :edit, :update] resources :members, only: [:index,:edit] do resources :messages, only: [:index, :create] end # For details on the DSL available within this file, see https://guides.rubyonrails.org/routing.html end
messages_controller.rb
class MessagesController < ApplicationController before_action :set_group def index @message = Message.new @messages = @group.messages.includes(:user) end def create @message = @group.messages.new(message_params) if @message.save redirect_to group_messages_path(@group), notice: 'メッセージが送信されました' else @messages = @group.messages.includes(:user) flash.now[:alert] = 'メッセージを入力してください。' render :index end end private def message_params params.require(:message).permit(:ondo, :symptom, :Textarea).merge(user_id: current_user.id) end def set_group @group = Group.find(params[:group_id]) end end
messages.rb
class Message < ApplicationRecord belongs_to :group belongs_to :user validates :ondo, presence: true validates :Textarea, presence: true validates :symptom, presence: true, inclusion: { in: 1..2 } end
20200730021825_create_messages.rb
class CreateMessages < ActiveRecord::Migration[6.0] def change create_table :messages do |t| t.integer :ondo t.integer :symptom t.string :Textarea t.references :group, foreign_key: true t.references :user, foreign_key: true t.timestamps end end end
message送信のview
.side .side__Header .side__Header--Box %ul.list %li.list__list-icon =link_to edit_user_path(current_user) do = icon('fas', 'user-edit') %span.name = icon('fas', 'user-circle') =current_user.name .side__Contents -# - current_user.groups.each do |group| -# .Group -# = link_to '#' do -# .Group__name -# = group.name .side__Contents--Box .side__Footer = form_with model: [@group, @message], html: {class: "Form"}, local: true do |f| -# .Form__contents -# = f.text_field :content, class: 'Form__inputContent', placeholder: 'type a message' -# = f.submit 'Send', class: 'Form__submit' -# %form.Form -# .Form__Heat -# %span.heat -# 体温 -# %select.Field{:name => "ondo",required:""} -# %option{:value => ""} - - - - - - -# %option{:value => "1",} 36.4以下 -# %option{:value => "2",} 36.5 -# %option{:value => "3"} 36.6 -# %option{:value => "4"} 36.7 -# %option{:value => "5"} 36.8 -# %option{:value => "6"} 36.9 -# %option{:value => "7"} 37.0 -# %option{:value => "8"} 37.1 -# %option{:value => "9"} 37.2 -# %option{:value => "10"} 37.3 -# %option{:value => "11"} 37.4 -# %option{:value => "12"} 37.5 -# %option{:value => "13"} 37.6 -# %option{:value => "14"} 37.7 -# %option{:value => "15"} 37.8 -# %option{:value => "16"} 37.9 -# %option{:value => "17"} 38.0 -# %option{:value => "18"} 38.1 -# %option{:value => "19"} 38.2 -# %option{:value => "20"} 38.3 -# %option{:value => "21"} 38.4 -# %option{:value => "22"} 38.5 -# %option{:value => "23"} 38.6以上 -# .Form__Symptom -# %span.symptom -# 症状 -# .Form__Symptom--Box -# %input.Form__radio--button{type: "radio", name:"symptom", value: "1", required: ""} 有 -# %input.Form__radio--button{type: "radio",name:"symptom", value: "2"} 無 -# %span 入力必須 -# .Form__Textarea -# %span.textarea -# 症状詳細 -# %textarea.Form__textContent{type: "textarea"} -# %button.Form__submit{type: "submit"} -# 送信
ターミナルで確認すると体温、症状、のデータしか送られない事が判明。
現状他に何が原因なのかが手詰まってしまいアドバイスいただけると幸いです。