Analytical gem on Heroku error - ruby-on-rails-3

Good morning. I am trying to use this gem:
https://github.com/jkrall/analytical
On Heroku. It runs dandy on my local environment, but on Heroku busts out with:
2012-10-31T13:52:28+00:00 app[web.1]: /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 4, col 5: `' (ArgumentError)
2012-10-31T13:52:28+00:00 app[web.1]: from /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load'
2012-10-31T13:52:28+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/analytical-3.0.12/lib/analytical.rb:14:in `block in analytical'
2012-10-31T13:52:28+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/analytical-3.0.12/lib/analytical.rb:13:in `open'
2012-10-31T13:52:28+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/analytical-3.0.12/lib/analytical.rb:13:in `analytical'
2012-10-31T13:52:28+00:00 app[web.1]: from /app/app/controllers/api_controller.rb:1:in `<top (required)>'
The line in "api_controller.rb" it is references is simply the "analytical" statement that initializes the gem in that controller, per the documentation.
Tried putting "analytical" in application_controller instead and it errored out too (in both dev and staging).
Totally stumped. Any help would be much appreciated!

When I had a similar problem, the issue turned out to be a syntax error in my config/analytical.yml file. In development, I was able to put my Google Analytics ID in without quotes around it, but on Heroku it gave this error. So instead of this:
production:
google:
key: UA-XXXXXXXX-X
I did this:
production:
google:
key: "UA-XXXXXXXX-X"
Also, possibly you need to make sure there's a trailing carriage return after that last line

Related

Error: migrate SQLite to Postgres

I developed my app with the standard configuration (SQLite 3). I want do deploy on heroku and have to change to postgresql.
But I get this error, when trying to migrate my db-schema.
rake db:migrate
rake aborted!
/Users/adrianschnell/Sites/bills_cmd/config/initializers/session_store.rb:3: syntax error, unexpected ':', expecting $end
...sion_store :cookie_store, key: '_bills_cmd_session'
^
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:245:in `load'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:588
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/engine.rb:587
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `instance_exec'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:30:in `run'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:55:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `each'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/initializable.rb:54:in `run_initializers'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:136:in `initialize!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `send'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/adrianschnell/Sites/bills_cmd/config/environment.rb:8
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
/Library/Ruby/Gems/1.8/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:103:in `require_environment!'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application.rb:297:in `initialize_tasks'
Tasks: TOP => db:migrate => environment
I don't know what i have to do now.
My Gem File has included 'pg' and my database.yml looks like:
# PostgreSQL v0.8.x
# gem install pg
development:
adapter: postgresql
encoding: unicode
database: bills_cmd_dev
pool: 5
username: adrianschnell
password:
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
adapter: postgresql
encoding: unicode
database: bills_cmd_test
pool: 5
username: adrianschnell
password:
PostgreSQL is running - via terminal i can access it.
EDIT:
I noticed, that I get the following error when trying to create the postgre db:
rake db:create:all
rake aborted!
syntax error on line 18, col 11: `'
/Library/Ruby/Gems/1.8/gems/railties-3.2.11/lib/rails/application/configuration.rb:115:in `database_configuration'
/Library/Ruby/Gems/1.8/gems/activerecord-3.2.11/lib/active_record/railties/databases.rake:25
Tasks: TOP => db:create:all => db:load_config
(See full trace by running task with --trace)
after hours of searching and testing different suggestions, I tried the ones here: stackoverflow
especially the entry of Darren was the solution for me. Now my RoR App is running with postgre.

rails 3.2.9 bundler error

