Tag: ruby on rails 3.2

失败:RuntimeError:保存图表失败! 当运行rake erd命令时

我正在努力为我的rails应用程序中的模型生成图表。 我在Windows 7上安装了graphviz 当我跑 rake erd OR rake erd filetype=dot 我收到了以下错误 $ rake erd –trace ** Invoke erd (first_time) ** Invoke erd:generate (first_time) ** Invoke erd:options (first_time) ** Execute erd:options ** Invoke erd:load_models (first_time) ** Execute erd:load_models Loading application environment… ** Invoke environment (first_time) ** Execute environment Loading code in search of Active Record models… […]

如何从其他网站获取元数据并在我的ruby轨道上显示?

使用FB或Google +时,我可以将任何网站的链接粘贴到状态更新框中,它会立即加载有关该网站的信息,并可选择点击缩略图。 我怎样才能在轨道上的ruby中实现这一目标? 我的所有搜索似乎都提出了如何执行此操作的php方法。 为了获取video数据信息,我使用Ruby Open Graph Protocol gem。 有没有像FB和G +那样抓取数据的东西? 如果没有标准的方法,这是在rails / ruby​​中完成的,如果是这样的话……这是怎么做到的? 亲切的问候

Rails 3 – validation时间存在

我有一个带有Time属性的模型。 我想检查时间不能为空(更好的选择可能是检查输入是时间,但我不知道如何处理)。 我试过这个validation: # id :integer not null, primary key # school_class_id :integer # meeting_time :time class Meeting { :message => “can’t be empty!” } end 然后我试图在规范中检查这个,这失败了(空的时间还可以,但它不应该是)。 我做错了什么? Rspec的: # id :integer not null, primary key # school_class_id :integer # meeting_time :time require ‘spec_helper’ describe Meeting do before(:each) do @class = FactoryGirl.create( :school_class ) @attr_meeting […]

使用Closure_tree gem而不是Awesome嵌套集

嗨,我按照链接设置了closure_tag gem。 当我尝试以下列方式使用closure_tree语法时(newStructure.find_or_create_by_path(parent)而不是newStructure.move_to_child_of(parent))…得到以下错误: “不能大规模分配受保护的属性:祖先,后代,世代” 这是使用newStructure.find_or_create_by_path(parent)的正确方法吗? def self.import(path) newStructure = FileOrFolder.find(:first, :conditions=>[“fullpath = ?”, path]) if newStructure return newStructure end newStructure = FileOrFolder.new newStructure.fullpath = path pathbits = path.split(‘/’) newStructure.name = pathbits.last newStructure.save parentpath = path.sub(/#{Regexp.escape(pathbits.last)}$/, ”) if parentpath.length > 1 parentpath.sub!(/\/$/,”) parent = FileOrFolder.find(:first, :conditions=>[“fullpath = ?”, parentpath]) unless parent parent = FileOrFolder.import(parentpath) end #newStructure.move_to_child_of(parent); […]

如何抑制Rails中的回溯?

使用raise或fail退出Rails应用程序时,如何防止回溯显示? 尝试使用back_trace_limit但它似乎只适用于控制台…?

每当我尝试为Jruby加载gem时,它都会给我这个错误。 这是在进入“gem install rails”之后。 请帮忙?

我正在尝试为jruby-1.7.0.RC2下载gem,但每当我试图推动它时我都会收到此错误。 Error: Your application used more stack memory than the safety cap of 2048K. 指定-J-Xss #### k以增加它(#### = cap size以KB为单位)。 为完整的StackOverflowError堆栈跟踪指定-w

升级到Rails 3.2.8导致与ActiveRecord的堆栈级别太深的错误

我对Ruby很新,但我遇到了一个问题,我无法深入了解问题。 我的简单应用程序工作正常,然后,在将Rails版本升级到3.2.8后,我在尝试查询数据库以查找记录时遇到了问题。 这在使用Rails 3.0.7时工作正常,但在升级到rails 3.2.8后,它开始失败并出现Stack Level太深的错误。 我的模型看起来像这样: class Resource true, :length => { :minimum => 5} validates :link, :presence => true validates :date_submitted, :presence => true has_many :comments validates_format_of :link, :with => URI::regexp(%w(http https)) validates :link, :uniqueness => {:scope => :link, :message => “This item has already been submitted”} end 当我从控制台调用Resource.all时,它失败并出现以下错误: SystemStackError:堆栈级别太深了/home/tom/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/irb/workspace.rb:80也许IRB错误!! 它似乎也与其他型号一起发生,并且在升级之前这种工作正常的事实似乎表明它是另外的东西。 有没有人对我应该在哪里有任何想法 – […]

使diff-lcs的输出成为可读的

我正在使用diff-lcs gem来输出两个html内容体之间的差异。 这是示例内容。 第一版: Paragraph one. Sentence one. Paragraph two. Another sentence. Paragraph three. I dare you to change me! 第二版: Paragraph one. Sentence two. Paragraph two. Another sentence. Paragraph three. I dare you to update me! 使用这个: seq1 = @versionOne.body seq2 = @versionTwo.body seq = Diff::LCS.diff(seq1, seq2) 你得到这个怪物: seq => [[#, #], [#, #], […]

为什么在rails中使用_form.html.erb

我是Ruby on Rails的新手。我使用scaffold为admin创建模型视图和控制器 现在,我的一位前辈告诉我在_form.html.erb为admin进行更改。我不知道如何实现它。与_form.html.erb相比,使用/进行更改的优点或缺点是什么?普通方法(在索引,新建,显示和编辑中进行更改) 我的_form.html.erb如下: – prohibited this admin from being saved: 我的Admin表格如下: – id serial NOT NULL, username character varying(20) NOT NULL DEFAULT ”::character varying, email character varying(255), first_name character varying(100), middle_name character varying(100), last_name character varying(100), designation character varying(255), office_phone character varying(255), deleted integer NOT NULL DEFAULT 0, super_admin boolean NOT NULL DEFAULT […]

before_filter set_locale除了控制器

我的routes.rb MyApp::Application.routes.draw do scope ‘(:locale)’ do #all resources here end namespace :blog do resources :posts, :only => [:index, :show] end end 我的application_controller.rb class ApplicationController < ActionController::Base # # before_filter :set_locale private def default_url_options(options = {}) {locale: I18n.locale} end def set_locale #code for detect locale here end # # end scope ‘(:locale)’内的所有资源都正常工作。 但是我不想使用带有namespace :blog语言环境namespace :blog ,当我尝试点击博客链接时,我可以看到这个urlhttp://localhost:3000/blog/posts?locale=en […]