English 中文(简体)
铁路3个模板:注射器的距离
原标题:Rails 3 template: strange beahaviour of inject_into_file

I am writing a template for Rails 3 (you can find it here), and I m having troubles with the following lines:

# 8. config/database.yml modifications
if yes?("Do you want to set the database host to  /var/run/postgresql ?")
  inject_into_file "config/database.yml", " host: /var/run/postgresql
", :after => "development:
"


  # FIXME these two won t work :(((( why????
  # inject_into_file "config/database.yml", " host: /var/run/postgresql
", :after => "production:
"
  # inject_into_file "config/database.yml", " host: /var/run/postgresql
", :after => "test:
"


  # Not finding other solutions, I rewrite the two blocks above with two seds
  run %q(sed -i  /test:/a  host: /var/run/postgresql  config/database.yml)
  run %q(sed -i  /production:/a  host: /var/run/postgresql  config/database.yml)
end

也就是说,第一个投放者——书本作品,以及汇/数据库。 页: 1 我

development:
  host: /var/run/postgresql

但是,其他两种注射器——纸面成功应用,但不会修改汇/数据库。 因此,我

test:
  adapter: postgresql

and

production:
  adapter: postgresql
最佳回答
问题回答

我在此 st卑地寻求解决一个略有不同的问题:

铁路公司说,以这种方式使用注射器。

inject_into_file  name_of_file.rb , after: "#The code goes below this line. Don t forget the Line break at the end
" do <<- RUBY 
  puts "Hello World"
RUBY
end

然而,这在我整个时间都没有奏效。 在某些情况下,它实际上将把“投射”一词和一些废气编码带入试图注入的档案中。

最后,我表示,你只能通过<代码>inject_into_file。 a 体积,而且非常容易。

inject_into_file  name_of_file.rb , :after => "#The code goes below this line. Don t forget the Line break at the end
" do
  "Hello World"
end




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签