jjzjj

pg_attribute

全部标签

ruby-on-rails - 获取 fields_for 和 accepts_nested_attributes_for 以处理 belongs_to 关系

我似乎无法使用Rails2.3的新accepts_nested_attributes_for工具在RailsView中为belongs_to关系生成嵌套表单。我确实检查了许多可用的资源,看起来我的代码应该可以工作,但是fields_for对我来说是爆炸性的,我怀疑它与如何做有关我配置了嵌套模型。我遇到的错误是一个常见的错误,可能有多种原因:'@account[owner]'isnotallowedasaninstancevariablename下面是涉及的两个模型:classAccount'User',:foreign_key=>'owner_id'accepts_nested_att

ruby-on-rails - accepts_nested_attributes_for rails 4 没有删除

我已经阅读和研究了大约3天。这是我最后的选择。土地.rb:has_many:uploads,:dependent=>:destroyaccepts_nested_attributes_for:uploads,:allow_destroy=>true,:reject_if=>:all_blank上传.rbbelongs_to:land_land_form_partial.html.erb{:multipart=>true}do|f|%>Delete:#...buttonsandotherfieldslands_controller.rbdefupdateif@land.update_at

ruby-on-rails - 将 bool 值传递给 update_attributes 的问题

我有以下模型:classGuestCateringtruevalidates:order_number,:presence=>truevalidates:orderable,:presence=>trueend但是当我尝试使用以下代码更新现有的GuestCatering时:guest_catering.update_attributes(:orderable=>false)guestcatering变量是一个有效的GuestCatering对象。guest_catering对象更新后出现错误,像这样:nil}>但是当我传递一个orderable=>true时,一切都很好,没有错误。这里

ruby - gem install pg 不适用于 OSX Lion

这个问题围绕SO有很多变化,但似乎没有一个能解决我的问题。我正在运行OSXLion(10.7.3)。安装了最新的XCode。我使用来自postgresapp.com的Postgres.app包安装了Postgres。但是当我尝试安装pggem时,我失败了:$geminstallpg----with-pg-config=/Applications/Postgres.app/Contents/MacOS/bin/pg_configBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingpg:ERROR:Fail

ruby-on-rails - PG::错误:SELECT DISTINCT,ORDER BY 表达式必须出现在选择列表中

ActionView::Template::Error(PG::Error:ERROR:forSELECTDISTINCT,ORDERBYexpressionsmustappearinselectlist我正在创建一个事件网站,我正在尝试按事件的开始时间对呈现的rsvps进行排序。有很多RSVPS,所以我将它们分组为不同的,但在过去的几天里,我在排序结果时遇到了很多困难,而没有在PG上弹出这个错误。我已经查看了之前关于该主题的一些问题,但仍然很迷茫。我怎样才能让它工作?非常感谢!@rsvps=Rsvp.where(:voter_id=>current_user.following.co

ruby-on-rails - Gem::LoadError: 无法激活 pg (~> 0.18),已激活 pg-1.0.0

这个问题在这里已经有了答案:RailsapplicationusingPostgresadaptercan'tactivatepg(1个回答)关闭4年前。我一直在做Rails教程发现here并且已经成功到必须使用$railsdb:migrate来迁移Comments迁移。在此之前,我已经能够毫无问题地生成文章模型并迁移文章创建迁移。在这两次迁移之间,我的Gemfile中没有任何变化,所以我不确定Bundler有什么问题。这是错误,后面是完整的命令行输出,以及我的Gemfile和schema.rb:Gem::LoadError:can'tactivatepg(~>0.18),alread

ruby-on-rails - 错误信息: Make sure that `gem install pg -v ' 0. 18. 1'` 绑定(bind)成功

我对ruby有疑问。我尝试了很多,但对我没有任何用处。当我想启动railsserver时,我得到这个错误信息:Anerroroccurredwhileinstallingpg(0.18.1),andBundlercannotcontinue.Makesurethat"geminstallpg-v'0.18.1"succeedsbeforebundling.这是我已经尝试过的:sudoinstallgembundleinstallbundleinstall--pathvendor/cachegeminstallpg-v'0.18.1'当我尝试geminstallpg-v'0.18.1'时

ruby-on-rails - accepts_nested_attributes_for 和 belongs_to 多态

我想用accepts_nested_attributes_for建立一个多态关系。这是代码:classContact:clientendclassJob:trueaccepts_nested_attributes_for:clientend当我尝试访问Job.create(...,:client_attributes=>{...}时给我NameError:uninitializedconstantJob::Client 最佳答案 我也遇到了“ArgumentError:无法构建关联模型名称。您是否正在尝试构建多态一对一关联?”的问题

ruby-on-rails - rails : Update model attribute without invoking callbacks

我有一个具有:credits属性的用户模型。我想要一个简单的按钮,它将通过名为“add”的路由将5添加到用户的积分中,以便/users/3/add将5添加到用户id=3的积分中。defadd@user=User.find(params[:id])@user.credits+=5redirect_toroot_pathend那是我Controller的相关部分。问题是,我不想调用@user.save,因为我有一个before_save回调,它根据当前的UTC时间重新加密用户的密码。我只想简单的给属性加5,避免回调,没想到这么简单的事情这么难。编辑:我将回调更改为:before_creat

ruby-on-rails - Rails has_many :through Find by Extra Attributes in Join Model

Ruby和Rails的新手,但我现在已经受过书本教育(这显然没有任何意义,哈哈)。我有两个模型,Event和User通过表EventUser连接classUser:event_usersendclassEventUser:event_usersend这个项目是一个日历,我必须在其中跟踪人们为给定的事件注册和刮掉他们的名字。我认为多对多是一种好方法,但我不能这样做:u=User.find:firstactive_events=u.events.find_by_active(true)因为事件实际上没有额外的数据,所以EventUser模型有。虽然我可以做到:u=User.find:fir