I'm recently began working on a project which I've cloned from github.
Everytime I try start the rails server I get the following error:
/Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in load': /Users/thomas/Projects/BillingMiddleware/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end (SyntaxError)
...sion_store :cookie_store, key: '_BillingMiddleware_session'
^
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:inload'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in load_dependency'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:inload'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:588
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587:in each'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:ininstance_exec'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in run'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:55:inrun_initializers'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in each'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:inrun_initializers'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:136:in initialize!'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:insend'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in method_missing'
from /Users/thomas/Projects/BillingMiddleware/config/environment.rb:5
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:inrequire'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:inload_dependency'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in require'
from /Users/thomas/Projects/BillingMiddleware/config.ru:4
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:ininstance_eval'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in initialize'
from /Users/thomas/Projects/BillingMiddleware/config.ru:1:innew'
from /Users/thomas/Projects/BillingMiddleware/config.ru:1
My collegue is also working on the project and doesn't seem to have any problems starting the server. He is running the same version of ruby, rails and WeBrick as me.
I've tried changing the syntax from key: to :key =>, this shouldn't be the problem though as I am running ruby version 1.9.3. If I make that change anyhow I get a different error message:
/Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load': /Users/thomas/Projects/BillingMiddleware/config/initializers/wrap_parameters.rb:8: syntax error, unexpected ':', expecting kEND (SyntaxError)
wrap_parameters format: [:json]
^
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:245:in `load'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:588
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587:in `each'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/engine.rb:587
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `run_initializers'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `send'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/thomas/Projects/BillingMiddleware/config/environment.rb:5
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
from /Users/thomas/Projects/BillingMiddleware/config.ru:4
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
from /Users/thomas/.rvm/gems/ruby-1.9.3-p194/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
from /Users/thomas/Projects/BillingMiddleware/config.ru:1:in `new'
from /Users/thomas/Projects/BillingMiddleware/config.ru:1
I've tired completely removing and re-installing rvm, ruby and rails several times to no prevail. I’ve also tried running bundle install which hasn’t help.
Does anyone have any idea of what’s going wrong?
Thanks
Try changing your hashes to :key => :value syntax. The same error and fixes are discussed at Rails 3.1 Deployment to Heroku Error.
The temp fixes suggested are:
config/initializers/session_store.rb
App::Application.config.session_store :cookie_store, :key => '_BillingMiddleware_session'
config/initializers/wrap_parameters.rb
ActionController::Base.wrap_parameters :format => [:json]
Looks like hash syntax on another line, after you fixed that one. Check config/intializers/wrap_parameters.rb and i wonder if this project got the flag to "not" use the new syntax?
Related
I am adding the elasticsearch gem to an existing rails app hosted on Heroku.
Running MyModel.import in production is raising an error
MultiJson::ParseError: unexpected character at line 1, column 1 [parse.c:690]
As my development and test environments are working perfectly, I assume that this is being caused by the data in MyModel, perhaps an encoding issue. But as this table is quite large, I am having trouble tracking down the problem.
Can anyone confirm that this error is likely to be caused by an
issue in the data being imported?
Is there a way to inspect the JSON data representation that MyModel.import invokes?
EDIT
Following suggestions below, I have tried running a few commands to track down the error.
MyModel.all.each(&:as_json)
MyModel.all.each(&:as_indexed_json)
MyModel.all.each { |r| r.__elasticsearch__.as_indexed_json }
MyModel.all.each { |r| MultiJson.load r.to_json }
are all running without errors. However they do not appear to be returning json, but arrays of records. Is this usual?
[#<MyModel id: 1, ......
Running import on a limited number of records is also causing strange results.
# a single record returns no error
MyModel.import query: -> { where(id: 1) }
=> 0
# multiple records return the error
MyModel.import query: -> { where(id: 1..2) }
MultiJson::ParseError: unexpected character at line 1, column 1 [parse.c:690]
The full stack trace is
MultiJson::ParseError: unexpected character at line 1, column 1 [parse.c:690]
from /app/vendor/bundle/ruby/2.4.0/gems/multi_json-1.11.3/lib/multi_json/adapters/oj.rb:15:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/multi_json-1.11.3/lib/multi_json/adapters/oj.rb:15:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/multi_json-1.11.3/lib/multi_json/adapter.rb:20:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/multi_json-1.11.3/lib/multi_json.rb:119:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/serializer/multi_json.rb:24:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/base.rb:322:in `perform_request'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/transport/http/faraday.rb:20:in `perform_request'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-transport-5.0.4/lib/elasticsearch/transport/client.rb:131:in `perform_request'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-api-5.0.4/lib/elasticsearch/api/actions/bulk.rb:95:in `bulk'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-model-5.0.1/lib/elasticsearch/model/importing.rb:123:in `block in import'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-model-5.0.1/lib/elasticsearch/model/adapters/active_record.rb:106:in `block in __find_in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/relation/batches.rb:121:in `block in find_in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/relation/batches.rb:214:in `block in in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/relation/batches.rb:198:in `loop'
from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/relation/batches.rb:198:in `in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/activerecord-5.0.6/lib/active_record/relation/batches.rb:120:in `find_in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-model-5.0.1/lib/elasticsearch/model/adapters/active_record.rb:105:in `__find_in_batches'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-model-5.0.1/lib/elasticsearch/model/importing.rb:122:in `import'
from /app/vendor/bundle/ruby/2.4.0/gems/elasticsearch-model-5.0.1/lib/elasticsearch/model.rb:118:in `import'
from (irb):14
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/console.rb:65:in `start'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/console_helper.rb:9:in `start'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:78:in `console'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:9:in `require'
from bin/rails:9:in `<main>'
This is proving to be a frustrating issue to debug. I am grateful for any further suggestions or ideas.
I'm a beginner trying to learn rails. When i tried to run the "rails test" command, I get this message. I don't understand what this message is :/
rails test
Running via Spring preloader in process 46753
/Users/.../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require': /Users/..../test/controllers/static_pages_controller_test.rb:26: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `block in require'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:258:in `load_dependency'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/activesupport-5.1.1/lib/active_support/dependencies.rb:292:in `require'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:14:in `block in require_files'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:13:in `each'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/test_requirer.rb:13:in `require_files'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/minitest_plugin.rb:94:in `plugin_rails_init'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:81:in `block in init_plugins'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:79:in `each'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:79:in `init_plugins'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:130:in `run'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/railties-5.1.1/lib/rails/test_unit/minitest_plugin.rb:77:in `run'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/minitest-5.10.2/lib/minitest.rb:63:in `block in autorun'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/..../.rbenv/versions/2.4.1/lib/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
The error message is actually telling you exactly where the issue is.
On line 26 of your static_pages_controller_test.rb file, you're missing an end.
...static_pages_controller_test.rb:26: syntax error, unexpected end-of-input, expecting keyword_end (SyntaxError)...
It's telling you that you likely have either ommitted an end from your static_pages_controller_test.rb file. Or, you have an extra end in that file.
If you look at the error:
..../test/controllers/static_pages_controller_test.rb:26 syntax error,
unexpected end-of-input, expecting keyword_end (SyntaxError)`
It's telling you that something is amiss on line 26.
Then syntax error, means you have typed something incorrectly.
It then says unexpected end-of-input which means that the parser couldn't figure out where to end the method, and the reason for that is that it was expecting keyword_end, which means there is an end keyword missing.
I am trying to learn Ruby by following the railstutorial.org website. I am at the automated tests part, running Guard but it throws an error:
C:\Users\Thomas\Documents\Development\teachmtg.com [master]> bundle exec guard
C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard/dsl.rb:119:in `instance_eval': C:/Users/Thomas/Documents/Development/teachmtg.com/Guardfile:4: syntax error, unexpected ',' (SyntaxError)
guard 'rspec', :version => 2 do, :all_after_pass => false do
^
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard/dsl.rb:119:in `instance_eval_guardfile'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard/dsl.rb:74:in `evaluate_guardfile'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard.rb:147:in `setup_from_guardfile'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard.rb:63:in `setup'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard.rb:188:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/lib/guard/cli.rb:110:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/guard-1.8.1/bin/guard:6:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.3/bin/guard:23:in `load'
from C:/RailsInstaller/Ruby1.9.3/bin/guard:23:in `<main>'
As I am completely new to Ruby and Rails, I have no idea where to look, what to look for, etc.
Can you give me a few tips and pointers ?
Thanks !
Remove do from :version => 2 do, :all_after_pass ... expression in Guardfile.
I have a rails application which works built on my test environment.
ruby -v => 1.9.3p194
rails -v => 3.2.12
gem -v => 1.8.23
On the server I wish to deploy to, the outputs are the following:
ruby -v => 1.9.3p0
rails -v => 3.2.12
gem -v => 1.8.15
I've started with a fresh installation of the server but I cannot get the server version of ruby and gem to match.
Additionally when I run rails s on the server (just to test) this is the failed output:
rails s
=> Booting WEBrick
=> Rails 3.2.12 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load': /var/www/New/confed ':', expecting kEND (SyntaxError)
match '/about', to: 'static_pages#about'
^
/var/www/New/config/routes.rb:6: syntax error, unexpected ':', expecting kEND
match '/cv', to: 'static_pages#cv'
^
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:236:in `load_dependency'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/dependencies.rb:245:in `load'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `each'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:26:in `updater'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `call'
from /var/lib/gems/1.8/gems/activesupport-3.2.12/lib/active_support/file_update_checker.rb:78:in `execute'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:27:in `updater'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application/finisher.rb:66
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `send'
from /var/lib/gems/1.8/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /var/www/New/config/environment.rb:5
from /var/www/New/config.ru:3:in `require'
from /var/www/New/config.ru:3
from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.8/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /var/www/New/config.ru:0:in `new'
from /var/www/New/config.ru:0
I've looked on my test system and I don't have /var/lib/gems/1.8 I only have /var/lib/gems/1.9.1
From your stack trace, it actually looks like you're running against Ruby 1.8, which doesn't support the simplified hash syntax symbol: value whereas 1.8 only had :symbol => value.
You can use rvm or rbenv to manage multiple ruby versions. rbenv imo is the better of the two when working with Rails.
Answering Ryan's question of why I think rbenv > rvm is based on personal feelings. I've found rbenv easy to work with, easy to understand and conceptualize how it was working, and I haven't run into a scenario where it has failed me. Additionally the source code is quite readable, which made my one foray for configuration easy to do.
After I install the custom-err-msg plugin, I get an error when I try to run rails server:
$ rails server
=> Booting WEBrick
=> Rails 3.0.3 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/home/jason/rails/snip/vendor/plugins/custom-err-msg/init.rb:3: uninitialized constant ActiveRecord::Errors (NameError)
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/plugin.rb:81
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `send'
from /usr/lib/ruby/gems/1.8/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /home/jason/rails/snip/config/environment.rb:5
from /home/jason/rails/snip/config.ru:3:in `require'
from /home/jason/rails/snip/config.ru:3
from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /usr/lib/ruby/gems/1.8/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /home/jason/rails/snip/config.ru:1:in `new'
from /home/jason/rails/snip/config.ru:1
Any idea why this is happening?
Here's an updated version that will work with Rails 3.
https://github.com/seansawyer/custom-err-msg
To fix the undefined method keys for nil:NilClass error, a method in lib/custom_error_message.rb needs to be changed to this:
def starts_with_humanized_column_followed_by_circumflex?(message)
keys.any? do |column|
humanized = #base.class.human_attribute_name column.to_s.split('.').last.to_s
message.match(/^#{humanized} \^/)
end
end
Someone, please send him a pull request!
This plugin is not compatible with Rails 3. I would recommend finding a fork that is or forking it and updating yourself.