草庐IT

configure_permitted_parameters

全部标签

ruby-on-rails - rails : Could not load database configuration. 没有这样的文件 -

我从GitHub存储库克隆了一个应用程序文件夹,在捆绑安装gems之后,我尝试使用rakedb:setup和rakedb:migrate命令,但都没有用,这是我的错误消息:**arun997@promanager:~/workspace(master)$rakedb:setuprequire'rails/all'...2.470sBundler.require...7.590srakeaborted!Cannotload`Rails.application.database_configuration`:Couldnotloaddatabaseconfiguration.Nosuchf

ruby-on-rails - 出现错误 "exceeded available parameter key space"?

在我的Rails应用程序中,在表单发布后,出现错误exceededavailableparameterkeyspace。表单中的表单字段太多。这是错误的原因吗?有意见吗? 最佳答案 如果您真的非常需要它,请尝试增加key_space_limitRack::Utils.key_space_limit=262144但根据this这可能很危险“更容易受到POST解析DOS攻击。”检查这个https://github.com/rack/rack/issues/318Rails/javascript:"toomanyparameterkeys

ruby-on-rails - Rails 4 强参数 : can I 'exclude' /blacklist attributes instead of permit/whitelist?

我正在将Rails3应用程序迁移到Rails4,并且正在将attr_accessible属性转换为Controller中的强参数。APIDocumentation显示如何“允许”属性:defperson_paramsparams.require(:person).permit(:name,:age)end然而,我的绝大多数属性都是批量分配安全的。我只需要将:account_id和:is_admin等几个属性列入黑名单。是否可以将属性列入黑名单而不是将几乎所有属性列入白名单?例如:defuser_paramsparams.require(:user).exclude(:account_i

ruby-on-rails - rails : Appending URL parameters & removing URL parameters

编辑:请参阅下面未回答的第二部分。(已回答)I.附加URL我正在尝试使用基本参数指南在我的View中堆叠参数:users_path(:a=>'test')以上将返回:?a=test但是,我希望能够连续点击:users_path(:b=>'goat')并让它返回?a=test&b=goat关于如何堆叠/附加这些URL参数有什么建议吗?(未回答)II.移除参数如果我想在参数设置旁边添加一个[x]链接,我该如何删除其相应的参数?(已回答)三。删除页面参数我想在用户选择参数选项时删除page参数。有没有办法做到这一点?很明显,如果我选择“体育”作为参数类别,则分页不应保留在第26页上。

ruby-on-rails - 未初始化常量 > ActionCable::Server::Configuration::ApplicationCable

当我运行服务器时,它的抛出错误显示在下面的日志中。我在谷歌上搜索了很多,但没有找到背后的原因。有人请点亮它。gem文件source'https://rubygems.org'#BundleedgeRailsinstead:gem'rails',github:'rails/rails'gem'rails','>=5.0.0.beta1','0.10.0.rc1'group:development,:testdogem'byebug'endgem'puma'group:developmentdogem'spring'end日志:/home/pd/.rvm/gems/ruby-2.2.4/g

ruby-on-rails - 设计 NoMethodError 'for' ParameterSanitizer

每次我尝试在我的网站上唱歌/唱歌时,我都会遇到错误。Heroku日志:StartedGET"/users/sign_in"for201.235.89.150at2016-07-0601:35:03+0000Completed500InternalServerErrorin3ms(ActiveRecord:0.0ms)NoMethodError(undefinedmethod`for'for#):app/controllers/application_controller.rb:11:in`configure_permitted_parameters'应用程序Controller.rbc

ruby-on-rails - Capistrano::Configuration:Class 的未定义方法 `instance'

我正在尝试在Rails应用程序中首次启动并运行Capistrano。我有一台运行Ubuntu12.04、nginx、unicorn和rails的linux服务器,但是,我似乎遇到了一些问题。我还使用RVM使用Capistrano3.0.0、rails3.2.14、bundler1.4.0和ruby​​1.9.3p448。我只设置了一个生产阶段,此时我只关心Capistrano与我的服务器通信并从github推送我的代码(目前还没有迁移和捆绑等)。当我使用下面的设置尝试命令capproductiondeploy:check或capproductiondeploy:setup(这似乎已被弃

ruby-on-rails - 摩卡 : How to add expectation of a method when there are multiple invocations with different parameters

我有一个RailsControllerAction要测试。在那个Action中,一个方法User.can?使用不同的参数多次调用。在其中一个测试用例中,我想确保User.can?('withdraw')被调用。但我不关心User.can的调用?与其他参数。defaction_to_be_tested...@user.can?('withdraw')...@user.can?('deposit')...end我在测试中尝试了以下:User.any_instance.expects(:can?).with('withdraw').at_least_once.returns(true)但是测

ruby-on-rails - rails : Unpermitted parameter in Rails 5

首先,我只想在发送到我的后端的当前对象中获取一个对象。我有这个简单的JSON(从表单生成):{"name":"Project1","project_criteria":[{"name":"Criterium1","type":"Type1","benefit":"1"},{"name":"Criterium2","type":"Type2","benefit":"3"}]}我的类(class):classProject项目Controller:defproject_paramsparams.require(:project).permit(:name,project_criteria:

ruby - sinatra config.ru : what is the configure block for?

我将Sinatra与Apache和“经典”风格的Phusion-Passenger一起使用:#config.rurequire'sinatra'configuredo....endrequire'./app'runSinatra::Application我想定义一些东西。在配置block内部或外部定义它有什么区别?#config.rurequire'sinatra'#A)Definingloggerhererack=File.new("logs/rack.log","a+")useRack::CommonLogger,rack#B)GlobalvariableshereLOGGER=L