Railsでフォームを作っている際に、下記のエラーが発生しました。
ArgumentError in Goodthing#index
Showing /home/ec2-user/environment/web-app/app/views/goodthing/index.html.erb where line #8 raised:
First argument in form cannot contain nil or be empty
Extracted source (around line #8):
7 <div>
8 <%= form_for(@goodthing_form, url :goodthing_path, :method => :GET) do |f| %>
9 <fieldset>
10 <legend><%= t(".filter") %></legend>
controllerはこちらになります。
class GoodthingController < BaseController set_function_label :user_management end def index @goodthing_form = GoodthingForm.new(goodthing_form_params) @date_from = @goodthing_form.from @date_to = @goodthing_form.to @name = @goodthing_form.name @group = @goodthing_form.group @users_name = current_organization.users.without_soft_destroyed.map {|user| user.profile.name } @groups_name = current_organization.groups.map {|group| group.name } # params[:search].each do |k, v| # instance_variable_set("@#{k}", v.strip) # end if params[:search].present? if @goodthing_form.valid? ar = current_organization.users.without_soft_destroyed.joins(groups,:profile,:comments).includes(:profile,:comments) ar = ar.where("`profile.open_goodthing LIKE ?", true) ar = ar.where("`groups.name LIKE ?", "%#{@group}%") if @group.present? ar = ar.where("profiles.name LIKE ?", "%#{@name}%") if @name.present? ar = ar.where("comments.recorded_on >= ?", @date_from) if @date_from.present? ar = ar.where("comments.recorded_on >= ?", @date_to) if @date_to.present? @search_users = ar.order(:id).page(params[:page]).per(150).select("users.id as id, profiles.name as name, comments.recorded_on as recorded_on") end
@goodthing_formのコントローラー部の定義が間違っていると推測しているのですが、どこが間違っているかがわかりません。
原因を教えていただけると幸いです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。