Skip to content

Commit

Permalink
Improved 'wrong rails version' error message.
Browse files Browse the repository at this point in the history
  • Loading branch information
parndt committed Sep 1, 2011
1 parent 21c6818 commit 1723076
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 9 additions & 4 deletions bin/refinerycms
Expand Up @@ -166,19 +166,21 @@ module Refinery
exit(1)
end

# Get the name and path of the new application
@app_path = Pathname.new(File.expand_path(@input.first))
@app_name = @app_path.to_s.split(File::SEPARATOR).last

rails_version_in_path = run_command('rails --version', {:cd => false, :bundler => false, :puts => false}).to_s.gsub(/(Rails |\n)/, '')
@rails_version_to_use = @options[:rails][:version] || rails_version_in_path
if @rails_version_to_use !~ %r{\b#{RAILS_MINOR_VERSION}}
puts "\nRails #{@rails_version_to_use} is not supported by Refinery #{::Refinery.version}, " \
"please use Rails #{RAILS_MINOR_VERSION}.x instead."
puts "\nYou can tell Refinery CMS an installed and compatible rails version to use like so:\n"
puts "\nrefinerycms #{@app_name} --rails-version #{RAILS_MINOR_VERSION}"
puts "\n"
exit(1)
end

# Get the name and path of the new application
@app_path = Pathname.new(File.expand_path(@input.first))
@app_name = @app_path.to_s.split(File::SEPARATOR).last

# Get the refinery path based on this file
@refinery_path = Pathname.new(File.expand_path('../../', __FILE__))

Expand Down Expand Up @@ -236,6 +238,9 @@ module Refinery
# Detect non-success or a blank rails output or starting with "Can't initialize" or "Error"
if !$?.success? or rails_output.to_s.length == 0 or rails_output =~ /^(Can't\ initialize|Error)/
puts "\nGenerating Rails application failed. Exiting..."
if run_command('gem list rails', {:cd => false, :puts => false, :ruby => false}) !~ %r{[( ]#{@rails_version_to_use}(.0)*[,\)]}
puts "\nDo you have Rails #{@rails_version_to_use} installed?"
end
puts "\n"
exit(1)
else
Expand Down
1 change: 1 addition & 0 deletions changelog.md
Expand Up @@ -2,6 +2,7 @@

* `refinerycms-core` now depends on rails so that users of 1.0.x can be confident of the entire stack being present as before. [Philip Arndt](https://github.com/parndt)
* No longer requiring autotest as a dependency of `refinerycms-testing`. [Philip Arndt](https://github.com/parndt)
* Improved 'wrong rails version' error message on install with a more helpful guide on how to specify a rails version. [Philip Arndt](https://github.com/parndt)
* [See full list](https://github.com/resolve/refinerycms/compare/1.0.7...1.0.8)

## 1.0.7 [31 August 2011]
Expand Down

0 comments on commit 1723076

Please sign in to comment.