小编Der*_*k W的帖子

watir-webdriver phantomjs and ghostdriver

I currently have a rails app that uses rspec and watir-webdriver for my integration tests. I want to run my integration tests in a headless browser (for speed purposes). Since my development is done on a mac the headless gem won't work for me. I am looking to phantomjs as the solution. Whereas phantomjs works well with rspec/capybara (via poltergeist) and there are plenty of examples on how to make that work, I can't find much in the way of …

ruby-on-rails watir-webdriver phantomjs

7
推荐指数
1
解决办法
7285
查看次数

RedirectToAction()与View()和三元运算符?

在决定从Controller Action返回哪个ActionResult时,我决定使用三元运算符而不是更长的if-else.这是我的问题......

这段代码有效

return
    ModelState.IsValid ?
    (ActionResult) RedirectToAction("Edit", new { id = id }) :
    View(new EditViewModel(updatedCategory));
Run Code Online (Sandbox Code Playgroud)

但事实并非如此

return 
     ModelState.IsValid ?
     RedirectToAction("Edit", new { id = id }) :
     View(new EditViewModel(updatedCategory));
Run Code Online (Sandbox Code Playgroud)

如果使用if-else,我不必进行显式转换.另外,RedirectToAction()和View()都返回一个ActionResult衍生物.

我喜欢这段代码的简洁性,但是这个代码似乎并不合适.任何人都可以开导我吗?

虽然我确定这很明显,但EditViewModel是我的Edit动作的视图模型,updatedCategory是EF4对象.但我不认为这与这个问题有关.

好的...我刚刚意识到我在做什么是不必要的,因为无论我是回到使用updatedCategory的Edit操作,所以我不需要确保模型有效.如果有人能提供帮助,我仍然很想知道这个问题的答案.

asp.net-mvc actionresult viewresult

6
推荐指数
1
解决办法
1183
查看次数