Redmine的插件迁移

我正在为Redmine开发一个插件。 如何为其创建迁移? 如果我使用script / generate plugin_migration,它将被放在/ db / migrate文件夹中,但我需要它在我的插件文件夹中。

Mongoid聚合$匹配Date对象不起作用?

我有一个具有这种结构的集合中的用户文档: { “_id” : ObjectId( “4fb54ef46d93b33b21003951” ), “activities” : [ { “id” : ObjectId( “4fd66f9001e7fe9f03000065” ), “type” : “checkin”, “date_time_created” : Date( 1339453328000 )}, { “date_time_created” : Date( 1337351732000 ), “date_time_updated” : Date( 1337351952635 ), “id” : ObjectId( “4fb65e346d93b3fe77000000” )} ] } 我可以根据日期轻松查询这些文档: User.where( :activities => { ‘$elemMatch’ => { :date_time_created => { ‘$gte’ => […]

Rails – 从模型生成迁移脚本

我正在学习rails,我遇到了迁移。 似乎每次我想编辑模型时,我都需要添加一个迁移脚本,即使我尚未投入生产。 您可以编辑模型,添加所需的所有属性,并在发布之前自动生成迁移脚本吗? 谢谢!

Rails Asset Pipeline – 错误的指纹

我的Rails 4应用程序有new.html.erb ,它引用了form.html.erb : # app/assets/templates/jobs/new.html.erb … <ng-include src="''”> … # app/assets/templates/jobs/form.html.erb my form is here ( ng-include是AngularJS指令) 问题是,当form.html.erb更改时,生产环境仍会加载旧的form.html.erb 。 发生这种情况可能是因为new.html.erb尚未更改,因此具有相同的旧指纹,指向带有旧指纹的form.html.erb 。 Rails处理这个问题的方法是什么?

无法删除闪光灯

我在迁移插件之前犯了一个错误,并写了 flash[:notice] = :label_presta_added 代替 flash[:notice] = l(:label_presta_added) 我纠正了我的错误,但似乎我的Redmine插件已经破坏了我的Redmine。 即使我删除了我的插件再次迁移,我仍然会收到此错误: Started GET “/” for 127.0.0.1 at 2016-06-01 22:21:37 +0200 Processing by WelcomeController#index as HTML Current user: admin (id=1) Rendered welcome/index.html.erb within layouts/base (28.1ms) Completed 500 Internal Server Error in 366ms (ActiveRecord: 116.0ms) ActionView::Template::Error (undefined method `html_safe’ for :label_presta_added:Symbol Did you mean? html_safe?): 97: 98: 99: […]

Select2 JS lib不能在Rails应用程序上运行

我得到了这个利用select2 JS库的Rails应用程序,无法弄清楚为什么它没有为我的选择列表设置样式。 它正在生产中。 我从生产服务器的快照创建了一个临时服务器。 我运行了rake assets:clobber && rake assets:precompile成功的地方。 我检查了已编译的application.js和application.css文件,其中包含JS代码和样式。 我可以运行$(“.classIwant”).select2(); 在控制台中它选择列表的样式,但是当我选择一个选项时它不会做任何事情。 我在运行$(“.classIwant”).select2();之后也遇到了这个错误$(“.classIwant”).select2(); 在控制台中: [违规]执行JavaScript时强制重排需要49毫秒 请原谅我的无知,因为这是我第一次使用这个JS lib。 任何帮助将非常感激。 提前致谢。 更新#1:当我将以下代码复制到控制台并手动运行App.init(); 有用。 为什么页面没有加载这个。 (function() { window.App || (window.App = {}); App.init = function() { $(“.classIwant”).select2(); $(‘#search’).on(“keyup”, function() { return searchTable($(this).val()); }); $(‘#search-list’).on(“keyup”, function() { return searchList($(this).val()); }); $(“#the_id”).on(‘change’, function(e) { return $(this).parent().submit(); }); return $(‘#preloader’).delay(200).fadeOut(); }; […]

Rails教程(M.Hartl)第3版,第8章,如何通过关闭流氓`rails console`来解锁数据库?

我在第8.4.1章中 ,在生成迁移后我尝试运行: $ bundle exec rake db:migrate 但是给出了以下错误: rake aborted! StandardError: An error has occurred, this and all later migrations canceled: SQLite3::BusyException: database is locked: #followed by a long list of paths/filenames and line numbers… 我知道这可能是因为我没有正确退出rails console –sandbox会话而退出终端。 但是如何找到并关闭此rails console会话?

HTTParty解析Rails中的JSON

我有一个URL,显示400个YMCA位置的JSON保留信息。 我的目标是能够为每个位置提取纬度和经度,以便在地图上显示点。 我正在玩HTTParty,只是想在视图中只显示纬度和经度。 这是我的控制器: require ‘rubygems’ require ‘httparty’ class HomesController < ApplicationController include HTTParty def index uri = HTTParty.get"http://www.livestrong.org/we-can-help/ymca.json" @place = JSON.parse(uri.body) end end 以下是观点: 到目前为止,这将显示屏幕上的所有JSON。 如何挑选各个零件?

Rails 4生成无效的列名称

我有一个相当简单的查询来返回多对多关系中的第一个记录,或者如果它不存在则创建一个。 UserCategorization.where(category_id: 3, user_id: 5).first_or_create 我的模型看起来像: class UserCategorization < ActiveRecord::Base belongs_to :user belongs_to :category self.primary_key = [:user_id, :category_id] end 但是它在SQL中生成无效的列名: SQLite3::SQLException: no such column: user_categorizations.[:user_id, :category_id]: SELECT “user_categorizations”.* FROM “user_categorizations” WHERE “user_categorizations”.”category_id” = 3 AND “user_categorizations”.”user_id” = 5 ORDER BY “user_categorizations”.”[:user_id, :category_id]” ASC LIMIT 1 如果我从模型中删除self.primary_key = [:user_id, :category_id] ,它可以正确检索记录但无法保存,因为它不知道在WHERE子句中使用什么: SQLite3::SQLException: no such column: user_categorizations.: […]

Rails + MongoID +简单forms关联:#Mongoid :: Relations :: Metadata的未定义方法`options’

我有以下模型,基本上是指课程和类别。 每节课可以有一个类别,每个类别都嵌入在课程中。 class Lesson include Mongoid::Document field :title, :type => String field :category, :type => String field :price, :type => Integer field :description, :type => String field :user_id, :type => String validates_presence_of :title validates_presence_of :category validates_presence_of :price validates_presence_of :user_id validates_numericality_of :price attr_accessible :title, :category, :description, :price embeds_one :category end class Category include Mongoid::Document field :name, […]