- 53
- 0
这里说我没有定义这个method,问题出在app/views/model/show.html.haml这个文件里。
我尝试了去controller 里面def show 里面有什么问题 可是 没发现有什么问题。
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
.show-param
.tabs-content
.parameter
.table-wrapper
%table
%caption
%strong Parameters
%thread
%td Name
%td DataType
%tbody
- @model.model_params.each do |p|
%tr
%td.font-bold{:width => "30%"}
= p.name
%td{:width=>"10%"}
= p.data_type
.row
= link_to 'Edit API Endpoint information', edit_project_model_path(), class: 'button tiny right small-margin-right-10'
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
def show
@hostname = request.host
@hostport = request.port.to_s
@model = Model.find(get_id)
@params =@model.model_params.all.order(name: :asc)
@p_id =get_project_id
end
相关代码
// 请把代码文本粘贴到下方(请勿用图片代替代码)
def m_params
params.require(:model).permit(:name,:description,:response,
model_params_attributes: [:id, :name, :data_type, :_destroy])
end
你期待的结果是什么?实际看到的错误信息又是什么?
- 共 0 条
- 全部回答
-
嘉图李的猫 普通会员 1楼
The
model_paramsmethod is a method that is defined in theActionView::Helpers::ModelHelperclass in the Rails framework. It is used to extract the data parameters from the model instance passed to thefindornewmethod. If you are trying to accessmodel_paramson anilobject, you are getting aundefined methoderror becausenilis not an instance of theModelHelper::Modelclass. To fix this error, you need to make sure that the model instance being passed to thefindornewmethod is notnil. If you are trying to access the model instance through a link or button that calls thefindornewmethod, make sure that the model instance exists and is notnilbefore calling the method. Here is an example of how you might usemodel_paramson anilobject in Rails:<%= link_to 'View Model', model_path(model: nil), method: :get %>In this example, the
model_path(model: nil)call would look for a model instance that has amodelattribute set tonil, and then retrieve the data parameters from that model instance usingmodel_params. If themodelattribute is not set tonil, themodel_paramsmethod will be called and the data parameters will be available for use in the link or button. Alternatively, you can also use theto_parammethod to get theidorclassof the model instance before accessing itsmodel_paramsmethod:<%= link_to 'View Model', model_path(model: nil), method: :get %>In this example, the
model_path(model: nil)call would look for a model instance that has amodelattribute set tonil, and then retrieve the data parameters from that model instance usingmodel_params. If themodelattribute is not set tonil, themodel_paramsmethod will be called and theidorclassof the model instance will be available for use in the link or button. In either case, make sure that the model instance being passed to thefindornewmethod is notniland that the data parameters are available before calling themodel_paramsmethod. If the data parameters are not available, theundefined methoderror will be raised.
- 扫一扫访问手机版
回答动态

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器更新之后。服务器里面有部分玩家要重新创建角色是怎么回事啊?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题函数计算不同地域的是不能用内网吧?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题ARMS可以创建多个应用嘛?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题在ARMS如何申请加入公测呀?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题前端小程序接入这个arms具体是如何接入监控的,这个init方法在哪里进行添加?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器刚到期,是不是就不能再导出存档了呢?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器的游戏版本不兼容 尝试更新怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器服务器升级以后 就链接不上了,怎么办?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器转移以后服务器进不去了,怎么解决?预计能赚取 0积分收益

- 神奇的四哥:发布了悬赏问题阿里云幻兽帕鲁服务器修改参数后游戏进入不了,是什么情况?预计能赚取 0积分收益
- 回到顶部
- 回到顶部
