problem description
Why do you say undefined method here
the environmental background of the problems and what methods you have tried
related codes
/ / Please paste the code text below (do not replace the code with pictures)
.parameters-area
.parameters
%h4 Parameters
-sharpparameters-panel
= parentform.fields_for :model_params, parentform.object.model_params.sort_by{|o| o.name.to_s.downcase } do |t|
.panel
.row{data:{"parameter-root": "true"}}
.medium-11.columns
.row
.medium-11.columns
= t.input :name
= t.input :data_type,collection: ModelParam.data_types.keys.to_a, input_html: {data: {"root-type": "true"}}
this is my model_param data definition
class CreateModelParams < ActiveRecord::Migration
def change
create_table :model_params do |t|
t.string :name
t.integer :data_type
t.integer :model_id
t.timestamps
end
add_index :model_params, :model_id
end
end
here is my controller
class ModelController < ApplicationController
skip_authorization_check
def index
@hostname = request.host
@hostport = request.port.to_s
@model = Model.all
@user_relations =Relation.where(user_id: current_user)
@p_id = get_project_id
end
def new
@model=Model.new
@p_id=get_project_id
end
def create
@model = Model.new(m_params)
if @model.name.strip.length != 0
if @model.save
redirect_to project_model_index_path, notice: "Model was successfully created."
else
render "new"
end
else
render "new"
end
end
def destroy
end
end
def show
@hostname = request.host
@hostport = request.port.to_s
end
def update
end
def get_project_id
params[:project_id]
end
def m_params
params.require(:model).permit(:name,:description,:response, model_params_attributes: [:id, :name, :data_type, :_destroy])
end
def get_id
params[:id]
end