谢谢,不过网面也可以做到您说的考察我的素质呀,用软件分享屏幕,一边解题一遍说思路,解题过程完全可以展现出来呀
不过我发现我经历的几个网面的确只是单单视频和电话面试,但是这样也可以不错地考察到我的水平呀,而且我的代码也在 github 上。可能国内的网面视频电话的方式比较多吧
谢谢这么细致
两处问题是吗?
第一个拼写错误会尽量避免
第二个关于 mail gun 的 env 文件们我忘了我是怎么折腾出来的。。反正第一次做这个 app 真的是各种折腾,搞不清原因我也不想删
这是我复习的时候重新实现这个 app 部分功能的练习,这个 repo 干净很多,每个 commit message 写的都更合理一下 https://github.com/Awlter/LS_rails_review
好啦,谢谢。
您好,接受网络面试吗
您好可以网络面试吗
真是第一次见,%w倒是挺常用的
大多数的 Ruby 核心贡献者来自日本,在那儿.....
👌👌
额,原来就在隔壁啊! 谢谢啦
是不是不读个计算机专业就会经常遇到这种听不懂的帖子啊。似懂非懂的,看着好兴奋
https://launchschool.com/books/oo_ruby/read/inheritance#privateprotectedandpublic
private methods are not accessible outside of the class definition at all, and are only accessible from inside the class when called without self.
空行
from outside the class, protected methods act just like private methods; from inside the class, protected methods are accessible just like public methods.
我想你并不是像楼上两位指出的你不懂 inject or reduce 是怎么工作的,你应该是知道 sum 是上一个 interation 最后一行的返回值 (或者是 next/break 后面的返回值)。
我觉得你没弄清楚的是 sum + 1 或 sum + 2 这命令是不会改变 sum 本身的,所以对于没有 next 前置的命令,比如 sum + 1 if a > 3 是不改变 sum 的,block 最后返回的 sum 是还没累加过的 sum, 不信你可以放个 pry 在 block 里的倒数第二行
改成 sum += 1, sum = sum + 1, 就会得到你想要的结果
我知道我没犯错就行。现在不敢升到 4.1.16,等有机会试一下,谢大神:)
没,我的“试过了”的意思是我觉得@queue_items.to_a
和@queue_items[0]
的试错效果是一样的,刚刚试了下的确一样(上面的代码)
From: /Users/wangxuefei/Documents/launchschool/rails_review/app/controllers/queue_items_controller.rb @ line 6 QueueItemsController#index:
4: def index
5: @queue_items = current_user.queue_items.includes(video: ['category'])
=> 6: binding.pry
7: end
[1] pry(#<QueueItemsController>)> @queue_items.to_a
QueueItem Load (0.3ms) SELECT "queue_items".* FROM "queue_items" WHERE "queue_items"."user_id" = $1 ORDER BY "queue_items"."position" ASC [["user_id", 1]]
Video Load (0.2ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" IN (8, 4, 1)
Category Load (0.2ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (2, 1)
NoMethodError: undefined method `each' for nil:NilClass
from /Users/wangxuefei/.rvm/gems/ruby-2.1.2@myflix/gems/activerecord-4.1.1/lib/active_record/associations/preloader/association.rb:87:in `block in associated_records_by_owner'
to_a
也是一样报错NoMethodError: undefined method
each' for nil:NilClass`
[4] pry(#<QueueItemsController>)> @queue_items[0]
CACHE (0.0ms) SELECT "queue_items".* FROM "queue_items"
CACHE (0.0ms) SELECT "videos".* FROM "videos" WHERE "videos"."id" IN (8, 9, 1)
CACHE (0.0ms) SELECT "categories".* FROM "categories" WHERE "categories"."id" IN (2, 1)
NoMethodError: undefined method `each' for nil:NilClass
from /Users/wang/.rvm/gems/ruby-2.1.2@myflix/gems/activerecord-4.1.1/lib/active_record/associations/preloader/association.rb:87:in `block in associated_records_by_owner'
我试过了,上面是我问题里的代码,下次问问题的时候再明确些指出来:)
我已经 google 过了,在 google 上都没人问过这个问题。。
class QueueItem < ActiveRecord::Base
belongs_to :video
belongs_to :user
validates :position, numericality: { only_integer: true }
def video_title
video.title
end
def video_category
video.category.name
end
关联应该是没问题的,因为video_category
这个方法是可以用的
我不知道你记不记得,小时候猪肉上面会有紫色的防疫标签。。
$ rake routes | grep example
example1_example2_index GET /example1/:example1_id/example2(.:format) example1/example2#index
POST /example1/:example1_id/example2(.:format) example1/example2#create
example2 GET /example2/:id(.:format) example1/example2#show
PATCH /example2/:id(.:format) example1/example2#update
PUT /example2/:id(.:format) example1/example2#update
DELETE /example2/:id(.:format) example1/example2#destroy
example1_index GET /example1(.:format) example1#index
https://stackoverflow.com/questions/37399068/rspec-controller-for-nested-resources-before-action
测试 show action 时 应该没有 example1, hmmm 我再查查
真的是睡不着啊,离奇。是什么造成的呢?。。。
@davidwei @hw676018683 朋友们 是不是很神奇。。 我用 binding.pry 了,测试的时候的确是先 require_admin 的。。。 ruby (= 2.1.2) rails (= 4.1.1) rspec-rails (= 2.99)
1) Admin::VideosController GET #new behaves like requires sign in redirects to sign in path
Failure/Error: action
NoMethodError:
undefined method `admin?' for nil:NilClass
Shared Example Group: "requires sign in" called from ./spec/controllers/admin/videos_controller_spec.rb:5
# ./app/controllers/admins_controller.rb:7:in `require_admin'
# ./spec/controllers/admin/videos_controller_spec.rb:6:in `block (4 levels) in <top (required)>'
# ./spec/support/shared_example.rb:3:in `block (2 levels) in <top (required)>'
2) Admin::VideosController POST #create behaves like requires sign in redirects to sign in path
Failure/Error: action
NoMethodError:
undefined method `admin?' for nil:NilClass
Shared Example Group: "requires sign in" called from ./spec/controllers/admin/videos_controller_spec.rb:15
# ./app/controllers/admins_controller.rb:7:in `require_admin'
# ./spec/controllers/admin/videos_controller_spec.rb:16:in `block (4 levels) in <top (required)>'
# ./spec/support/shared_example.rb:3:in `block (2 levels) in <top (required)>'
Finished in 19.17 seconds
180 examples, 2 failures
可以悬赏么?一个比特币。。
刚刚在浏览器上在没有登陆的情况下手动输入http://localhost:3000/videos/new
, 是先触发的require_user
....可是为什么测试时顺序颠倒呢?测试是这样的
describe Admin::VideosController, :type => :controller do
describe "GET #new" do
it_behaves_like "requires sign in" do
let(:action) { get :new }
end
end
end
-------
RSpec.shared_examples "requires sign in" do
it "redirects to sign in path" do
action
expect(response).to redirect_to sign_in_path
end
end
第一次经历新版本更新,这种感觉就是像苹果发布新电脑一样的感觉吗?
这就变成一个用 ruby 怎么删除 array 里其中一个元素的问题了对吗?
谢谢各位
cedar-14