草庐IT

ruby-on-rails - rails 3 : User Created custom forms?

我正在努力思考如何允许用户创建具有所有字段类型的自定义表单。如果有一颗gem就好了,但我似乎无法在任何地方找到。所以我有一个像这样的数据库设置:t.integer:form_idt.string:namet.string:hintt.integer:positiont.string:field_typet.boolean:requiredt.integer:sizet.boolean:multiplet.text:valuest.timestamps这就是我所在的位置。我想不出如何遍历field_type并返回值,以及将它们与实际填写的表单相关联。谢谢 最佳

ruby-on-rails - 未知属性 : user_id

我在执行current_user.stories.build时遇到错误unknownattribute:user_idclassUser架构.rbcreate_table"stories",:force=>truedo|t|t.string"responsible"t.string"descr"t.string"state"t.datetime"created_at",:null=>falset.datetime"updated_at",:null=>falseendcreate_table"users",:force=>truedo|t|t.string"email"t.string

ruby - 我想覆盖设计 gem 的 authenticate_user 和 current_user 方法

我想覆盖authenticate_user!和我的应用程序Controller中设计gem的current_user方法你能帮我解决这个问题吗谢谢 最佳答案 你可以像猴子一样修补它:moduleDevisemoduleControllersmoduleHelpersdefauthenticate_user!#dosomestuffendendendend但我会问最终目标是什么,因为Devise已经内置了一些可定制性,覆盖这些方法让我想知道“为什么要使用Devise?” 关于ruby-我想

ruby-on-rails - rails : Only allow admin user to create new users in Rails with Devise (No external modules)

目前,我的Users数据库有一个名为“admin”的列,其值为bool值,默认设置为false。我有一个管理员用户播种到数据库中。如何编写我的应用程序以便是管理员的用户可以创建新用户,而不是的用户不能?(此外,用户应该仅由管理员创建)似乎应该有一种简单的方法可以在不涉及使用某些外部模块的设计中做到这一点。然而,到目前为止,我还没有找到满意的答案。我更有可能标记仅是设计的解决方案。(一个简单的标准MVC/Rails解决方案加分)但是,如果真的有更好的方法来做到这一点而不涉及CanCan,我可能也接受它。注意:我已经搜索了一段时间,发现了其他几个与这个问题非常相似的stackoverflo

ruby-on-rails - 工厂女郎 + RSpec : undefined method 'create' when create(:user)

不能调用“dummy=create(:user)”来创建用户。来回走了好几个小时。/home/parreirat/backend-clone/Passworks/spec/models/user_spec.rb:15:in`block(2levels)in':undefinedmethod`create'for#(NoMethodError)"这是工厂,users.rb:FactoryGirl.definedofactory:userdoemail'heheheheheheh@gmail.com'password'chucknorris'name'luismendes'endend这就

ruby - 工厂女郎 : Factory not registered: user (ArgumentError)

在使用FactoryGirl将所有鸭子按正确顺序排列时遇到很多麻烦。设置极简Rails应用程序(3.0.11)、factory_girl_rails(1.4.0)、factory_girl(2.3.2)&cucumber-rails(1.2.1)和ruby​​-1.8.7-p352。cucumber测试是:Feature:aScenario:testfactory-girlGiventhefollowinguserexists:|name|email||Brandon|brandon@example.com|结果是这样的:cucumberUsingthedefaultprofile..

ruby-on-rails - 找不到路径 "/sessions/user"的设计映射设计登录错误

最近几天很郁闷。我有一个安装了Devise的Rails应用程序,我在其中生成了一个新的用户模型,并且还生成了DeviseView。当我在填写电子邮件和密码字段后单击“登录”并尝试以现有用户身份登录时,会发生这种情况:AbstractController::ActionNotFound-Couldnotfinddevisemappingforpath"/sessions/user".Thismayhappenfortworeasons:1)Youforgottowrapyourrouteinsidethescopeblock.Forexample:devise_scope:userdog

ruby-on-rails - Rails 设计 : user_signed_in? 不工作

我的观点是:但是当以用户身份登录时:我仍然可以看到链接:为什么助手不工作? 最佳答案 您是否在Controller中使用了devise的beforeaction?before_action:authenticate_user! 关于ruby-on-rails-Rails设计:user_signed_in?不工作,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6003883/

ruby-on-rails - rails : Your user account isn't allowed to install to the system RubyGems

我正在运行命令bundleinstall在项目文件夹中。在某些项目文件夹中,它会产生错误,而在其他项目文件夹中,它不会产生错误。错误是:Youruseraccountisn'tallowedtoinstalltothesystemRubyGems我知道这可以通过遵循推荐的建议来解决:bundleinstall--pathvendor/bundle我的问题是为什么行为不一致? 最佳答案 在我的例子中,我按照错误消息的建议解决了问题:Youruseraccountisn'tallowedtoinstalltothesystemRubyG

ruby-on-rails - 如何在 rspec 功能测试中访问(设计)current_user?

在设计文档中,他们提供了有关在测试Controller时如何访问current_user的提示:https://github.com/plataformatec/devise/wiki/How-To:-Test-controllers-with-Rails-3-and-4-%28and-RSpec%29但是,在进行功能测试时呢?我正在尝试测试我的一个Controller的创建方法,并且在该Controller中使用了current_user变量。问题是devise中建议的宏使用了@request变量,并且对于功能规范来说它是nil。什么是解决方法?编辑:这是我目前的规范:feature