草庐IT

accept-parameters

全部标签

ruby-on-rails - rails : Access parameters in view after form submission

在我的Rails3.2项目中,我有一个用于在app/views/sites/中的new.html.erb中创建新站点的表单......然后是sites_controller.rb中的create函数defcreate@site=Site.new(params[:site])respond_todo|format|if@site.saveformat.html{redirect_to@site}elseformat.html{renderaction:"new"}endendend然后在用户提交之后,我想在show.html.erb中显示用户刚刚提交的hash_nameYoujustpu

html - rails : Wrap parameter coming from form in a nested hash

我有以下用于搜索的表单,它还应该执行过滤:我现在要做的是将用于过滤的参数包装在嵌套哈希中,以便我在参数中有如下内容:{"utf8"=>"✓","search"=>"term","action"=>"index","controller"=>"search","filter"=>{"field"=>"value"}}。请注意,过滤器参数是嵌套的我找不到使用标准Rails表单助手来执行此操作的方法。有什么办法吗? 最佳答案 在您想要的嵌套键周围使用[]。在您的示例中,将您的check_box更改为:如果您想要以下形式的内容:{"filt

ruby-on-rails - rails : Multiple parameters before do?

我有这个有效的语法(因为它几乎来自API)"whatever"do-%>还有这个,有效"whatever"},{:method=>"get"})%>现在我尝试将它们结合起来,猜测语法。“get”没有像我希望的那样被添加为表单方法。这应该怎么读?"whatever",:method=>"get"do-%>表单标签应为:不是 最佳答案 'whatever'},:method=>"get")do-%>查看APIdocs,问题是:method需要进入options散列,而:action需要进入url_for_options散列,你需要额外的

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

ruby-on-rails - ruby rails : Accept nested attributes for parent rather than child records?

在我的Rails应用程序中,Users可以有许多People,而这些People又可以(但不一定)属于Organisations。简而言之,就是:Users----Organisations现在,如果能够以某种方式从人员View中创建新组织,那就太好了。它试过这个:classPerson但它不起作用,因为Organization不是Person的子级。还有其他方法可以实现吗?感谢您的帮助。 最佳答案 我可以看到Person实际上是Organisation的子级,它也可以为父级模型创建嵌套形式。您已经在使用accepts_nested

ruby-on-rails - 使用 config.filter_parameters 在 rails 3 中自定义过滤参数

我正在努力从Rails2.3.11升级到3.0.10,但在转换ApplicationController的filter_parameter_logging中的内容时遇到问题。我想过滤这两个特定参数,如果它们出现在类似:referrer标签的值中,我也会过滤它们。我可以在我的application.rb中过滤掉常规参数config.filter_parameters+=[:password,:oauth,...]但我遇到的麻烦是我们还传入filter_parameter_logging的block。它还会过滤掉任何看起来像url的值中的参数,因此类似http://example.com?

ruby-on-rails - Ruby 2 关键字参数和 ActionController::Parameters

我有一个在ruby​​2.1上运行的Rails4应用程序。我有一个看起来像这样的User模型classUser正如您在搜索方法中看到的那样,我正在尝试使用ruby​​2的新关键字参数功能。问题是,当我从我的Controller中调用此代码时,所有值都被转储到query中。参数{"action"=>"search","controller"=>"users",query:"foobar"}请注意,这是一个ActionController::Parameters对象,而不是它看起来的散列用户Controllerdefsearch@users=User.search(params)end我觉

c++ - ndk-build : CreateProcess: make (e=87): The parameter is incorrect

在Windows平台上使用NDK构建静态库时出现错误:process_begin:CreateProcess("PATH"\android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ar.exe,"someothercommands")failed.make(e=87):Theparameterisincorrect.make:***[obj/local/armeabi-v7a/staticlib.a]Error87make:***Waitingforu

c++ - ndk-build : CreateProcess: make (e=87): The parameter is incorrect

在Windows平台上使用NDK构建静态库时出现错误:process_begin:CreateProcess("PATH"\android-ndk-r8b\toolchains\arm-linux-androideabi-4.6\prebuilt\windows\bin\arm-linux-androideabi-ar.exe,"someothercommands")failed.make(e=87):Theparameterisincorrect.make:***[obj/local/armeabi-v7a/staticlib.a]Error87make:***Waitingforu

c# - 带有方法参数的 WCF webHttpBinding 错误。 "At most one body parameter can be serialized without wrapper elements"

Operation''ofcontract''specifiesmultiplerequestbodyparameterstobeserializedwithoutanywrapperelements.Atmostonebodyparametercanbeserializedwithoutwrapperelements.EitherremovetheextrabodyparametersorsettheBodyStylepropertyontheWebGetAttribute/WebInvokeAttributetoWrapped.我正在尝试通过以下配置(通过WCF配置编辑器设置)使用