试试 roo 或 spreadsheet 吧
+1
http://railscasts.com/episodes/269-template-inheritance prepend_view_path 呢?
#14 可以在后端生成好 html 第一次请求的时候返回给前端嘛,没说前端话后端的 view 就完全不用,呵呵
number.gsub(/^(?<h>[\d]{6})([\d]*)(?<t>[\w]{4})$/, '\k<h>XXXXXXXX\k<t>')
这样?
wget -mk 吧
哈哈,好安逸~
2 确实是都可以用 respond_with
下面是一些用法
这个就是很经典的那种写法的简写
@message.new(params[:message])
@message.save
respond_with @message, :location => [:messages], :action => :new
有 namespance 时
respond_with :admin, @repository
respond_with :admin, @repository, :location => root_path
使用嵌套路由时
respond_with @post, @comment
当然,如果你想自定义 response code 时,使用类似这个方法 https://github.com/nesquena/rabl/wiki/Response-Codes
如果你想自定义 flash,参考 https://github.com/plataformatec/responders
配合 respond_to 就可以定义 action 使用 哪些 template
3 respond_with 后面传递那个 resource 仅仅是用 resource.errors.empty? 来判断成功和失败的
4 在 search 完成后的 template 里直接用 controller 里的 @xx 就好了,不需要传递
就用 category 字段就好了,重复的代码写到 module
hi @Saito 看了 #6 的回复,现在 gitlab 还是通过修改 authorized_key,指定使用自己的 ssh magic command 用脚本来实现从数据库中匹配 user 和 repo 的关系吧?听了第六期的 http://teahour.fm/2013/03/11/git-github-and-gitlab.html ,再看 #7 #8 回复,这里有个疑问,如果不用 authorized_key,是选择修改 sshd pam 呢?还是选择类似于用 eventmachine 写个 sshd 来实现呢?pam 中如何指定 command 能否给个参考资料呢?谢谢
开发的时候就仅仅是 require,开发完成后根据 Gemfile.lock 回头再来固定版本 基本上默认最新的都是稳定版本
嗯,在理
TestsController.action(:test).call(env)
但是这样意义不大,基本上都是在 middleware 和 routes.rb 中这样用,action 中这样调没啥意义。
validates ... :on => :update
注册和更新分开 valid
更新前需要验证当前密码 devise 有提供 update_with_password
https://github.com/plataformatec/devise/blob/master/lib/devise/models/database_authenticatable.rb#L56 方法,需要你提供 params[:current_password]
,controller 里也就需要使用 update_with_password
,现有的 devise 提供的修改基本信息 https://github.com/plataformatec/devise/blob/master/app/controllers/devise/registrations_controller.rb#L39 只要提供当前密码包括 email password 等其他信息都是一起改的。按照你的需求,你得自己定义个新的路由来更改信息,controller 参考 registrations#update 写就 ok 了,可以根据需求使用 update_with_password
和 update_without_password
config.xx 直接 application.rb 里改就是了,为啥在 environment.rb 改呢?
Rails::Initializer
是不是 Rails::Initializable::Initializer
这个?
换用 sidekiq 呢?代码基本上不用改动。
<<简约之美:软件设计之道>> 不晓得这本杂样?
感谢推荐,“此书每篇都不长,但是每篇都会让你有所感悟,有所收获”就冲这句,买来品之!
resource=
https://github.com/plataformatec/devise/blob/master/app/controllers/devise_controller.rb#L92
resource
https://github.com/plataformatec/devise/blob/master/app/controllers/devise_controller.rb#L16
sign_in
https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb#L114
也就是说 sign_in 的时候会给 "@#{resource_name}"
赋值,当然还有几个地方会对 "@#{resource_name}"
进行修改的,具体的可以搜索下 resource =
、resource ||=
、resource=
这些
血泪的教训啊~
#2 楼 @scige 每个人一个 sqlite,可以使用下面的方法动态生成一个 model 来做数据操作了。建库、建表参考 https://github.com/luislavena/sqlite3-ruby 吧,上面有例子。当然也可以用 migration 来做这个事情。
require 'sqlite3'
require 'active_record'
my_ar = Class.new(ActiveRecord::Base) do
self.abstract_class = true
establish_connection(
:adapter => "sqlite3",
:database => "/tmp/tmp.sqlite3"
)
end
my_user = Class.new(my_ar) do
self.table_name = 'users'
end
my_user.new
如果只是自己用用,数据量不大的话,每个人一个 sqlite 好了,简单
ruby 1.8 是 $KCODE='UTF-8'
,1.9 才是 #encoding: utf-8
REXML 默认的 encoding 就是 utf-8,所以 xml 应该是 utf-8 的,参考 http://ruby-doc.org/stdlib-1.8.6/libdoc/rexml/rdoc/REXML/Encoding.html
当数据库性能发生瓶颈的时候再解决这个问题吧,到时候也仅仅是 去掉 touch: true
加点 after_commit
update_all
之类的
你忘记了加 "less-rails" 这个 gem
group :assets do
gem "therubyracer"
gem "less-rails"
end
gem "twitter-bootstrap-rails"