Strange rails error - ruby-on-rails

Everything in my app was working fine, walked away for a few hours and came back to this...
Psych::SyntaxError in Home#index
Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/layouts/_navigation.html.erb where line #16 raised:
couldn't parse YAML at line 13 column 2
Extracted source (around line #16):
13: <div class="testform">
14: <%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
15:
16: <%= f.input :email, :required => false, :autofocus => true, :label => false, :placeholder => 'Email' %>
17: <%= f.input :password, :required => false, :label => false, :placeholder => 'Password' %>
18: <%= f.button :submit, "Sign in", :class =>'btn btn-info' %>
19: <%= link_to 'Sign up', new_user_registration_path, :class=>'btn btn-success' %>
Trace of template inclusion: app/views/layouts/application.html.erb
Rails.root: /Users/nelsonkeating/Desktop/ReminDeal
Application Trace | Framework Trace | Full Trace
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse'
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:119:in `parse'
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:106:in `load'
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:205:in `load_file'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:171:in `load_yml'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:157:in `load_file'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:in `block in load_translations'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:in `each'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:15:in `load_translations'
/gems/i18n-0.6.0/lib/i18n/backend/simple.rb:57:in `init_translations'
/gems/i18n-0.6.0/lib/i18n/backend/simple.rb:71:in `lookup'
/gems/i18n-0.6.0/lib/i18n/backend/base.rb:26:in `translate'
/gems/i18n-0.6.0/lib/i18n.rb:156:in `block in translate'
/gems/i18n-0.6.0/lib/i18n.rb:152:in `catch'
/gems/i18n-0.6.0/lib/i18n.rb:152:in `translate'
/gems/simple_form-2.0.2/lib/simple_form/inputs/base.rb:174:in `translate'
/gems/simple_form-2.0.2/lib/simple_form/components/hints.rb:8:in `hint'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/single.rb:12:in `render'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:29:in `block in render'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:27:in `each'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:27:in `render'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:29:in `block in render'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:27:in `each'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/many.rb:27:in `render'
/gems/simple_form-2.0.2/lib/simple_form/wrappers/root.rb:15:in `render'
/gems/simple_form-2.0.2/lib/simple_form/form_builder.rb:115:in `input'
app/views/layouts/_navigation.html.erb:16:in `block in _app_views_layouts__navigation_html_erb__200588386938644858_70171278998500'
/gems/actionpack-3.2.3/lib/action_view/helpers/capture_helper.rb:40:in `block in capture'
/gems/actionpack-3.2.3/lib/action_view/helpers/capture_helper.rb:187:in `with_output_buffer'
/gems/actionpack-3.2.3/lib/action_view/helpers/capture_helper.rb:40:in `capture'
/gems/actionpack-3.2.3/lib/action_view/helpers/form_helper.rb:606:in `fields_for'
/gems/client_side_validations-3.1.4/lib/client_side_validations/action_view/form_helper.rb:45:in `fields_for'
/gems/actionpack-3.2.3/lib/action_view/helpers/form_helper.rb:377:in `form_for'
/gems/client_side_validations-3.1.4/lib/client_side_validations/action_view/form_helper.rb:28:in `form_for'
/gems/simple_form-2.0.2/lib/simple_form/action_view_extensions/form_helper.rb:33:in `block in simple_form_for'
/gems/simple_form-2.0.2/lib/simple_form/action_view_extensions/form_helper.rb:51:in `with_simple_form_field_error_proc'
/gems/simple_form-2.0.2/lib/simple_form/action_view_extensions/form_helper.rb:32:in `simple_form_for'
app/views/layouts/_navigation.html.erb:14:in `_app_views_layouts__navigation_html_erb__200588386938644858_70171278998500'
/gems/actionpack-3.2.3/lib/action_view/template.rb:143:in `block in render'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:125:in `instrument'
/gems/actionpack-3.2.3/lib/action_view/template.rb:141:in `render'
/gems/actionpack-3.2.3/lib/action_view/renderer/partial_renderer.rb:265:in `render_partial'
/gems/actionpack-3.2.3/lib/action_view/renderer/partial_renderer.rb:238:in `block in render'
/gems/actionpack-3.2.3/lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `block in instrument'
/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `instrument'
/gems/actionpack-3.2.3/lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
/gems/actionpack-3.2.3/lib/action_view/renderer/partial_renderer.rb:237:in `render'
/gems/actionpack-3.2.3/lib/action_view/renderer/renderer.rb:41:in `render_partial'
/gems/actionpack-3.2.3/lib/action_view/helpers/rendering_helper.rb:27:in `render'
app/views/layouts/application.html.erb:20:in `_app_views_layouts_application_html_erb___581424401402979334_70171303782600'
/gems/actionpack-3.2.3/lib/action_view/template.rb:143:in `block in render'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:125:in `instrument'
/gems/actionpack-3.2.3/lib/action_view/template.rb:141:in `render'
/gems/actionpack-3.2.3/lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
/gems/actionpack-3.2.3/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
/gems/actionpack-3.2.3/lib/action_view/renderer/template_renderer.rb:18:in `render'
/gems/actionpack-3.2.3/lib/action_view/renderer/renderer.rb:36:in `render_template'
/gems/actionpack-3.2.3/lib/action_view/renderer/renderer.rb:17:in `render'
/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:110:in `_render_template'
/gems/actionpack-3.2.3/lib/action_controller/metal/streaming.rb:225:in `_render_template'
/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:103:in `render_to_body'
/gems/actionpack-3.2.3/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
/gems/actionpack-3.2.3/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:88:in `render'
/gems/actionpack-3.2.3/lib/action_controller/metal/rendering.rb:16:in `render'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
/gems/activesupport-3.2.3/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
/gems/activesupport-3.2.3/lib/active_support/core_ext/benchmark.rb:5:in `ms'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
/gems/activerecord-3.2.3/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:39:in `render'
/gems/actionpack-3.2.3/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
/gems/actionpack-3.2.3/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:167:in `process_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/rendering.rb:10:in `process_action'
/gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:425:in `_run__3144154735564117921__process_action__4375222825164767808__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
/gems/actionpack-3.2.3/lib/abstract_controller/callbacks.rb:17:in `process_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/rescue.rb:29:in `process_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `block in instrument'
/gems/activesupport-3.2.3/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
/gems/activesupport-3.2.3/lib/active_support/notifications.rb:123:in `instrument'
/gems/actionpack-3.2.3/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
/gems/actionpack-3.2.3/lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
/gems/activerecord-3.2.3/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
/gems/actionpack-3.2.3/lib/abstract_controller/base.rb:121:in `process'
/gems/actionpack-3.2.3/lib/abstract_controller/rendering.rb:45:in `process'
/gems/actionpack-3.2.3/lib/action_controller/metal.rb:203:in `dispatch'
/gems/actionpack-3.2.3/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
/gems/actionpack-3.2.3/lib/action_controller/metal.rb:246:in `block in action'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:36:in `call'
/gems/journey-1.0.3/lib/journey/router.rb:68:in `block in call'
/gems/journey-1.0.3/lib/journey/router.rb:56:in `each'
/gems/journey-1.0.3/lib/journey/router.rb:56:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/routing/route_set.rb:600:in `call'
/gems/client_side_validations-3.1.4/lib/client_side_validations/middleware.rb:18:in `call'
/gems/warden-1.1.1/lib/warden/manager.rb:35:in `block in call'
/gems/warden-1.1.1/lib/warden/manager.rb:34:in `catch'
/gems/warden-1.1.1/lib/warden/manager.rb:34:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/head.rb:14:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/flash.rb:242:in `call'
/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/cookies.rb:338:in `call'
/gems/activerecord-3.2.3/lib/active_record/query_cache.rb:64:in `call'
/gems/activerecord-3.2.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:467:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `_run__2947535173615619242__call__2415189830075756674__callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:405:in `__run_callback'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
/gems/activesupport-3.2.3/lib/active_support/callbacks.rb:81:in `run_callbacks'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/reloader.rb:65:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
/gems/railties-3.2.3/lib/rails/rack/logger.rb:26:in `call_app'
/gems/railties-3.2.3/lib/rails/rack/logger.rb:16:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/request_id.rb:22:in `call'
/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
/gems/activesupport-3.2.3/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
/gems/actionpack-3.2.3/lib/action_dispatch/middleware/static.rb:62:in `call'
/gems/railties-3.2.3/lib/rails/engine.rb:479:in `call'
/gems/railties-3.2.3/lib/rails/application.rb:220:in `call'
/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
/gems/railties-3.2.3/lib/rails/rack/log_tailer.rb:14:in `call'
/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in '
/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
/gems/railties-3.2.3/lib/rails/commands.rb:50:in `'
script/rails:6:in `require'
script/rails:6:in `'
Request
Parameters:
None
Show session dump
Show env dump
Response
Headers:
None
Heres the entire _navigation file..
<ul class="nav">
<span class="brand span" href="#">
<%= link_to logo, root_path %>
</span>
<div class="span6 pull-right" id="nav-cont">
<% if user_signed_in? %>
<li>
<div class="logout1">
<%= link_to 'Logout', destroy_user_session_path, :method=>'delete', :class=>'btn btn-inverse' %>
</div>
</li>
<% else %>
<div class="testform">
<%= simple_form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
<%= f.input :email, :required => false, :autofocus => true, :label => false, :placeholder => 'Email' %>
<%= f.input :password, :required => false, :label => false, :placeholder => 'Password' %>
<%= f.button :submit, "Sign in", :class =>'btn btn-info' %>
<%= link_to 'Sign up', new_user_registration_path, :class=>'btn btn-success' %>
</div>
<% end %>
<% end %>
</div>
en.yml
# Sample localization file for English. Add more files in this directory for locales.
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
en:
hello: "Hello world"
database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
# 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: sqlite3
database: db/test.sqlite3
pool: 5
timeout: 5000
production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000
devise.en.yml
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
en:
errors:
messages:
expired: "has expired, please request a new one"
not_found: "not found"
already_confirmed: "was already confirmed, please try signing in"
not_locked: "was not locked"
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
:"%{count} errors prohibited this %{resource} from being saved:"
devise:
failure:
already_authenticated: 'You are already signed in.'
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
updated_not_active: 'Your password was changed successfully.'
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'Welcome! You have signed up successfully.'
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
updated: 'You updated your account successfully.'
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
omniauth_callbacks:
success: 'Successfully authenticated from %{kind} account.'
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions'
NEW ERROR
ArgumentError in Home#index
Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/layouts/_navigation.html.erb where line #16 raised:
syntax error on line 12, col -1: ` devise:
failure:
already_authenticated: 'You are already signed in.'
unauthenticated: 'You need to sign in or sign up before continuing.'
unconfirmed: 'You have to confirm your account before continuing.'
locked: 'Your account is locked.'
invalid: 'Invalid email or password.'
invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.'
sessions:
signed_in: 'Signed in successfully.'
signed_out: 'Signed out successfully.'
passwords:
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
updated: 'Your password was changed successfully. You are now signed in.'
updated_not_active: 'Your password was changed successfully.'
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
confirmations:
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
confirmed: 'Your account was successfully confirmed. You are now signed in.'
registrations:
signed_up: 'Welcome! You have signed up successfully.'
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
updated: 'You updated your account successfully.'
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
omniauth_callbacks:
success: 'Successfully authenticated from %{kind} account.'
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
mailer:
confirmation_instructions:
subject: 'Confirmation instructions'
reset_password_instructions:
subject: 'Reset password instructions'
unlock_instructions:
subject: 'Unlock Instructions''

The "couldn't parse YAML" error suggests that there is an issue with the formatting of a YAML file.
In your case, there's a formatting error in your devise.en.yml:
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
:"%{count} errors prohibited this %{resource} from being saved:"
Before the : on the last line, it is missing a key. Perhaps this was accidentally deleted somehow? In other devise translation files, I typically see the key "other".
not_saved:
one: "1 error prohibited this %{resource} from being saved:"
other: "%{count} errors prohibited this %{resource} from being saved:"

Try
en:
- hello: "Hello world"

Replaced all YML files with previous versions.. if you have a problem like this there is probably and extra character or space buried in one of those files.. can be impossible to find, recommend replacing files if they have not been modified.

I had this error and it turned out to be a tab character that was present on a blank line. Invisible, but apparently caused the parser to choke.
To find it in vim I did a search for tab chars:
/\t

Related

ActiveRecord::RecordNotFound - Couldn't find User with id= in Rails

I am following this tutorial link for JQuery validations.
In the link they gave the routes as:
in routes.rb
map.check_email “users/check_email”, :controller => “users”, :action => “check_email”
map.resources :users
As it is throwing error, I changed:
match '/check_email' => 'users#check_email', :as => 'check_email'
devise_for :users, :controllers => {:sessions => 'sessions'}, :path => '', :path_names => { :sign_in => "login", :sign_out => "logout" }
Added jquery.validate to assets/javascripts.
users_controller.rb:
def check_email
Rails.logger.debug "check_email..................."
#user = User.find_by_email(params[:user][:email])
respond_to do |format|
format.json { render :json => !#user }
end
end
def show
#user = User.find(params[:id])
#hide_logo_section = Rails.application.config.custom.force_report_logo_accounts.include?(#user.account.name)
respond_to do |format|
format.html # show.html.erb
format.json { render :json => #user }
end
end
In sessions/new,the login form is followed by Forgot password.
app/views/sessions/new.html.erb:
<%= semantic_form_for(resource_name, :url => password_path(resource_name), :remote => true, :format => :json, :html => { :id => 'password_reset' }) do |f| %>
<%= f.inputs do %>
<%= f.input :email, :label => 'Your email address', :input_html => { :id => 'user_email_field',:placeholder => "Enter your email..."}%>
<label id="error_explanation1" class="error errorExplanation" style="margin-top:-10px;"></label>
<% end %>
<%= f.buttons do %>
<%= f.commit_button :label => 'Send me that link', :button_html => {:class => 'submit button', :id => 'forgot_password_button', :disable_with => 'Wait...' }%>
<% end %>
<% end %>
<script type="text/javascript">
$(document).ready(function () {
alert('hellllllll');
$('#password_reset').validate({
debug: true,
rules: {
'user[email]': {required: true, email: true,
remote:'/users/check_email' }
}
});
});
</script>
I am calling controller in the above script with remote.
The required and email validations are fine but it is throwing error when checking the method. Infact it is not going to the method check_email and showing id=check_email in the log.
This is my log:
Started GET "/login" for 127.0.0.1 at 2016-11-04 15:36:22 +0530
Processing by SessionsController#new as HTML Rendered
sessions/new.html.erb within layouts/home (1152.6ms) Rendered
home/_header.html.erb (0.5ms) Rendered home/_footer.html.erb (0.4ms)
Completed 200 OK in 1718ms (Views: 1315.0ms | ActiveRecord: 0.0ms)
Started GET "/assets/application.js" for 127.0.0.1 at 2016-11-04
15:36:24 +0530 RailsDevTweaks: Skipping ActionDispatch::Reloader hooks
for this request.
Started GET "/users/check_email?user%5Bemail%5D=test1%40gmail.com" for
127.0.0.1 at 2016-11-04 15:36:38 +0530 RailsDevTweaks: Skipping ActionDispatch::Reloader hooks for this request. Processing by
UsersController#show as JSON Parameters:
{"user"=>{"email"=>"test1#gmail.com"}, "id"=>"check_email"} User
Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."account_id"
IS NULL AND "users"."id" = ? AND (users.deleted_at IS NULL) LIMIT 1
[["id", "check_email"]] Completed 404 Not Found in 331ms
ActiveRecord::RecordNotFound - Couldn't find User with id=check_email
[WHERE "users"."account_id" IS NULL AND (users.deleted_at IS NULL)]:
(gem)
activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:343:in
find_one' (gem)
activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:314:in
find_with_ids' (gem)
activerecord-3.2.13/lib/active_record/relation/finder_methods.rb:107:in
find' (gem)
activerecord-3.2.13/lib/active_record/associations/collection_association.rb:95:infind' (gem)
activerecord-3.2.13/lib/active_record/associations/collection_proxy.rb:46:in
find' (gem)
inherited_resources-1.3.1/lib/inherited_resources/base_helpers.rb:44:in
resource' (gem) cancan-1.6.9/lib/cancan/inherited_resource.rb:12:in
load_resource_instance' (gem)
cancan-1.6.9/lib/cancan/controller_resource.rb:32:inload_resource'
(gem) cancan-1.6.9/lib/cancan/controller_resource.rb:25:in
load_and_authorize_resource' (gem)
cancan-1.6.9/lib/cancan/controller_resource.rb:10:inblock in
add_before_filter' (gem)
activesupport-3.2.13/lib/active_support/callbacks.rb:429:in
_run__917766069841795016__process_action__2108608744963441679__callbacks'
(gem) activesupport-3.2.13/lib/active_support/callbacks.rb:405:in
__run_callback' (gem)
activesupport-3.2.13/lib/active_support/callbacks.rb:385:in
_run_process_action_callbacks' (gem)
activesupport-3.2.13/lib/active_support/callbacks.rb:81:in
run_callbacks' (gem)
actionpack-3.2.13/lib/abstract_controller/callbacks.rb:17:in
process_action' (gem)
actionpack-3.2.13/lib/action_controller/metal/rescue.rb:29:in
process_action' (gem)
actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:30:in
block in process_action' (gem)
activesupport-3.2.13/lib/active_support/notifications.rb:123:inblock
in instrument' (gem)
activesupport-3.2.13/lib/active_support/notifications/instrumenter.rb:20:in
instrument' (gem)
activesupport-3.2.13/lib/active_support/notifications.rb:123:in
instrument' (gem)
actionpack-3.2.13/lib/action_controller/metal/instrumentation.rb:29:in
process_action' (gem)
actionpack-3.2.13/lib/action_controller/metal/params_wrapper.rb:207:in
process_action' (gem)
activerecord-3.2.13/lib/active_record/railties/controller_runtime.rb:18:in
process_action' (gem)
actionpack-3.2.13/lib/abstract_controller/base.rb:121:inprocess'
(gem) actionpack-3.2.13/lib/abstract_controller/rendering.rb:45:in
process' (gem)
actionpack-3.2.13/lib/action_controller/metal.rb:203:indispatch'
(gem)
actionpack-3.2.13/lib/action_controller/metal/rack_delegation.rb:14:in
dispatch' (gem)
actionpack-3.2.13/lib/action_controller/metal.rb:246:inblock in
action' (gem)
actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in
call' (gem)
actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:73:in
dispatch' (gem)
actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:36:in
call' (gem) journey-1.0.4/lib/journey/router.rb:68:inblock in
call' (gem) journey-1.0.4/lib/journey/router.rb:56:in each' (gem)
journey-1.0.4/lib/journey/router.rb:56:incall' (gem)
actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:612:in
call' (gem)
meta_request-0.2.1/lib/meta_request/middlewares/app_request_handler.rb:11:in
call'
Please helpActiveRecord::RecordNotFound - Couldn't find User with id=
The problem is on your routes. Check what rails docs says:
Rails routes are matched in the order they are specified, so if you have a resources :photos above a get 'photos/poll' the show action's route for the resources line will be matched before the get line. To fix this, move the get line above the resources line so that it is matched first.
When you call the URL: /users/check_email actually you're executing the users#show action.
Change your check_email route to something like
get '/users/validation/check_email', to: 'users#check_email', as: :check_email
and it will work.
ps: don't forget to update the url on your javascript.

Why isn't my Rails 3 Action Mailer sending out an email when I'm trying to use activation through Sorcery?

I using sorcery for email activation and I've followed their wiki tutorial: https://github.com/NoamB/sorcery/wiki/User-Activation.
I'm pretty sure the problem lies within sending out emails and less so towards activation because that is another issue.
Here's the code for User Mailer:
class UserMailer < ActionMailer::Base
default :from => "my_gmail_account#gmail.com"
def activation_needed_email(user)
#user = user
#url = "http://0.0.0.0:3000/users/#{user.activation_token}/activate"
mail :to => user.email,
:subject => "Welcome to PolyHerd.com"
end
end
Here's my development.rb file:
SampleApp::Application.configure do
# Settings specified here will take precedence over those in config/application.rb
config.action_mailer.delivery_method = :smtp
ActionMailer::Base.perform_deliveries = true
ActionMailer::Base.smtp_settings = {
:address => "smtp.gmail.com",
:port => "587",
:domain => "localhost:3000",
:enable_starttls_auto => true,
:authentication => "plain",
:user_name => "my_gmail_account#gmail.com",
:password => "my_pw"
}
I'm getting this when I run the code through console:
ruby-1.9.2-p180 :017 > UserMailer.activation_needed_email(u).deliver
ActionView::Template::Error: ActionView::Template::Error
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activemodel-3.0.10/lib/active_model/attribute_methods.rb:392:in `method_missing'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.0.10/lib/active_record/attribute_methods.rb:46:in `method_missing'
from /Users/x/sample_app/app/views/user_mailer/activation_needed_email.text.erb:1:in `_app_views_user_mailer_activation_needed_email_text_erb__925048320772673370_2171058260_3164940035285331741'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/action_view/template.rb:135:in `block in render'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.10/lib/active_support/notifications.rb:54:in `instrument'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/action_view/template.rb:127:in `render'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/action_view/render/rendering.rb:59:in `block in _render_template'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `block in instrument'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.10/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.0.10/lib/active_support/notifications.rb:52:in `instrument'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/action_view/render/rendering.rb:56:in `_render_template'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/action_view/render/rendering.rb:26:in `render'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:115:in `_render_template'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:109:in `render_to_body'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:102:in `render_to_string'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:93:in `render'
... 7 levels...
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/base.rb:673:in `mail'
from /Users/x/sample_app/app/mailers/user_mailer.rb:14:in `activation_needed_email'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:150:in `process_action'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/base.rb:119:in `process'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.0.10/lib/abstract_controller/rendering.rb:41:in `process'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/old_api.rb:75:in `process'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/base.rb:471:in `process'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/base.rb:466:in `initialize'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/base.rb:450:in `new'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/actionmailer-3.0.10/lib/action_mailer/base.rb:450:in `method_missing'
from (irb):17
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.10/lib/rails/commands/console.rb:44:in `start'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.10/lib/rails/commands/console.rb:8:in `start'
from /Users/x/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.10/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
EDIT:
Here's the email template:
Welcome to PolyHerd.com, <%= #user.username %>
===============================================
Congratulations, you are now a part of Poly Herd,
your username is: <%= #user.username %>.
To activate your account, just follow this link: <%= #url %>.
Thanks for joining and have a great day!
I was getting no error, however mails were not going out.
On looking at your domain, I got tempted to change mine. Am also in development mode. I changed it to localhost:3000, and mails are now coming through.
You guys rock!!!
Simon

Problem when migrating from Authlogic to Devise

I referred this Migrating from Authlogic to Devise
and followed it to get the database structure required by devise ready.
However I get this error on my sign_in page
wrong number of arguments (2 for 1)
This is my Request:
{"commit"=>"Sign in","authenticity_token"=>"oWXrE+EdhO4ScuaBzPBqCnpYsal1QcDC483ygVSs0fw=","user"=>{"password"=>"password", "email"=>"email#email.com"}}
I'm using Rails 2.3.8 and hence using Devise v 1.0.
This is my sessions/new view :
<% form_for resource_name, resource, :url => session_path(resource_name) do |f| -%>
<p><%= f.label :email %></p>
<p><%= f.text_field :email %></p>
<p><%= f.label :password %></p>
<p><%= f.password_field :password %></p>
<p><%= f.submit "Sign in" %></p>
<% end -%>
Any ideas to get this to work? Thanks !
EDIT
Here's the stack trace:
ArgumentError (wrong number of arguments (2 for 1)):
devise (1.0.8) lib/devise/models/database_authenticatable.rb:139:in `find_for_authentication'
devise (1.0.8) lib/devise/models/database_authenticatable.rb:117:in `authenticate'
devise (1.0.8) lib/devise/strategies/database_authenticatable.rb:16:in `authenticate!'
warden (1.0.3) lib/warden/strategies/base.rb:53:in `_run!'
warden (1.0.3) lib/warden/proxy.rb:303:in `_run_strategies_for'
warden (1.0.3) lib/warden/proxy.rb:298:in `each'
warden (1.0.3) lib/warden/proxy.rb:298:in `_run_strategies_for'
warden (1.0.3) lib/warden/proxy.rb:271:in `_perform_authentication'
warden (1.0.3) lib/warden/proxy.rb:90:in `authenticate'
devise (1.0.8) lib/devise/controllers/helpers.rb:36:in `authenticate'
devise (1.0.8) app/controllers/sessions_controller.rb:19:in `create'
warden (1.0.3) lib/warden/manager.rb:35:in `call'
warden (1.0.3) lib/warden/manager.rb:34:in `catch'
warden (1.0.3) lib/warden/manager.rb:34:in `call'
Anything to do with warden dependency?
I had the same problem, using warden 0.10.7 and devise 1.0.8
I tried the User.find in the console and was OK.
To fix it, I removed the class method authenticate on my User-Model:
#def self.authenticate(login, pass)
# find(:first, :conditions => ["login = ? AND password = ?", login, sha1(pass)])
#end
The error seems to be occuring in a User.find call, which is strange. Do you have anything that might be overriding the default find method?
Try this in the console and see if you get an error.
User.find(:first, :conditions=>{:email=>'email#email.com'})

Rails: Absolutely stumped with delayed_job. Not receiving arguments anywhere

I'm trying to send mail in a Rails 3 application using collectiveidea's delayed_job. If I try to send mail regularly (.deliver) it works fine, but as soon as I switch to delayed job, things fall to pieces.
The standard error I get in the delayed_job mysql table is:
{undefined method `name' for
nil:NilClass...
where 'name' is the first argument in the mailer's view (#contact.name). This works fine if I take delayed_job out again.
If I remove all references to #contact in the view, I get
{A sender (Return-Path, Sender or
From) required to send a message
In short, it doesn't seem to be understanding any arguments at all.
All relevant code below - if anyone has any suggestions for this it would be very appreciated
CONTROLLER
def sendmail
#contact = Contact.new(params[:contact])
if #contact.save
ContactMailer.delay.contact_mail(#contact)
flash[:notice] = 'Your message has been successfully sent'
redirect_to root_path
else
render :action => 'index'
end
end
MAILER:
class ContactMailer < ActionMailer::Base
default :from => "my#email.address"
def contact_mail(contact)
#contact = contact
mail(:to => 'my#email.address', :subject => 'Contact Form Query', :from => 'my#email.address', :content_type => 'text/plain')
end
handle_asynchronously :contact_mail, :run_at => Proc.new { 2.seconds.from_now }
end
MAILER VIEW:
You have received a new query:
-----------------------------------
<%= #contact.name %>
<%= #contact.business %>
<%= #contact.phone %>
-----------------------
<%= #contact.message %>
-----------------------
INITIALIZER:
Delayed::Worker.destroy_failed_jobs = false
Delayed::Worker.max_run_time = 5.weeks
And finally, the full error message:
{undefined method `name' for nil:NilClass
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/whiny_nil.rb:48:in `method_missing'
/Users/john/Websites/Rails/InDevelopment/connectted/app/views/contact_mailer/contact_mail.html.erb:4:in `_app_views_contact_mailer_contact_mail_html_erb___3386534441642202773_2166008980__4301703149293725172'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:135:in `block in render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:54:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/template.rb:127:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:59:in `block in _render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `block in instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications/instrumenter.rb:21:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/notifications.rb:52:in `instrument'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:56:in `_render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/action_view/render/rendering.rb:26:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:114:in `_render_template'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:108:in `render_to_body'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:101:in `render_to_string'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionpack-3.0.0/lib/abstract_controller/rendering.rb:92:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:111:in `render'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:210:in `block in create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `each'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:208:in `create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/deprecated_api.rb:143:in `create_parts'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/old_api.rb:77:in `process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:446:in `process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:441:in `initialize'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `new'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/actionmailer-3.0.0/lib/action_mailer/base.rb:425:in `method_missing'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/performable_mailer.rb:6:in `perform'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/backend/base.rb:83:in `invoke_job'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:119:in `block (2 levels) in run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/timeout.rb:57:in `timeout'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed
/worker.rb:119:in `block in run'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:118:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:176:in `reserve_and_run_one_job'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:103:in `block in work_off'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `times'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:102:in `work_off'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:77:in `block (2 levels) in start'
/Users/john/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:76:in `block in start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `loop'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/worker.rb:73:in `start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:100:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:79:in `block in run_process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:250:in `block in start_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/daemonize.rb:199:in `call_as_daemon'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:254:in `start_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/application.rb:294:in `start'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/controller.rb:70:in `run'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:193:in `block in run_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `call'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons/cmdline.rb:112:in `catch_exceptions'
/Users/john/.rvm/gems/ruby-1.9.2-p0/gems/daemons-1.1.0/lib/daemons.rb:192:in `run_proc'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:78:in `run_process'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:72:in `block in daemonize'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `times'
/Users/john/.rvm/gems/ruby-1.9.2-p0/bundler/gems/delayed_job-c933ffcd776a/lib/delayed/command.rb:70:in `daemonize'
script/delayed_job:5:in `<main>' |
The issue is with the code in your mailer taking the object instead of the objects id:
def contact_mail(contact)
#contact = contact
mail(:to => 'my#email.address', :subject => 'Contact Form Query', :from => 'my#email.address', :content_type => 'text/plain')
end
You should change that to this:
def contact_mail(contact_id)
#contact = Contact.find(contact_id)
mail(:to => 'my#email.address', :subject => 'Contact Form Query', :from => 'my#email.address', :content_type => 'text/plain')
end
Never pass the actual objects to your mailer. Simply pass the id's and retrieve them upon processing.
I had this same problem, and fixed it by moving all the attributes into instance variables. So, in the view:
<%= #contact.name %>
<%= #contact.business %>
<%= #contact.phone %>
becomes:
<%= #name %>
<%= #business %>
<%= #phone %>
and I just looked up the instance variables in the mailer method. So, in the mailer:
def contact_mail(contact)
#contact = contact
mail(:to => 'my#email.address', :subject => 'Contact Form Query', :from => 'my#email.address', :content_type => 'text/plain')
end
becomes:
def contact_mail(contact)
#name = contact.name
#business = contact.business
#phone = contact.phone
mail(:to => 'my#email.address', :subject => 'Contact Form Query', :from => 'my#email.address', :content_type => 'text/plain')
end
Why is it not working? Not sure, I imagine it has to do with some ActionMailer voodoo.
How to get it working? Abstract out the delayed job pieces into another class. Have the method that is delayed do nothing more than send them email; meaning that the rendering of the email is done in real time, but the sending of it is delayed. This should get around your problem and accomplish the asynchronous sending of emails.
Hey this might be far off, but you're not sending any params to your MAILER. Here's a copy of my referred_email.rb I keep in my lib/ dir. I call it with delayed_job:
#my controller
Delayed::Job.enqueue ReferredEmail.new(params[:subject], params[:editor1])
#Reffered_Email.rb
class ReferredEmail < Struct.new(:subject, :editor1)
def perform
(CardReferral.all.map(&:email) - CardSignup.all.map(&:email)).each do |cf|
#cf = CardReferral.find_by_email(cf)
Notifier.deliver_referred_magic_email(User.find(#cf.user_id), #cf.email, #cf.name, #cf.message, subject, editor1)
end
end
end
It seems like you are using both:
ContactMailer.delay.contact_mail(#contact)
and
handle_asynchronously :contact_mail, :run_at => Proc.new { 2.seconds.from_now }
which you should only do one or the other. Try removing the handle_asynchronously and see if that fixes the problem.

XML Builder in Rails: 'wrong number of arguments' bug that I just can't trace

New to rails, and I've just spent hours trying to hunt down a bug. Any help very appreciated.
I'm trying to make a rails page so that if a user enters /info/who_bought/1 the page outputs HTML, and if they enter /info/who_bought/1.xml, the page returns an XML file. (In short, I'm doing chapter 11 from the 'Agile Web Development with Rails' book)
The HTML-formatted output works fine, but if I enter the xml I consistently get a 'wrong number of arguments (1 for 0)' error page. Downloaded the actual ebook and did a direct copy/paste of all code; still facing the same problem. Google doesn't bring up any mention of code bugs.
Code & full stack trace below. If anyone has any ideas I'd be very appreciative. In short - what could possible cause xml.builder to return a '1 for 0 arguments' bug?
Many thanks,
Baggage
# app/controllers/info_controller.rb
class InfoController < ApplicationController
def who_bought
#product = Product.find(params[:id])
#orders = #product.orders
respond_to do |format|
format.html
format.xml {render :layout => false }
end
end
protected
def authorize
end
end
# app/views/info/who_bought.xml.builder
xml.order_list(:for_product => #product.title) do
for o in #orders
xml.order do
xml.name(o.name)
xml.email(o.email)
end
end
end
# app/models/product.rb
class Product < ActiveRecord::Base
has_many :orders, :through => :line_items
has_many :line_items
validates_presence_of :title, :description, :image_url
validates_numericality_of :price
validates_uniqueness_of :title
validates_length_of :title,
:minimum => 10
validates_format_of :image_url,
:with => %r{\.(gif|jpg|png)$}i,
:message => 'must be a URL for GIF, JPG ' +
'or PNG image.'
validate :price_must_be_at_least_a_cent
def price_must_be_at_least_a_cent
errors.add(:price, 'should be at least 0.01') if price.nil? || price < 0.01
end
def self.find_products_for_sale
find(:all, :order => "title")
end
end
# config/routes.rb
ActionController::Routing::Routes.draw do |map|
map.resources :users
map.resources :line_items
map.resources :orders
map.resources :products
map.connect ':controller/:action'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'
end
# Full trace
/usr/lib/ruby/1.8/builder/xmlbase.rb:134:in `to_xs'
/usr/lib/ruby/1.8/builder/xmlbase.rb:134:in `_escape'
/usr/lib/ruby/1.8/builder/xmlbase.rb:87:in `text!'
/usr/lib/ruby/1.8/builder/xmlbase.rb:144:in `_newline'
/usr/lib/ruby/1.8/builder/xmlbase.rb:60:in `method_missing'
app/views/info/who_bought.xml.builder:2
vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:359:in `method_missing'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:212:in `method_missing'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:212:in `each'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:212:in `send'
vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:212:in `method_missing'
vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:359:in `method_missing'
app/views/info/who_bought.xml.builder:1
vendor/rails/actionpack/lib/action_view/renderable.rb:39:in `send'
vendor/rails/actionpack/lib/action_view/renderable.rb:39:in `render'
vendor/rails/actionpack/lib/action_view/template.rb:73:in `render_template'
vendor/rails/actionpack/lib/action_view/base.rb:256:in `render'
vendor/rails/actionpack/lib/action_controller/base.rb:1177:in `render_for_file'
vendor/rails/actionpack/lib/action_controller/base.rb:940:in `render_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render'
app/controllers/info_controller.rb:6
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:135:in `call'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:135
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:164:in `call'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:164:in `respond'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:158:in `each'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:158:in `respond'
vendor/rails/actionpack/lib/action_controller/mime_responds.rb:107:in `respond_to'
app/controllers/info_controller.rb:5:in `who_bought'
vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `perform_action_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in `perform_action_without_caching'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:34:in `cache'
vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'
vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action'
vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process'
vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:184:in `handle_request'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:112:in `dispatch_unlocked'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:125:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:in `synchronize'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:in `dispatch'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:134:in `dispatch_cgi'
vendor/rails/actionpack/lib/action_controller/dispatcher.rb:41:in `dispatch'
/usr/lib/ruby/1.8/mongrel/rails.rb:76:in `process'
/usr/lib/ruby/1.8/mongrel/rails.rb:74:in `synchronize'
/usr/lib/ruby/1.8/mongrel/rails.rb:74:in `process'
/usr/lib/ruby/1.8/mongrel.rb:159:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:158:in `each'
/usr/lib/ruby/1.8/mongrel.rb:158:in `process_client'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:285:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:285:in `new'
/usr/lib/ruby/1.8/mongrel.rb:285:in `run'
/usr/lib/ruby/1.8/mongrel.rb:268:in `initialize'
/usr/lib/ruby/1.8/mongrel.rb:268:in `new'
/usr/lib/ruby/1.8/mongrel.rb:268:in `run'
/usr/lib/ruby/1.8/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/1.8/mongrel/configurator.rb:281:in `run'
/usr/bin/mongrel_rails:129:in `run'
/usr/lib/ruby/1.8/mongrel/command.rb:212:in `run'
/usr/bin/mongrel_rails:282
This is a conflict between Rails 3.1, Builder 3.0, and either the fast_xs gem or hpricot (which bundles fast_xs). The reason why some people can't reproduce it is that they don't have fast_xs or hpricot in their Gemfile.
Unfortunately, since it's a three-way conflict, everybody thinks it's the other library's fault:
Builder bug report
Rails pull request
fast_xs bug report
In the meantime, pile another monkey patch on the heap and add config/initializers/unbreak_string_to_xs.rb with the following:
class String
def fast_xs_absorb_args(*args); fast_xs; end
alias_method :to_xs, :fast_xs_absorb_args
end
(From this answer to a duplicate.)
Try (re)installing the 'builder' gem, that fixed the '1 for 0 arguments' bug for me :)
sudo gem install builder
Don't forget to restart your server afterwards
I would kind of like to blame the "for o in #orders" part. Perhaps trying with a traditional way would help to eliminate this suspicion:
#orders.each do |o|
...
end

Resources