Ruby on rails 在黄瓜测试过程中,将id称为nil,这将被误认为是4
static_controller.rb的第31行调用了您期望成为ActiveRecord对象的id,但实际上是nil。找出原因Ruby on rails 在黄瓜测试过程中,将id称为nil,这将被误认为是4,ruby-on-rails,cucumber,Ruby On Rails,Cucumber,static_controller.rb的第31行调用了您期望成为ActiveRecord对象的id,但实际上是nil。找出原因 错误消息指出,nil不是ActiveRecord对象,只有Ruby内部id字段,对于nil,该字段始终为4。在static\u controller.rb文件中,我包含spacific电影的id@header\u movie=PAPERCLIP\u STORAGE\u PATH+videos/header\u movies/{header\u movie.header
错误消息指出,nil不是ActiveRecord对象,只有Ruby内部id字段,对于nil,该字段始终为4。在static\u controller.rb文件中,我包含spacific电影的id@header\u movie=PAPERCLIP\u STORAGE\u PATH+videos/header\u movies/{header\u movie.header\u movie\u file\u name}在这种情况下,Rails似乎在抱怨header\u movie not@header\u movie为零。也许你从未设定过?我不能再帮你了,除非你能在static_controller.rb中发布该行的方法。但一旦我加载了欢迎页面,我就遇到了与视频文件格式相关的MIME类型错误。。。。。。。这样地。。。。。。不支持文本/html的HTTP内容类型。加载媒体资源失败。这本书的plz指南。@manijain-这似乎不相关,尽管我不能确定。我不知道那个错误。当请求视频时,您的后端可能正在返回HTML?我想这可能与未设置header_movie变量有关。我现在真的只是猜测。是的,你是对的。。。加载页面时找不到标题\u电影变量。。。和我们对cucumber运行测试一样,我们得到了nil的id…所以我想知道如何在mozila上为视频文件定义mime类型。如果一旦我得到了,那么确定这个测试将运行。
manish@ubuntu:~/change/artfacedev2_15july$ bundle exec cucumber features/home_page.feature
Using the default profile...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Checking for old unconfirmed users
2013-07-23 19:29:38 +0530
Updating CurrencyValue
2013-07-23 19:29:38 +0530
Feature: homepage
Background: I am on the homepage # features/home_page.feature:3
Given I am on the homepage # features/step_definitions/home_page_steps.rb:1
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id (RuntimeError)
./app/controllers/static_controller.rb:31:in `home'
./features/step_definitions/home_page_steps.rb:2:in `/^I am on the homepage$/'
features/home_page.feature:4:in `Given I am on the homepage'
"Exception"
"undefined method `update_attribute' for nil:NilClass"
..........................
in home_page.feature
Feature: homepage
Background: I am on the homepage
Given I am on the homepage
..........................
in home_page_step.rb
Given /^I am on the homepage$/ do
visit "/"
end
...........................
path.rb is
module NavigationHelpers
def path_to(page_name)
case page_name
when /the homepage/
'/'
when /users section in backend panel/
'/backend/users/'
when /backend login page/
'/backend/af_login/'
else
raise "Can't find mapping from \"#{page_name}\" to a path.\n"
end
end
end
World(NavigationHelpers)