草庐IT

my_param

全部标签

ruby-on-rails - rails 5 : How to pass collection_select values through strong_params in a fields_for?

我已经尝试了所有视频和文章,但仍然找不到将fields_forcollection_select值加入strong_params白名单的解决方案。我花了好几天时间想弄明白(并问了很多人)。如果有人能花时间帮助我,我将不胜感激!我在List和Topic之间有一个多对多的关联,List_Topic充当连接模型。使用form_for,我为List的一个实例(@list)创建了一个表单,然后是一个fields_for:list_topics。在字段中,我创建了一个collection_select,它由Topic.all填充。在我的列表Controller中我有:classListsContr

ruby - 为什么我在运行 rake db :migrate on my fresh rails instance? 时总是出错

为什么我在运行rakedb:migrate时总是出现下面的错误...我已经关注了这封信https://github.com/plataformatec/devise#getting-started在设计githubreadme上,创建了一个全新的项目,仍然出现错误。创建了一个新的铁路应用:(成功)已将gem'devise'添加到我的Gemfile:(成功)安装包:(成功)运行Rails生成器:(成功)生成了一个名为User的设计模型:(成功)我在SQLite3:CantOpenException(uanbletoopendatabasefile)提到了SO问题这让我尝试使用返回db/d

ruby - 选择标记 : How to use params to set the selected value?

我有一个带有2个选项的选择标签:select_tag:type,options_for_select("Produit1Produit2",params[:product]),id:"different_option_value_html",onchange:"this.form.submit();",include_blank:"Whichproducts?"选择其中一个选项后,表单将自动提交。我想将参数保持在第一位。我的意思是在“whichproducts”的位置不点击选择就可见。 最佳答案 我终于更改了语法,使用它可以正常工作

ruby-on-rails - Ruby on Rails 教程 对 Params 哈希的工作原理感到困惑

所以我看到其他人对此感到困惑,我已经阅读了其他答案,但我仍然感到困惑。在删除请求期间,信息是如何存储和解析到参数散列中的?我了解它在向其提交信息方面的工作原理。即当发出Put、Post或Get请求时,我知道信息是通过paramshash传递给相应的Controller操作的。但是,基于用户部分(_user.html.erb)中的以下代码:以及自动路由到的DESTROY操作中的代码:defdestroyUser.find(params[:id]).destroyflash[:success]="Userdestroyed."redirect_tousers_urlend我不明白param

ruby-on-rails - 为什么在不传递 :id param work (in rails)? 的情况下重定向到 #show 操作

我有一个关于Rails的简单问题。我遵循了一个教程(来自CrashLearner)。在该教程中,我们有一个简单的资源message,它生成常规的后续路线(摘自rakeroutes)PrefixVerbURIPatternController#ActionmessagesGET/messages(.:format)messages#indexPOST/messages(.:format)messages#createnew_messageGET/messages/new(.:format)messages#newedit_messageGET/messages/:id/edit(.:fo

ruby-on-rails - Rails link_to params .id 而不是/id

我在创建链接时遇到了一个小问题。我的看法:'Erdusikker?',:method=>:delete%>输出:http://localhost:3000/blogs/5/comments.6它应该在哪里:http://localhost:3000/blogs/5/comments/6 最佳答案 blog_comments_path是博客所有评论的路径。如果您只想发表评论,则必须使用blog_comment_path(检查rakeroutes,我可能的语法有误。但是你明白了这个想法。)

ruby-on-rails - 更新到 Rails 3.2.2 : How to properly move my plugin from the '/vendor' to '/lib' directory?

我正在将RubyonRails从3.1升级到3.2.2,我想知道我应该做什么以及我应该注意什么以便正确移动我的供应商插件(注意:它不是一个gem,目前我不打算将它变成一个gem)从目录/vendor到/lib如officialdocumentation中所写:Rails3.2deprecatesvendor/pluginsandRails4.0willremovethemcompletely.YoucanstartreplacingthesepluginsbyextractingthemasgemsandaddingtheminyourGemfile.Ifyouchoosenottom

ruby-on-rails - Rails3 如何使用 :params in named scope?

我正在尝试显示特定订单的里程碑列表。(订单有很多里程碑。)在我的订单模型中,我有这个:scope:open,lambda{joins("joinmilestonesonmilestones.order_id=orders.id").where("order_id=?ANDmilestone_status=?",:params[:order_id],true).group("orders.id")}我遇到的问题是让当前订单ID起作用-:params[:order_id]显然是错误的。在我的route我有这个:resources:ordersdoresources:milestonesen

ruby - 使用 RSpec 测试纯 Ruby bin/my_app.rb 应用程序?

我有一个用纯Ruby编写的命令行(非RAILS)应用程序,我正在通过Cucumber和RSpec运行它。它遵循lib、bin、spec和feature目录的典型应用程序层次结构。到目前为止,我一直遵循编写失败的Cucumber功能/场景的传统流程,下降到RSpec以驱动支持的lib文件,然后让场景通过。不幸的是,在“bin/my_application.rb”中推出主应用程序入口点时,这似乎并不那么直接。对我来说主要问题是我不是在描述RSpec中的类,它是一个顺序Ruby脚本,用于管理应用程序的类并通过命令行参数和选项进行初始化。“bin/my_application.rb”只是一个小

ruby-on-rails - Strong Params : params. permit 返回 Unpermitted parameters despite whitelist

UsersProfileController具有如下所示的强大参数:defuser_profile_paramsparams.permit(:age,:relations)#yes,Iamnotrequiringuser_profile.JustpermittingattributesIneed.endcreate操作通过父级(has-one和belongs-to关联)构建UserProfiledefcreateparent=Parent.create_guestparent.build_user_profile(user_profile_params)ifparent.save#do