小编Dmy*_*iak的帖子

为每个用户创建子域

如何注册期间为网站的每个注册用户创建子域?
对于下面的场景......

  1. 用户打开site.com/register.
  2. 提供详细信息和提交.
  3. 立即重定向到newuser.site.com
  4. 用户可以在newuser.site.com区域工作

我不知道如何解决这个问题:

  1. 为用户创建和传播子域.
  2. 使用单个ASP.NET应用程序来处理所有子域和主域.
  3. 配置IIS.

理想情况下,我希望尽可能地使用.NET Framework.

.net asp.net iis dns

3
推荐指数
1
解决办法
1598
查看次数

不执行ActiveRecord回调

鉴于以下规范:

describe Participation do
  describe "invitation by email", :focus do
    let(:participation) { build :participation } # Factory
    let(:email)         { participation.email }

    it "should send an invitation" do
      # This one is failing
      binding.pry # The code below is executed here
      participation.should_receive(:invite_user!)
      participation.save!
    end

    context "when user already exists" do
      let!(:existing) { create :user, :email => email }
      it "should not send an invitation" do
        participation.should_not_receive(:invite_user!)
        participation.save!
      end
    end
  end
end
Run Code Online (Sandbox Code Playgroud)

我似乎无法通过以下实现传递它:

class Participation < ActiveRecord::Base
  attr_accessor :email

  belongs_to :user
  validates …
Run Code Online (Sandbox Code Playgroud)

ruby activerecord rspec ruby-on-rails callback

2
推荐指数
1
解决办法
2336
查看次数

如何在Heroku上向PostgreSQL添加intarray扩展

我的应用程序正在使用intarrayPostgreSQL的扩展.

不幸的是,根据文档和命令行,它似乎不可用:

> echo 'show extwlist.extensions' | heroku pg:psql
                                                                                extwlist.extensions                                                                                 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 btree_gist,chkpass,cube,dblink,dict_int,dict_xsyn,earthdistance,fuzzystrmatch,hstore,isn,ltree,pg_trgm,pgcrypto,pgrowlocks,pgstattuple,plpgsql,unaccent,uuid-ossp,citext,tablefunc
(1 row)
Run Code Online (Sandbox Code Playgroud)

也:

> heroku pg:psql
psql (9.1.5, server 9.1.6)
SSL connection
Type "help" for help.

=> CREATE EXTENSION intarray;
WARNING:  extension "intarray" is not whitelisted
CREATE EXTENSION
Run Code Online (Sandbox Code Playgroud)

所以这是否意味着我不能使用Heroku或者有一种方法来添加intarray扩展(idx例如使用函数).

谢谢.

ruby sql postgresql heroku

2
推荐指数
1
解决办法
3194
查看次数

当MVC2视图不存在时返回HTTP 404

我只需要一个类似CMS的小型控制器.最简单的方法是这样的:

public class HomeController : Controller {
    public ActionResult View(string name) {
        if (!ViewExists(name))
            return new HttpNotFoundResult();
        return View(name);
    }

    private bool ViewExists(string name) {
        // How to check if the view exists without checking the file itself?
    }
}
Run Code Online (Sandbox Code Playgroud)

问题是如果没有可用的视图,如何返回HTTP 404?

可能我可以在适当的位置检查文件并缓存结果,但这感觉非常脏.

谢谢,
德米特里.

.net asp.net-mvc view http-status-code-404 asp.net-mvc-2

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

如何跳到/第N个逗号

可能重复:
在VIM上看到现场的最有效方法是什么?

使用这样的代码:

[caret here]create_stage :pay_deposit, due: deposit_due_date, actual: deposit_paid_date, action: 'Deposit', status: status
Run Code Online (Sandbox Code Playgroud)

我想跳到第N个逗号(或至少左右)之前/之后/之后 actual: deposit_paid, [need to be here], action: 'etc'

这样做最有效的方法是什么?(我目前只是w-w-w哪个很糟糕,也可以开始计算单词的数量来使用类似12w但只会分散太多的话).

我不想搜索,因为我想保持当前的搜索和突出显示.

unix navigation vim editor

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

更清晰的方法来定义没有lambda的方法

是否有更简单和/或更易读的方法在Ruby中创建闭包,以便定义的方法可以访问变量 m

我在lambda这里有一个轻微的"问题" .

我经常动态定义必须访问局部变量的方法:

例如:

class Comparison

  def income
    123
  end

  def sales
    42342
  end

  # and a dozen of other methods

  # Generate xxx_after_tax for each method
  instance_methods(false).each do |m|
    lambda {
      define_method("#{m}_after_tax") do
        send(m) * 0.9
      end
    }.call
  end
end
Run Code Online (Sandbox Code Playgroud)

ruby closures metaprogramming ruby-on-rails

0
推荐指数
1
解决办法
133
查看次数