我正在尝试在OSX Lion上安装Imagemagick,但有些东西没有按预期工作.
-> brew install imagemagick
/usr/local/git/bin/git
==> Cloning https://github.com/adamv/ImageMagick.git
Cloning into /Users/klebershimabuku/Library/Caches/Homebrew/imagemagick--git...
fatal: https://github.com/adamv/ImageMagick.git/info/refs not found: did you run git update-server-info on the server?
Error: Failure while executing: git clone --depth 1 https://github.com/adamv/ImageMagick.git /Users/kleber/Library/Caches/Homebrew/imagemagick--git
Run Code Online (Sandbox Code Playgroud)
布鲁医生说:
-> brew doctor
We couldn't detect gcc 4.0.x. Some formulae require this compiler.
Some "config" scripts were found in your path, but not in system or Homebrew folders.
`./configure` scripts often look for *-config scripts to determine if software packagesare installed, and what additional …Run Code Online (Sandbox Code Playgroud) 我怎样才能做到这一点?
试图创建2个方法,称为
def disable_timestamps
ActiveRecord::Base.record_timestamps = false
end
def enable_timestamps
ActiveRecord::Base.record_timestamps = true
end
Run Code Online (Sandbox Code Playgroud)
和更新方法本身:
def increment_pagehit
update_attribute(:pagehit, pagehit+1)
end
Run Code Online (Sandbox Code Playgroud)
使用回调来打开和关闭时间戳,例如:
before_update :disable_timestamps, :only => :increment_pagehit
after_update :enable_timestamps, :only => :increment_pagehit
Run Code Online (Sandbox Code Playgroud)
但它没有更新任何东西,甚至是所需的属性(pagehit).
有什么建议?我不想创建另一个表来计算分页数.
我试图包括一些助手用rspec测试,但没有运气.
我做了什么:
support/helpers.rb在我的spec文件夹下创建了一个文件
支持/ helpers.rb
module Helpers
include ActionView::Helpers::NumberHelper
include ActionView::Helpers::TextHelper
end
Run Code Online (Sandbox Code Playgroud)
并试图要求这个文件spec_helper.rb.
# This file is copied to spec/ when you run 'rails generate rspec:install'
require 'rubygems'
require 'spork'
require 'support/helpers'
Spork.prefork do
.
.
end
Run Code Online (Sandbox Code Playgroud)
这会生成以下错误:
/spec/support/helpers.rb:2:in `<module:Helpers>': uninitialized constant Helpers::ActionView (NameError)
Run Code Online (Sandbox Code Playgroud)
我应该如何使用Rspec提供这些助手?
谢谢.
试图找到但没有成功.只是想知道如何在Rails 3中测试范围.
可以使用rspec,shoulda或只是一个测试单元.
谢谢.
实际上,我尝试这种方式,但它不是完整的测试,因为它仍然需要放置order()方法.
范围:
scope :recents_available, where(:available => true, :locked => false).order("created_at DESC")
describe Job, ":recents_available" do
it "should have the scope" do
Job.should respond_to(:recents_available)
end
it "should include recents jobs that are available and unlocked" do
@job = Factory(:job, :available => true, :locked => false )
Job.recents_available.should include(@job)
end
Run Code Online (Sandbox Code Playgroud)
结束
在旧版本2.x我做了类似的事情:
map.resources :jobs, :as => 'vagas'
Run Code Online (Sandbox Code Playgroud)
这样,我可以使用jobs_path创建一个链接.
但是在rails 3中,我仍然可以使用:至于定义一个别名,但我不能再使用jobs_path,因为它迫使我使用vagas_path.
所以我想知道是否有任何方法来定义别名并仍然使用原始资源名称来创建链接.
我将创建一个多用户应用程序,因此,我将拥有一个管理员用户,该用户将有权创建新用户.
我创建了UsersController但是在尝试创建新用户时,已经登录,我将重定向到root_path,并显示一条错误消息"您已经登录".
那么,我该怎么办呢?
我之前使用的是Mysql数据库,并决定切换到Postgresql,现在,当我使用rspec运行测试时,我收到了很多警告和通知.
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
should has link "Suspender"
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
should has css "title" with text "Suspensão de anúncio"
WARNING: there is already a transaction in progress
NOTICE: there is no transaction in progress
should has css "h1" with text "Awesome job!"
Run Code Online (Sandbox Code Playgroud)
我怎么能压制那个?有办法吗,对吗?
我有以下内容删除特定属性上的空格.
#before_validation :strip_whitespace
protected
def strip_whitespace
self.title = self.title.strip
end
Run Code Online (Sandbox Code Playgroud)
我想测试一下.现在,我试过:
it "shouldn't create a new part with title beggining with space" do
@part = Part.new(@attr.merge(:title => " Test"))
@part.title.should.eql?("Test")
end
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
我根据输入的日期搜索字段.
问题是每当我提交表单时,搜索结果都会很好,但搜索字符串会在页面重新加载时从字段中消失.
任何人都可以告诉我如何在字段中保持搜索字符串.
我使用ruby形式,下面是代码..
<%=form_for :messages, url: url_for( :controller => :time_sheets, :action => :late ), :html => { :id => "submitForm1" } do |f| %>
<div class="field">
<tr>
<td> From Date <%= f.text_field :leaveFrom, :id => 'datepicker2', :class => 'phcolor','data-validation' =>'required', :readonly => true %></td>
<td> To Date <%= f.text_field :leaveTo, :id => 'datepicker7', :class => 'phcolor', :readonly => true %></td>
<td >Late Time<%= f.text_field :on_duty, :id => 'timepicker5' %></td>
<div class="actions">
<td style="position: absolute;right: 178px;"><input type="button" class="btn btn-primary" id="submitid" …Run Code Online (Sandbox Code Playgroud) 我正在创建一个新的rails 3.2项目,除了我在css文件上做的最后修改之外,一切都正常.
如果我确实app/assets/stylesheets/application.css对此文件进行了更改,那么在控制台上运行以下命令之前,我无法在浏览器上看到更改:
bundle exec rake assets:precompile RAILS_ENV=development
我的config/environment/development.rb档案.
Sample::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Log error messages when you accidentally call methods on nil.
config.whiny_nils …Run Code Online (Sandbox Code Playgroud)