我不确定,但这可能与崩溃的计算机有关.重新启动后(崩溃后)我得到一个错误的助手错误,其中助手名称错误.切换分支对结果没有影响.
错误是:
缺少帮助文件助手// users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb
香港专业教育学院尝试更新宝石,卸载铁轨和重新安装,检查帮助名称和任何帮助包括在内.我还审查了git日志并检查了最近更改的代码.没运气.
Started GET "/" for 127.0.0.1 at 2015-01-09 17:53:57 -0700
ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
AbstractController::Helpers::MissingHelperError - Missing helper file helpers//users/xxxx/sites/xxxx/app/helpers/accounts_helper.rb_helper.rb:
actionpack (4.2.0) lib/abstract_controller/helpers.rb:151:in `rescue in block in modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:148:in `block in modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:144:in `modules_for_helpers'
actionpack (4.2.0) lib/action_controller/metal/helpers.rb:93:in `modules_for_helpers'
actionpack (4.2.0) lib/abstract_controller/helpers.rb:108:in `helper'
actionpack (4.2.0) lib/action_controller/railties/helpers.rb:17:in `inherited'
app/controllers/application_controller.rb:1:in `<top (required)>'
activesupport (4.2.0) lib/active_support/dependencies.rb:457:in `block in load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:647:in `new_constants_in'
activesupport (4.2.0) lib/active_support/dependencies.rb:456:in `load_file'
activesupport (4.2.0) lib/active_support/dependencies.rb:354:in `require_or_load'
activesupport …
Run Code Online (Sandbox Code Playgroud) Rails有607个未解决的问题......所以,我不是先把这个漏洞堵住,而是先尝试一下.我已升级到4.1并正在实施rails mailer预览.我尝试升级现有的邮件程序并添加测试/邮件程序/预览目录.当出现以下错误时,我尝试生成一个新的邮件程序.同样的错误.
class NotifierPreview < ActionMailer::Preview
def welcome
Notifier.welcome(User.first)
end
end
Run Code Online (Sandbox Code Playgroud)
导致此错误:
The action 'notifier' could not be found for Rails::MailersController
Run Code Online (Sandbox Code Playgroud)
我试过搜索谷歌,文档,堆栈溢出,但没有任何躲避这个错误.
有人遇到这个或有任何想法吗?
是否可以在Prawn中为bounding_box添加背景颜色?
bounding_box([100, cursor], width: 80, height: 20) do
pad_top(7) { text "THIS IS TEXT", size: 8, align: :center }
stroke_bounds
end
Run Code Online (Sandbox Code Playgroud)
我已经尝试将其添加到bounding_box块
background_color: "CCCCCC"
Run Code Online (Sandbox Code Playgroud)
我试过在块内添加这个
fill_color "CCCCCC"
background_color "CCCCCC"
Run Code Online (Sandbox Code Playgroud)
似乎没有什么东西适用于bounding_box
我有一个属于角色模型的帐户模型.
factory :role do
name "student"
end
factory :account do
user
role
end
Run Code Online (Sandbox Code Playgroud)
第一个工厂创建一个名为"student"的角色.第二个工厂创建一个帐户,该帐户与在上一个工厂中创建的学生角色相关联.它也与用户相关联......这对于这个问题并不重要.
我有很多要测试的角色(管理员,学生,助理)......我不想在角色工厂中指定'学生'......这太静态了.如何指定创建帐户工厂时要创建的角色?喜欢:
factory :account do
user
role_id { factory :role { name: "admin"} }
end
Run Code Online (Sandbox Code Playgroud)
完成此任务的最佳方法是什么?
我刚刚从CanCan切换到Pundit.我不确定有几件事,以及如何最好地使用Pundit.例如.
如果您有一个可以有多个父对象的资源,例如可以说一个目标属于一个学生和教师.因此,学生可以有很多目标,教师可以有很多目标.在控制器索引操作中,您可能会:
if params[:student_id].present?
@account = Student.find(params[:student_id])
@goals = @account.goals
elsif params[:instructor_id].present?
@account Instructor.find(params[:instructor_id])
@goals = @account.goals
end
Run Code Online (Sandbox Code Playgroud)
params在策略中不可用,因此逻辑需要在这里完成.我认为.据我所知,如果您跳过policy_scope,在查看目标索引页时会出现未经授权的错误.
你会:
@goals = policy_scope(@account.goals)
Run Code Online (Sandbox Code Playgroud)
要么
@goals = policy_scope(Goal.scoped).where( account_id: @account.id)
Run Code Online (Sandbox Code Playgroud)
当你在混合中抛出一堆包含时会发生什么?
@example = policy_scoped(@school.courses.includes(:account => :user, :teacher ))
Run Code Online (Sandbox Code Playgroud)
或者当需要订购时......这是正确的吗?policy_scope(Issue.scoped).order("created_at desc")
使用范围时:什么是:范围在这里?是:范围正在评估的模型的实例?我试过通过:scope访问它的属性,但是没有用.
policy_scope(Issue.scoped).order("created_at desc")
Run Code Online (Sandbox Code Playgroud) 在大多数控制器测试中,此警告显示给我(适合所有人).我知道它只是一个警告......现在......直到5发布.我不确定我需要改变什么来遵守这种弃用.serialized_attributes有什么变化?我喜欢让这个警告消失并改进我的代码准备5.0 ...但不确定如何继续.谢谢.
从控制器测试中达到标准更新操作时...我收到错误:
@document.update_attributes(document_params)
Run Code Online (Sandbox Code Playgroud)
在测试中(本例为浓缩):
before do
@document = documents(:drivers_license)
end
def valid_params
{ name: 'Passport' }
end
it "must update document" do
put :update, id: @document, document: valid_params
assert_redirected_to documents_path
end
Run Code Online (Sandbox Code Playgroud)
此测试通过,但现在在rails 4.2中输出错误:DEPRECATION WARNING:serialized_attributes
不予替换而弃用,将在Rails 5.0中删除."
那么,在这个例子中......是serialized_attributes"{name:'Passport'}"?
升级到Rails 5后,我的架构文件在运行db:migrate时不断被更改.Rails正在发生变化:
create_table "flightlessons", force: :cascade do |t|
Run Code Online (Sandbox Code Playgroud)
至:
create_table "flightlessons", id: :integer, default: -> { "nextval('lessons_id_seq'::regclass)" }, force: :cascade do |t|
Run Code Online (Sandbox Code Playgroud)
它只发生在这一个模型上.为什么rails在这个特定型号上实现nextval?而且,为什么模型名称错误(lessons_id_seq应该是flightlessons_id_seq).但是,手动将其更改为flightlessons_id_seq会导致相同的无关系错误.
PG::UndefinedTable: ERROR: relation "lessons_id_seq" does not exist
Run Code Online (Sandbox Code Playgroud)
为了继续,我只需将schema.rb文件更改回"应该"行.然后,我可以迁移或测试:准备或者其他什么,直到下一次rails将其改回到使用nextval方法.
感谢您对此的任何见解.
Rails 4.2,active_jobs,callback_methods
在自定义作业的perform方法中,我创建了一条新记录(并将文件上传到S3).如何在after_perform回调中传递或获取新记录ID?我想发送一封post_perform的电子邮件,其中包含指向S3文档的链接...但是,不知道如何在after_perform方法中获取id.根据文档,您可以使用job.attributes,但我得到'未定义的方法属性'.
我可以将邮件程序调用移动到perform方法中,但我宁愿使用回调来正确处理它.我不确定如何在perform方法之外访问属性(或这些属性的来源).
我试着通过将其置于回调中来做一些侦探工作(以确定回调可用的属性):
puts "job: #{ job }"
Run Code Online (Sandbox Code Playgroud)
要么
puts "job: #{ job.attributes }"
Run Code Online (Sandbox Code Playgroud)
要么
puts "job: #{ job.attributes.first }"
Run Code Online (Sandbox Code Playgroud)
这些都没有奏效,而且都导致了未定义的"属性".
我正在使用Sketch来创建将在我的Xcode 6自动布局故事板中使用的图像.但是我无法确保图像尺寸正确.它们总是显得太大并且溢出故事板视图控制器.在Xcode中有没有办法看到故事板预期的尺寸?有没有系统的方法来做到这一点......而不是反复试验?
我回去使用Fixtures.IMOP,固定装置比工厂更好; 更容易使用,更容易理解,更容易理解(没有魔力).我的建议:将测试库限制为非常基础(听DHH)...使用minitest和灯具.
在我的应用程序中,一个区有很多学校,一个学校有很多用途,一个用户有很多帐户,一个帐户有一个角色.为了创建完整的测试工厂,我需要创建一个贯穿工厂的用户和学校.我在最近的尝试中得到了"堆栈级太深"的错误.
我的user_test.rb
FactoryGirl.define do
factory :district do
name "Seattle"
end
factory :school do
association :primarycontact, factory: :user # expecting this to attach the user_id from factory :user as :primary contact_id in the school model
association :district, factory: :district # expecting this to attach the :district_id from the :district factory as :district_id in the school model
name "Test School"
end
factory :user do, aliases: [:primarycontact]
email "adam@example.com"
name "Who What"
username "wwhat"
password "123456"
password_confirmation { |u| …
Run Code Online (Sandbox Code Playgroud) factory-bot ×2
actionmailer ×1
callback ×1
helper ×1
minitest ×1
pdf ×1
postgresql ×1
prawn ×1
pundit ×1
schema ×1
xcode6 ×1