I am doing simple hello world project with rails but it seems it it throwing bundler error to me. I want to see how to remove the bundler errors that comes after i type
rails new helloproject
the errors in the console are:
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:271:in `<class:Path>': uninitialized constant Bundler::GemInstaller (NameError)
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:270:in `<module:Source>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:10:in `<module:Bundler>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:9:in `<top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:21:in `initialize'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `new'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `evaluate'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/definition.rb:18:in `build'
/usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
/usr/lib/ruby/vendor_ruby/bundler/cli.rb:222:in `install'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `block in <main>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `<main>'
There was an error in your Gemfile, and Bundler cannot continue.
I wonder how can i get past this error and bundle the application properly?
I do manage to run the server and run the hello world app but every new project seems to throw this bundler error.
I have checked similar questions but this one seems to be unique type of the error.
How to get rid of these bundler install errors?
Check the following steps,
gem install bundler
and after adding:
gem 'bundler'
in line 2 in config/boot.rb (just after require 'rubygems')
let me know if not solved.

"\xC4" from ASCII-8BIT to UTF-8 when running rake db:migrate on Heroku

When I try to run heroku run rake db:migrate in my application, I get the following error
"\xC4" from ASCII-8BIT to UTF-8
with a stacktrace of
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `write'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `puts'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:150:in `display_error_message'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:142:in `rescue in standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:132:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/app/.bundle/gems/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `load'
/app/.bundle/gems/ruby/1.9.1/bin/rake:19:in `'
I've tried setting encoding manually in config/environment.rb via
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
But it doesn't seem to help. The problem might be, that I'm using slim as a templating engine with many unicode characters directly in the templates, but I'm not sure if there's a better way of doing that.
Simply add this to the top of your file
# encoding: UTF-8
this error is frequent with migration when you insert data. For exemple I've got this with a simple migration adding Québec
Province.create(:name => 'Québec (Canada)')

rake db:migrate aborted! on US-ASCII using rake 0.9.2.2 and rails 3.0.10

Recently I upgraded my gems and started adding new stuff to my app like authentication by third party social websites using omniauth gem. On development environment everything is fine and works like a charm.
I am deploying to staging and production servers using capistrano. Basic deployment is fine and working so far, but I have got really strange problems when I want to do migrations when deploying.
I get the following error messages from capistrano:
[my.server.com] executing command
*** [err :: my.server.com] rake aborted!
*** [err :: my.server.com] "\xC5" on US-ASCII
*** [err :: my.server.com]
*** [err :: my.server.com] (See full trace by running task with --trace)
command finished in 2472ms
I was googling all around and couldn't find any relevant solution. I also tried to downgrade rake gem back to 0.8.7 but with no success on the end - the same errors.
After hours of googling and digging in I found the solution that (I hope) may by helpful for someone with a similar or the same problem.
I did bundle exec rake --trace db:migrate on the staging server and got the following error messages:
rake aborted!
"\xC5" on US-ASCII
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `read'
/var/www/myapp/test.myapp.com/releases/20111230233802/config/application.rb:5:in `<top (required)>'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `require'
/var/www/myapp/test.myapp.com/releases/20111230233802/Rakefile:4:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/rake_module.rb:25:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:501:in `raw_load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:82:in `block in load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:81:in `load_rakefile'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:65:in `block in run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `load'
/var/www/myapp/test.myapp.com/shared/bundle/ruby/1.9.1/bin/rake:19:in `<main>'
So I jumped in to the config/application.rb file to find out what could rise the error. Line 5 of that file loads an external config file:
require 'yaml'
APP_CONFIG = YAML.load(File.read(File.expand_path('../app_config.yml', __FILE__)))
and that external file contains UTF-8 chars, not US-ASCII. So I tried a couple of different solutions to solve that problem.
The only one which worked for me was to add an extra few lines of code on top of config/application.rb file:
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
just to tell rake to load external files using utf-8 encoding. After that change everything went smooth and exactly as expected. Problem solved!
PS.
I really don't know why developers of rake 0.9 have changed previous behavior of rake 0.8 which worked fine for me and probably for you as well for a long time. Maybe you have an idea why? I am very curious.

Why is my development server not loading? default_controller_and_action': missing :action (ArgumentError)

