开发者

Is there any way to hook the "controller" generator so it runs "rspec_controller"?

I want to make 开发者_JAVA百科it so I can just type script/generate controller and it will run script/generate rspec_controller. How can I do this?


Do you mean that you want it:

  1. to also run script/generate rspec_controller, or
  2. to only run script/generate rspec_controller?

If 1 then you have multiple options. The simplest and less intrusive would probably be to simply wrap script/generate as follows:

  1. rename script/generate as script/generate.orig
  2. create script/generate anew with the following contents:

    #!/bin/sh
    "`dirname \"$0\"`/generate.orig" "$@"
    if [ "$1" == "controller" ] ; then
      shift
      "`dirname \"$0\"`/generate.orig" rspec_controller "$@"
    fi
    
  3. ensure the new script/generate is executable etc., e.g. chmod a+rx script/generate

  4. add script/generate.orig to source control and checkin the modified script/generate script
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