我有一个特别复杂的模型,其中定义了验证和回调.业务需求现在需要一个特定的场景,添加新记录需要跳过验证和回调.最好的方法是什么?
我正在使用Rails 3.0.9,Ruby 1.9.2,Devise 1.3.4并且需要在Devise会话中使用新视图来访问请求url参数,尽管我将此视为一般的Rails请求处理问题.实质上,向Devise认证资源发出请求,该资源将用户重定向到登录屏幕.在登录视图中,我需要访问请求URL,例如,这是在开头调用的请求URL
http://mysite.com/article/5?type=blah
Run Code Online (Sandbox Code Playgroud)
在重定向登录页面中,我需要访问该URL,任何人都知道我该怎么做?
对于使用WSDL的Web服务调用,我收到错误Cannot find dispatch method for {http://ws.somecompany.com/services}ValidateUser,这究竟是什么意思?这是不是意味着找不到ValidateUser?
新的Sinatra,只是开发服务器启动和运行,但rackup使用WEBrick而不是Thin,Thin已经安装了宝石,这必须是一个简单的配置调整,但我不知道在哪里.哦,当你在它,Thin当我更改源代码时自动刷新?WEBrick当我更改源代码时,似乎必须停止并重新启动.
编辑
正如所建议的那样,thin start对我的设置进行调整.它本身会抛出一个错误"start_tcp_server": no acceptor (RuntimeError),这意味着我已经在该端口上运行了另一个服务.要解决这个问题,我只需运行thin start -p 9292.希望这有助于其他人.
我需要在登录过程中重写Devise会话控制器(Rails 3.0.9,Ruby 1.9.2,Devise 1.3.4),我尝试了这个没有任何影响
class SessionsController < Devise::SessionsController
# GET /resource/sign_in
def new
resource = build_resource
clean_up_passwords(resource)
respond_with_navigational(resource, stub_options(resource)){ render_with_scope :new }
end
end
Run Code Online (Sandbox Code Playgroud)
想法?
编辑 如答案所示,我还需要改变路线.另外,我还需要复制视图.这里有更好的解释 http://presentations.royvandewater.com/authentication-with-devise.html#8
我的自定义策略:
devise.rb
config.warden do |manager|
manager.strategies.add(:custom_strategy) do
def authenticate!
... authenticate against 3rd party API...
if res.body =~ /success/
u = User.find_or_initialize_by_email(params[:user][:email])
if u.new_record?
u.save
end
success!(u)
end
end
end
Run Code Online (Sandbox Code Playgroud) 目前的迁移:
t.string "email", :default => "", :null => false
add_index :users, :email, :unique => true
Run Code Online (Sandbox Code Playgroud)
我想创建一个新的迁移来删除:null => false要求,并删除default => ""for email.另外,我想更改要删除的索引:unique => true.语法是什么?
我on Rails的3.0.9,我想知道,如果它是安全的命名模式Request,我知道有一些保留字/特殊班的Ruby,Rails和SQL,不知道这是其中之一.