Tag: ruby on rails4

谷歌分析与铁轨4

谷歌分析我的轨道4项目实施有点困难。 我将跟踪代码包括在我的布局文件的底部,甚至尝试删除turbolinks 这里build议,但是我谷歌仍然无法检测到这个跟踪cookie。 有任何想法吗 ?

Rails 4.2:内部服务器错误,内容达到最大文件多部分

刚刚升级到Rails 4.2,并且在尝试编辑具有多个has_many对象的模型时,在本地主机和生产环境中出现内部服务器错误。 这是我在rails的控制台上看到的消息 !! Unexpected error while processing request: Too many open files – Maximum file multiparts in content reached 请求甚至没有得到控制器,即我看不到在轨道控制台中通常的以下行 Started GET "/feeds/3/edit" for 127.0.0.1 at 2015-01-04 20:07:19 -0800 Processing by FeedsController#edit as HTML …… …… 任何线索? 使用Ruby 2.1.5升级到2.2没有运气。

Rails 4中的has_many'conditions'选项等价于什么?

有人可以告诉我什么是在Rails 4做下面的行的等效方式? has_many :friends, :through => :friendships, :conditions => "status = 'accepted'", :order => :first_name 我尝试了以下内容: has_many :friends, -> { where status: 'accepted' }, :through => :friendships , :order => :first_name 但是我得到以下错误: Invalid mix of scope block and deprecated finder options on ActiveRecord association: User.has_many :friends

什么是`params.require(:person).permit(:name,:age)`在Rails 4中做什么?

所有Rails 4文档中强参数的例子都使用params.require(:person).permit(:name, :age) 。 有人可以解构和解释什么是发生在require和permit在这里? 谢谢!

Rails 4,ExecJS :: ProgramError Pages#welcome

我正在尝试将login注销function添加到我的Rails应用程序。 为此,我添加了密码encryption的bcrypt gem以及访问控制器。 现在,当我在本地运行它时,我收到一条错误消息。 在添加上述function之前,我的应用运行良好。 错误信息: TypeError: Object doesn't support this property or method (in C:/DevKit/lib/ruby/gems/1.9.1/gems/turbolinks-2.5.3/lib/assets/javascripts/turbolinks.js.coffee) Extracted source (around line #8): <head> <title>PostApp</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track'=>true %> <%= javascript_include_tag 'application', 'data-turbolinks-track'=>true %> —-> Line 8 <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <%= csrf_meta_tags %> 的Gemfile: source 'http://rubygems.org' # Bundle edge Rails instead: gem 'rails', github: […]

新数据不会持久化到Postgres上的Rails数组列

我有一个types为text的朋友列的用户模型。 这个迁移被运行到与postgres一起使用数组function: add_column :users, :friends, :text, array: true 用户模型有这个方法: def add_friend(target) #target would be a value like "1234" self.friends = [] if self.friends == nil update_attributes friends: self.friends.push(target) end 下面的规范通过,直到我调用#add_friend后添加#add_friend : it "adds a friend to the list of friends" do user = create(:user, friends: ["123","456"]) stranger = create(:user, uid: "789") user.add_friend(stranger.uid) user.reload #turns the […]