I'm a Ruby nuby (and new to Stack Overflow) working on the Rails Tutorial by Michael Hartl and all of a sudden my development server won't load and keeps exiting. Console also won't load and Rspec spec/ produces errors/exceptions. I am including some output from the terminal, your help is much appreciated.
Exiting
/Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:164:in `default_controller_and_action': missing :action (ArgumentError)
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:68:in `normalize_options!'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:51:in `initialize'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `new'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:261:in `match'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1112:in `match'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/mapper.rb:1297:in `match'
from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:11:in `block in <top (required)>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `instance_exec'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/actionpack-3.0.3/lib/action_dispatch/routing/route_set.rb:233:in `draw'
from /Users/ameedachowdhury/rails_projects/railstutorial/config/routes.rb:1:in `<top (required)>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `block in load'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `block in load_dependency'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:596:in `new_constants_in'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:225:in `load_dependency'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/dependencies.rb:235:in `load'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:127:in `block in reload_routes!'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:127:in `each'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:127:in `reload_routes!'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:120:in `block in routes_reloader'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `call'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/activesupport-3.0.3/lib/active_support/file_update_checker.rb:32:in `execute_if_updated'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application/finisher.rb:51:in `block (2 levels) in <module:Finisher>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `call'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application/finisher.rb:52:in `block in <module:Finisher>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `instance_exec'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/initializable.rb:25:in `run'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/initializable.rb:50:in `block in run_initializers'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `each'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/initializable.rb:49:in `run_initializers'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:134:in `initialize!'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/application.rb:77:in `method_missing'
from /Users/ameedachowdhury/rails_projects/railstutorial/config/environment.rb:5:in `<top (required)>'
from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `require'
from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:3:in `block in <main>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `new'
from /Users/ameedachowdhury/rails_projects/railstutorial/config.ru:1:in `<main>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/server.rb:162:in `app'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/commands/server.rb:65:in `start'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/commands.rb:30:in `block in <top (required)>'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap'
from /Users/ameedachowdhury/.rvm/gems/ruby-1.9.2-p0#rails3tutorial/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
ameeda-chowdhurys-macbook:railstutorial ameedachowdhury$
When I ran into this problem, it was because one of the routes in routes.rb had a slash (/) instead of the hash (#) when using the controller#action syntax (I used "controller/action", which was incorrect).
For example, I accidentally had root :to => 'home/index'. It was supposed to be root :to => 'home#index'.
I found this solution in here.
This is caused by incorrect routes -
Please check your config/routes.rb , even if one route mentioned is wrong then this error is thrown !!
Also make sure that the route is
'/url/for/something' => 'controller#action'
or
root :to => 'controller#action
I'm also a Ruby nuby and had the same error while working on the Rails Tutorial by Michael Hartl. If you're like me, you might be just typing in all code that appears in the book with really reading or understanding the text. Not everything is step by step. In demonstrating camel case vs. snake case Hartl shows a box with the following code
$ rails generate controller static_pages ...
Here, Hartl is simply trying to contrast instructions to generate a StaticPages controller using snake case, rather than camel case, which was done in Listing 3.4. The dots "..." are simply to edit out or truncate the rest of the instructions for the cmd line. I typed in exactly what was shown and wound up with the following in my routes file:
SampleApp::Application.routes.draw do
get "static_pages/..."
get "static_pages/home"
get "static_pages/help"
open up your routes file, delete
get "static_pages/..."
save the routes file, and try starting rails server again.
I also destroyed "rails generate controller static_pages ..." Not sure if that had any effect, but now everything works.
By default you get this:
Rails.application.routes.draw do
get 'static_pages/...'
get 'static_pages/home'
get 'static_pages/help'
JUST ERASE THIS:
get 'static_pages/...'
AND YOU WILL HAVE THIS IN THE ROUTES.RB FILE
Rails.application.routes.draw do
get 'static_pages/home'
get 'static_pages/help'
In my case it was caused by the suffix slash '/' in some of my routes. E.g.
post 'load_query/'
After removing this suffix to
post 'load_query'
it worked.
change your default root in the routes.rb file.
get "static_pages#home" TO root to: 'static_pages#home'
I've gone through the same issue, and the above change worked for me.