Ruby China
  • 社区
  • 招聘
  • Wiki
  • 酷站
  • Gems
  • 注册
  • 登录
Brad
@jpman
高级会员
第 3980 位会员 / 2012-10-09

[email protected]
北京
0 篇帖子 / 28 条回帖
0 关注者
7 正在关注
75 收藏
GitHub Public Repos
More on GitHub
  • 概况
  • 话题
  • 回帖
  • 收藏
  • 正在关注
  • 关注者
  • 求问 create! 报错和 rescue 之间的关系 at 2016年10月13日

    #14 楼 @smartepsh render status: 403 等于 render status: :forbidden 至于render head: :forbidden 我特意用了 rails 5 试了一下就是 返回 200

  • 求问 create! 报错和 rescue 之间的关系 at 2016年10月13日
    为什么不会按照猜想走,为什么不会报错?

    因为 resuce 截获了异常

    为什么渲染了200 OK……?

    如果是 403 应该这么写 render status: :forbidden

  • 有关 Rails 路由设计的最佳实践 at 2016年10月08日

    #6 楼 @lilijreey http://guides.rubyonrails.org/routing.html#advanced-constraints 你可以多看看文档

  • [已解决] rails 如何导入自定义 xls at 2016年07月27日

    Spreadsheet 不支持 xlsx 导入 https://github.com/zdavatz/spreadsheet/issues/77 Spreadsheet 作者推荐用 RubyXL

  • 碰到 Assets Pipeline 里的 “幽灵文件”,我被自己给逗乐了 at 2016年03月25日

    所以,application 里 require 的优先级应该是 coffee 和 sass 大于 js 和 css 的吧。

    http://guides.rubyonrails.org/asset_pipeline.html#asset-organization 这个才是真正的原因

  • 控制器中的实例对象? at 2016年03月01日

    #9 楼 这里我查了一下 api 发现 render 'new' 会自动转换成 render action: 'new'. 但是我在这个 controller 里没有定义 new action 的时候 依然可以正常渲染, 于是我又 google 了一下 发现了这篇文章 http://climber2002.github.io/blog/2015/02/21/how-rails-finds-your-templates-part-1/ 这里 render 方法 找到 template 文件 的全过程。

     if (options.keys & [:partial, :file, :template]).empty?
       options[:prefixes] ||= _prefixes
     end
    
    options[:template] ||= (options[:action] || action_name).to_s
    

    当没有 option[:template] 的时候 , 会得到一个 options[:prefixes], 然后 option[:action] 会赋值给 option[:template]

    所以这里 render action: 'new' 和 controller 里的 new action 是没有任何关系的。

  • 控制器中的实例对象? at 2016年03月01日

    #5 楼 @wwwicbd render new 只是负责把你的 new.html.erb 模版渲染成 html 而已。 你这里说的渲染方法和提交方法没有任何关联,如果你想让 url 变成 http://localhost:3000/articles/new. 你需要用 redirect_to

  • 送几本《AngularJS 学习手册》 at 2016年01月06日

    拉低中奖率

  • 解决 stack level too deep 问题 at 2016年01月06日

    #23 楼 @runup mouse 不是变量,这个只是 mouse() 的另一种写法而已。

  • 两段元编程代码的疑问 at 2015年12月25日

    匿名类就是没有名字的类 😄

    c = Class.new(Array)
    c.name  #=>nil
    
  • Rails 怎么提交表单,怎么传递 URI? at 2015年11月30日

    这个问题和 rails 无关

  • Mac 下 Sublime 的 folder side bar,每次关闭 Sublime 后 side bar 都会清空里面的文件列表 at 2015年10月26日

    保存成一个 project 就可以了 下次用的时候切换一下就好了 https://www.google.com.hk/#safe=strict&q=sublime+project

  • 做 Web 前后端开发,Mac 苹果电脑,是最佳装备吗 at 2015年10月20日

    楼主还是用 3000 块笔记本吧 给你用肯定是浪费的

  • 欢迎 3 位新的 Ruby China 社区管理员 at 2015年10月14日

    👍

  • 这在 Rails 里也是默认的吗 (where 前没有 object)? at 2015年09月21日

    这种写法和 rails 无关,调用 where 的是 self, 而这里 self 指向的是 User.

  • [上海] 哔哩哔哩-诚邀 Ruby 工程师-还在继续! at 2015年07月03日

    B 站!

  • 乐享圣诞,喜迎新年抽奖活动(截止日期:2015.1.2) at 2014年12月26日

    66666

  • 一个简单的路由问题 at 2014年11月12日

    1 楼应该是正解。你得理解是错得

  • 你所不知道的 console 对象的五个函数 (功能) at 2014年11月11日

    👏

  • Koding 邀请用户送空间活动 at 2014年03月05日

    https://koding.com/R/ibrad

  • Peatio (貔貅) 电子加密货币交易所准备开源并征集内测用户 at 2014年02月17日

    [email protected]

  • [奖品图曝光] UPYUN 送上情人节三件套,祝大家码上有爱情 at 2014年02月11日

    苍老师!dreamfanbin at gmail.com

关于 / RubyConf / Ruby 镜像 / RubyGems 镜像 / 活跃会员 / 组织 / API / 贡献者
由众多爱好者共同维护的 Ruby 中文社区,本站使用 Homeland 构建,并采用 Docker 部署。
服务器由 赞助 CDN 由 赞助
iOS 客户端 / Android 客户端 简体中文 / English