ArgumentError in ImagesController#index but appliaction trace is empty - ruby-on-rails-3

I am calling the index action for a class which gives the following error:
Started GET "/images" for 127.0.0.1 at Sun Aug 28 06:14:41 +0200 2011
Processing by ImagesController#index as HTML Completed 500 Internal
Server Error in 1ms
ArgumentError (wrong number of arguments (2 for 0)):
There is nothing in the application trace, meaning that the failure occurs before any of the files that I created for app get processed. The full trace is here:
activesupport (3.0.8) lib/active_support/callbacks.rb:97:in `send'
activesupport (3.0.8) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (3.0.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.8) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.8) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.8) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.8) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:82:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:493:in `call'
sass (3.1.7) lib/sass/./sass/plugin/rack.rb:54:in `call'
warden (1.0.5) lib/warden/manager.rb:35:in `call'
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
warden (1.0.5) lib/warden/manager.rb:34:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.8) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.8) lib/active_support/callbacks.rb:419:in `_run_call_callbacks'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.8) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.8) lib/rails/application.rb:168:in `call'
railties (3.0.8) lib/rails/application.rb:77:in `send'
railties (3.0.8) lib/rails/application.rb:77:in `method_missing'
railties (3.0.8) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.2.3) lib/rack/handler/webrick.rb:13:in `run'
rack (1.2.3) lib/rack/server.rb:217:in `start'
railties (3.0.8) lib/rails/commands/server.rb:65:in `start'
railties (3.0.8) lib/rails/commands.rb:30
railties (3.0.8) lib/rails/commands.rb:27:in `tap'
railties (3.0.8) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
Here is the relevant code from lib/active_support/callbacks.rb, which I modified to print out the method arguments
def run_callbacks(kind, *args, &block)
p *args
p &block
p kind
send("_run_#{kind}_callbacks", *args, &block)
end
Here is the output with the above code:
"callback arguments"
:checkout
"callback arguments"
"index"
:process_action
Started GET "/images" for 127.0.0.1 at Sun Aug 28 06:40:37 +0200 2011
Processing by ImagesController#index as HTML Completed 500 Internal
Server Error in 1ms
ArgumentError (wrong number of arguments (2 for 0)):
Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb
(1.5ms) Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
(8.6ms) Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
within rescues/layout (20.9ms)
Here is the DB schema:
create_table "images", :force => true do |t|
t.string "photo"
t.integer "w"
t.integer "h"
t.integer "eyes"
t.integer "head_top"
t.integer "head_bottom"
t.integer "user_id"
t.string "face_params", :limit => 2000
t.string "smiling"
t.string "facing"
t.string "filename"
t.string "content_type"
t.binary "data", :limit => 16777215
t.datetime "created_at"
t.datetime "updated_at"
end
Here is the relevant controller code:
def index
p "made it to index action--------------------------"
if user_signed_in?
#user = current_user
#selected_image = #user.get_selected_image
#problems = #selected_image ? #selected_image.problems.all : Array.new
#images = #user.images - Array[#selected_image]
#image = #user.image_build
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => #images }
end
else
redirect_to root_path
end
end
All the other controllers seem to work. Other actions for this controller give the same error.
Any ideas?
EDIT: Added Routes.rb as per comment below
Id::Application.routes.draw do
resources :payment_notifications
resources :addresses
resources :orders do
member do
get "select_address_for"
put "set_address_for"
get "complete"
end
end
resources :prints do
member do
post "email"
get "confirm_email"
end
end
resources :images do
member do
put "select"
get "thumb"
get "send"
end
end
resources :docs do
member do
get "image_for"
end
end
devise_for :users
##This will redirect the user after sign-in or sign-up.
##Otherwise is will default to the 'root' route, defined below
#devise_for :users do
# get 'users', :to => 'docs#index', :as => :user_root # Rails 3
#end
resources :admins
resources :assistants
resources :books
resources :links
resources :categories
resources :tips
resources :rules
resources :countries
resources :types
resources :continents
# match ':controller(/:action(/:id(.:format)))'
# match ':controller/:action/:id'
# match ':controller/:action/:id.:format'
# match ':controller/:action.:format'
end

You're redefining the send method in your images controller, which is a base ruby method. Rename it to something else and your problem should disappear.

Related

NoMethodError (undefined method `empty?' for #<Event:0x6042e88>):

I created a rails API using postgre database in which i have a model (table) name as counseling_event
NOTE: Not using scaffold and using rails-5
My scheman(migration) for counseling_event is as follow:
class CreateCounselingEvent < ActiveRecord::Migration[5.0]
def change
create_table :counseling_event do |t|
t.text :name
t.datetime :start_time
t.datetime :end_time
t.text :location
t.integer :user_id
t.integer :role_id
t.timestamps
end
end
end
I added a column to the above table, which is of type enum. column name is event_type
Now, In my Controller i.e CounselingEventController, in my action index i'm retrieving the data from the counseling_event table. the code is as follows.
def index
#counseling_event = CounselingEvent.where(start_time: "2016-10-30".."2016-12-11")
render body: #counseling_event
end
when i call this api controller action from frontend through following route
get 'counseling_event/index'
I'm getting this error in my console:
CounselingEvent Load (1.5ms) SELECT "counseling_event".* FROM "counseling_event"
NoMethodError (undefined method `empty?' for #<CounselingEvent:0x47d1d58>):
activemodel (5.0.0.1) lib/active_model/attribute_methods.rb:433:in `method_missing'
rack (2.0.1) lib/rack/etag.rb:68:in `block in digest_body'
activerecord (5.0.0.1) lib/active_record/relation/delegation.rb:38:in `each'
activerecord (5.0.0.1) lib/active_record/relation/delegation.rb:38:in `each'
actionpack (5.0.0.1) lib/action_dispatch/http/response.rb:145:in `each_chunk'
actionpack (5.0.0.1) lib/action_dispatch/http/response.rb:126:in `each'
actionpack (5.0.0.1) lib/action_dispatch/http/response.rb:74:in `each'
actionpack (5.0.0.1) lib/action_dispatch/http/response.rb:464:in `each'
rack (2.0.1) lib/rack/etag.rb:66:in `digest_body'
rack (2.0.1) lib/rack/etag.rb:29:in `call'
rack (2.0.1) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.1) lib/rack/head.rb:12:in `call'
activerecord (5.0.0.1) lib/active_record/migration.rb:552:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `call'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
I don't know the reason for the error but, trying hard to resolve it. can any one help me out to solve this error. it seems like some activemodel error. Thanks in advance.
Rails is based on Rack. Rack can only handle strings. You're rendering an object, not a string.
You probably want something like:
render plain: #counceling_event.to_s
It basically happens because Rack attempts to call #empty? on the body of the response to determine how it should respond to the client.
But since your #counceling_event isn't a string and doesn't respond to empty? it fails.
I'm unsure what you're trying to do by render body: <SOMETHING>. If you're on a Rails app you probably want to render a view instead of content directly from the controller.
If you really want to render from the controller you should consider using render plain: <SOMETHING>.
Hope this helps.

NameError in RegistrationsController#create using devise login

I have a project in which I am using omniauth for Facebook, Twitter, and LinkedIn. It is also using the Devise login gem. When a user goes to the sign-up page to create a login and inputs the e-mail and selects a password, the error page NameError in RegistrationsController#create shows up.
This appears in the terminal:
Started POST "/users" for 127.0.0.1 at 2014-07-25 14:42:30 -0400
Processing by RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"MMYGtL6b6AyEuWIWwpxMg7qn8TWGXinMZTQ2K0GDsyU=", "user"=>{"email"=>"Phil9767#yahoo.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
(0.1ms) begin transaction
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'phil9767#yahoo.com' LIMIT 1
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 91ms
NameError (undefined local variable or method `confirmed_at' for #<User:0x00000106162ef0>):
activemodel (4.1.1) lib/active_model/attribute_methods.rb:435:in `method_missing'
activerecord (4.1.1) lib/active_record/attribute_methods.rb:206:in `method_missing'
devise (3.2.4) lib/devise/models/confirmable.rb:88:in `confirmed?'
devise (3.2.4) lib/devise/models/confirmable.rb:163:in `confirmation_required?'
activesupport (4.1.1) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `block (2 levels) in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `each'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `all?'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.1) lib/active_record/callbacks.rb:306:in `create_record'
activerecord (4.1.1) lib/active_record/timestamp.rb:57:in `create_record'
activerecord (4.1.1) lib/active_record/persistence.rb:482:in `create_or_update'
activerecord (4.1.1) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.1) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.1.1) lib/active_record/persistence.rb:103:in `save'
activerecord (4.1.1) lib/active_record/validations.rb:51:in `save'
activerecord (4.1.1) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.1.1) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
activerecord (4.1.1) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
activerecord (4.1.1) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.1) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.1) lib/active_record/transactions.rb:268:in `block in save'
activerecord (4.1.1) lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
activerecord (4.1.1) lib/active_record/transactions.rb:267:in `save'
devise (3.2.4) app/controllers/devise/registrations_controller.rb:15:in `create'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/builder.rb:59:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.8ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.2ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (10.6ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (28.6ms)
I have done many searches on stackoverflow, and it doesn't appear to be whether authentications is pluralized in the associations, nor does it seem to be related to skipping the authentication in devise. I created a registrations controller, but it didn't seem to help. Any ideas on what the issue could be?
Here is my user model
class User < ActiveRecord::Base
has_many :authentications
TEMP_EMAIL_PREFIX = 'change#me'
TEMP_EMAIL_REGEX = /\Achange#me/
# Include default devise modules. Others available are:
# :lockable, :timeoutable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update
def self.find_for_oauth(auth, signed_in_resource = nil)
# Get the identity and user if they exist
identity = Identity.find_for_oauth(auth)
# If a signed_in_resource is provided it always overrides the existing user
# to prevent the identity being locked with accidentally created accounts.
# Note that this may leave zombie accounts (with no associated identity) which
# can be cleaned up at a later date.
user = signed_in_resource ? signed_in_resource : identity.user
# Create the user if needed
if user.nil?
# Get the existing user by email if the provider gives us a verified email.
# If no verified email was provided we assign a temporary email and ask the
# user to verify it on the next step via UsersController.finish_signup
email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
email = auth.info.email if email_is_verified
user = User.where(:email => email).first if email
# Create the user if it's a new registration
if user.nil?
user = User.new(
name: auth.extra.raw_info.name,
#username: auth.info.nickname || auth.uid,
email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
password: Devise.friendly_token[0,20]
)
user.skip_confirmation!
user.save!
end
end
# Associate the identity with the user if needed
if identity.user != user
identity.user = user
identity.save!
end
user
end
def email_verified?
self.email && self.email !~ TEMP_EMAIL_REGEX
end
end
This is my schema.rb
ActiveRecord::Schema.define(version: 20140724042203) do
create_table "identities", force: true do |t|
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "identities", ["user_id"], name: "index_identities_on_user_id"
create_table "users", force: true do |t|
t.string "provider"
t.string "uid"
t.string "name"
t.string "oauth_token"
t.datetime "oauth_expires_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Your model Users is missing the "confirmed_at" attribute.
you can create it with a new migration:
rails g migration add_unconfirmed_to_devise
and put in:
class AddUnconfirmedToDevise < ActiveRecord::Migration
def change
change_table(:users) do |t|
#t.string :confirmation_token
#t.datetime :confirmed_at
#t.datetime :confirmation_sent_at
#t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
#t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
#t.string :unlock_token # Only if unlock strategy is :email or :both
#t.datetime :locked_at
end
end
end
Just uncomment each attribute you need.

undefined method `model_name' for NilClass:Class

I am having trouble with adding comments to posts in a simple blog. Using Haml, Rails 3, ActiveAdmin, and Spree.
NoMethodError in Posts#show
Showing /app/views/posts/show.html.haml where line #25 raised:
undefined method `model_name' for NilClass:Class
Extracted source (around line #25):
22: .comments
23: %h3 Leave a Reply
24: / = #comment.inspect
25: = form_for #comments do |f|
26: .row-fluid
27: = f.hidden_field :post_id
28: .row-fluid
Application Trace | Framework Trace | Full Trace
activemodel (3.2.13) lib/active_model/naming.rb:163:in `model_name_from_record_or_class'
activemodel (3.2.13) lib/active_model/naming.rb:158:in `param_key'
actionpack (3.2.13) lib/action_view/helpers/form_helper.rb:369:in `form_for'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:146:in `form_for_with_haml'
haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
app/views/posts/show.html.haml:25:in `block in _1d7665fe0e4edacd3f10a86fba89b0fb'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `block in capture_with_haml'
haml (4.0.3) lib/haml/helpers.rb:368:in `call'
haml (4.0.3) lib/haml/helpers.rb:368:in `block in capture_haml'
haml (4.0.3) lib/haml/helpers.rb:617:in `with_haml_buffer'
haml (4.0.3) lib/haml/helpers.rb:364:in `capture_haml'
haml (4.0.3) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:138:in `content_for'
app/views/posts/show.html.haml:1:in `_1d7665fe0e4edacd3f10a86fba89b0fb'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
deface (0.9.1) lib/deface/action_view_extensions.rb:37:in `render'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/miriam.williams/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__1713495783671643053__process_action__2295715638951091725__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__2801646708740260414__call__1745177411958485085__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
Request
Parameters:
{"title"=>"TEST 2 Post"}
app/controllers/posts_controller.rb
class PostsController < ApplicationController
def index
if params[:search]
#posts = Post.find(
:all,
:conditions => ['text LIKE ? or title LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"], :order => "created_at DESC")
else
#posts = Post.find(:all, :order => "created_at DESC")
end
#posts_by_month = #posts.group_by { |post| post.created_at.strftime("%B %Y") }
#recent_posts = Post.order('created_at DESC').limit(5)
if params[:date]
date = Time.parse(params[:date])
date1 = date.beginning_of_month
date2 = date.end_of_month
range = date1
#posts = Post.find(
:all, :order => "created_at DESC",
:conditions => ["created_at <= ? AND created_at >= ?", date2, date1])
end
end
def show
Rails.logger.debug("My object: #{#comment.inspect}")
title = params[:title]
#post = Post.where('title' => title).first
#comment = Comment.new( :post => #post )
end
End
app/models/post.rb
class Post < ActiveRecord::Base
attr_accessible :image, :text, :title, :image_file_name
has_attached_file :image, :styles => { :thumb => "150x150>", :full => "315x250>" }
has_many :comments, :dependent => :destroy
end
app/controller/comments_controller.rb
class CommentsController < ApplicationController
def create
#comment = Comment.new(params[:comment])
if #comment.save
flash[:notice] = 'Comment was successfully created.'
redirect_to(#comment.post)
else
flash[:notice] = "Error creating comment: #{#comment.errors}"
redirect_to(#comment.post)
end
end
def new
#post = Post.find(params[:post_id])
end
End
app/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
attr_accessible :comment, :email, :name, :website
validates :name,:email, :comment, :presence => true
validates :name, length: 2..20
End
routes.rb
devise_for :admin_users, ActiveAdmin::Devise.config
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
mount Spree::Core::Engine, :at => '/products'
root :to => 'pages#index'
get "history" => 'pages#history', :as => :history
get 'about' => 'pages#about', :as => :about
get 'pajama' => 'pages#pajama', :as => :pajama
get 'comfort' => 'pages#comfort', :as => :comfort
get 'contact' => 'pages#contact', :as => :contact
get 'cookbook' => 'pages#cookbook', :as => :cookbook
get 'charity' => 'pages#charity', :as => :charity
get 'retailers' => 'pages#retailers', :as => :retailers
get 'media' => 'pages#media', :as => :media
get 'official-rules' => 'pages#official_rules', :as => :official_rules
get 'terms-privacy' => 'pages#terms_privacy', :as => :terms_privacy
get "posts/archives" => 'posts#show', :as => :archives
match "posts/archives/:year/:month" => "posts#archives", :constraints => { :year => /\d{4}/, :month => /\d{2}/}
post 'messages' => 'messages#create', :as => :messages
resources :posts do
resources :comments
end
ActiveAdmin.routes(self)
End
App/views/show.html.haml
.row-fluid
.comments
%h3 Leave a Reply
/ = #comment.inspect
= form_for #comment do |f|
.row-fluid
= f.hidden_field :post
.row-fluid
= label_tag(:name, "Name", :id => 'name-label')
= f.text_field :name
.row-fluid
= label_tag(:email, "Email", :id => 'email-label')
= f.text_field :email
.row-fluid
= label_tag(:website, "Website", :id => 'website-label')
= f.text_field :website
.row-fluid
= label_tag(:comment, "Comment", :id => 'comment-label')
= f.text_area :comment
.row-fluid.submit
= f.submit("Post Comment", :id => "submit")
You're calling form_for with #comments
22: .comments
23: %h3 Leave a Reply
24: / = #comment.inspect
25: = form_for #comments do |f|
26: .row-fluid
27: = f.hidden_field :post_id
28: .row-fluid
, you have not instantiated it in the controller action
def show
Rails.logger.debug("My object: #{#comment.inspect}")
title = params[:title]
#post = Post.where('title' => title).first
#comment = Comment.new( :post => #post ) end

Fog S3 Upload leads to

I am developing a platform that allows merchants to upload a picture of their store. I am using Carrierwave+fog for this. As the app is hosted on heroku, the pictures will need to be stored on amazon s3.
On my local machine, everything works fine if the storage is local, but things go wrong once fog handles the uploading.
I will first post the local storage version (works fine), then my current fog-enabled s3 version together with the error that I am getting.
Local storage version (works fine):
# app/uploaders/picture_uploader.rb
class PictureUploader < CarrierWave::Uploader::Base
storage :file
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
Fog-enabled s3 version (doesn't work):
# app/uploaders/picture_uploader.rb
class PictureUploader < CarrierWave::Uploader::Base
storage :fog
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
end
# config/initializers/fog.rb
CarrierWave.configure do |config|
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => 'xxxx', # required
:aws_secret_access_key => 'xxxx' # required
}
config.fog_directory = 'yyyy' # required
config.fog_public = true # optional, defaults to true
end
When I now create or edit a new store, the picture is actually successfully uploaded to s3, but rails gives an Permission denied error message (app/tmp/carrierwave/20121104-0929-5512-8270/04.png could not be accessed).
Full Error Message:
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:1406:in `unlink'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:1406:in `block in remove_file'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:1414:in `platform_support'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:1405:in `remove_file'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:785:in `remove_file'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:563:in `block in rm'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:562:in `each'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/fileutils.rb:562:in `rm'
carrierwave (0.5.8) lib/carrierwave/sanitized_file.rb:217:in `delete'
carrierwave (0.5.8) lib/carrierwave/uploader/store.rb:60:in `block in store!'
carrierwave (0.5.8) lib/carrierwave/uploader/callbacks.rb:17:in `with_callbacks'
carrierwave (0.5.8) lib/carrierwave/uploader/store.rb:58:in `store!'
carrierwave (0.5.8) lib/carrierwave/mount.rb:347:in `store!'
carrierwave (0.5.8) lib/carrierwave/mount.rb:217:in `store_bild!'
activesupport (3.1.0) lib/active_support/callbacks.rb:401:in `_run_save_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.1.0) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.1.0) lib/active_record/persistence.rb:37:in `save'
activerecord (3.1.0) lib/active_record/validations.rb:50:in `save'
activerecord (3.1.0) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (3.1.0) lib/active_record/transactions.rb:241:in `block (2 levels) in save'
activerecord (3.1.0) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.1.0) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.1.0) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.1.0) lib/active_record/transactions.rb:241:in `block in save'
activerecord (3.1.0) lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
activerecord (3.1.0) lib/active_record/transactions.rb:240:in `save'
activerecord (3.1.0) lib/active_record/persistence.rb:163:in `block in update_attributes'
activerecord (3.1.0) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.1.0) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.1.0) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.1.0) lib/active_record/persistence.rb:161:in `update_attributes'
app/controllers/stores_controller.rb:62:in `block in update'
actionpack (3.1.0) lib/action_controller/metal/mime_responds.rb:269:in `call'
actionpack (3.1.0) lib/action_controller/metal/mime_responds.rb:269:in `retrieve_response_from_mimes'
actionpack (3.1.0) lib/action_controller/metal/mime_responds.rb:194:in `respond_to'
app/controllers/stores_controller.rb:61:in `update'
actionpack (3.1.0) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.0) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.0) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.0) lib/active_support/callbacks.rb:416:in `_run__16358980__process_action__192134115__callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.0) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.0) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.0) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.0) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.0) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.0) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.0) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.0) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.0) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:75:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:531:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.6) lib/rack/etag.rb:23:in `call'
rack (1.3.6) lib/rack/conditionalget.rb:35:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.6) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.6) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/cookies.rb:326:in `call'
activerecord (3.1.0) lib/active_record/query_cache.rb:62:in `call'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0) lib/rails/engine.rb:455:in `call'
railties (3.1.0) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.6) lib/rack/handler/webrick.rb:59:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
This error confuses me, as typing in app/tmp/carrierwave/20121104-0929-5512-8270/04.png directly into the browser works fine.
For completeness sake, here is the controller & model (same in both versions)
#stores_controller.rb
def create
#store = Store.new(params[:store])
respond_to do |format|
if #store.save
format.html { redirect_to #store, notice: 'Store was successfully created.' }
format.json { render json: #store, status: :created, location: #store }
else
format.html { render action: "new" }
format.json { render json: #store.errors, status: :unprocessable_entity }
end
end
end
#models/store.rb
class Store < ActiveRecord::Base
mount_uploader :bild, PictureUploader
end
Try adding cache_dir to your uploader:
def cache_dir
"#{Rails.root}/tmp/uploads"
end
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
Also, you might have to add config/initializers/carrierwave.rb:
CarrierWave.configure do |config|
# hack fix for windows machine due to tmp file permission error
# per https://github.com/jnicklas/carrierwave/issues/220/
if ENV['RAILS_ENV'] != 'production'
config.delete_tmp_file_after_storage = false
end
config.fog_credentials = {
:provider => 'AWS', # required
:aws_access_key_id => ENV['MF_S3_KEY'], # required
:aws_secret_access_key => ENV['MF_S3_SECRET'], # required
:region => 'us-east-1' # optional, defaults to 'us-east-1'
}
config.fog_directory = ENV['MF_FLYER_BUCKET'] # required
#config.fog_host = 'https://assets.example.com' # optional, defaults to nil
#config.fog_public = false # optional, defaults to true
#config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {}

Rails 3 form_for Argument Error (1 for 0) but it *must* have at least one argument, no?

I just can't seem to figure this one out...
As far as I know, you have to provide an instance variable to the form_for view helper, but it raises an error when I do that...
For a simple scaffold form_for I get an argument error wrong number of arguments (1 for 0) when supplying the instance of the model on a new action.
The relevan code:
Controller
class AdminMessagesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
def new
#admin_message = AdminMessage.new
logger.debug instance_variables
respond_to do |format|
format.html # new.html.erb
format.json { render json: #admin_message }
end
end
Controller instance_variables
[:#_routes, :#_action_has_layout, :#_view_context_class, :#_headers, :#_status, :#_request, :#_response, :#_env, :#_prefixes, :#_lookup_context, :#_action_name, :#_response_body, :#_config, :#_params, :#current_user, :#current_ability, :#admin_message, :#_authorized]
Model
class AdminMessage < ActiveRecord::Base
validates_presence_of :subject, :body
end
Roles (CanCan)
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
elsif user
can :manage, [Profile, BackgroundImage], :user_id => user.id
can :manage, Page, :profile => { :user_id => user.id }
can :read, [Profile]
else
can :read, [Profile]
end
New View
- #title = "New Message"
= link_to 'Back', admin_messages_path, class: 'button'
%hr
%h1= #title
= render 'form'
Form View
= form_for #admin_message do |f|
-if #admin_message.errors.any?
#error_explanation
%h2= "#{pluralize(#admin_message.errors.count, "error")} prohibited this admin_message from being saved:"
%ul
- #admin_message.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :subject
= f.text_field :subject
.field
= f.label :body
= f.text_area :body
.field
= f.label :send
= f.check_box :send
.actions
= f.submit 'Save'
Routes
resources :admin_messages
Stack Trace
ArgumentError in Admin_messages#new
Showing /example/app/views/admin_messages/_form.html.haml where line #4 raised:
wrong number of arguments (1 for 0)
Extracted source (around line #4):
1: -# - puts self.public_methods
2: -# - puts self.instance_variables
3:
4: = form_for #admin_message do |f|
5: -if #admin_message.errors.any?
6: #error_explanation
7: %h2= "#{pluralize(#admin_message.errors.count, "error")} prohibited this admin_message from being saved:"
Full Stack Trace
activerecord (3.1.2) lib/active_record/attribute_methods/read.rb:89:in `_send'
activerecord (3.1.2) lib/active_record/attribute_methods/primary_key.rb:8:in `to_key'
actionpack (3.1.2) lib/action_controller/record_identifier.rb:76:in `record_key_for_dom_id'
actionpack (3.1.2) lib/action_controller/record_identifier.rb:57:in `dom_id'
actionpack (3.1.2) lib/action_view/helpers/form_helper.rb:388:in `apply_form_for_options!'
actionpack (3.1.2) lib/action_view/helpers/form_helper.rb:365:in `form_for'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:182:in `form_for_with_haml'
haml (3.1.3) lib/haml/helpers/xss_mods.rb:132:in `form_for_with_haml_xss'
app/views/admin_messages/_form.html.haml:4:in `_app_views_admin_messages__form_html_haml__1654301332507974170_70145208768920'
actionpack (3.1.2) lib/action_view/template.rb:171:in `block in render'
activesupport (3.1.2) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.2) lib/action_view/template.rb:169:in `render'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:256:in `render_partial'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:228:in `block (2 levels) in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:227:in `block in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:219:in `render'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.1.2) lib/action_view/helpers/rendering_helper.rb:27:in `render'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:11:in `block in render_with_haml'
haml (3.1.3) lib/haml/helpers.rb:90:in `non_haml'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:11:in `render_with_haml'
app/views/admin_messages/new.html.haml:6:in `_app_views_admin_messages_new_html_haml__1382734216418550338_70145179834340'
actionpack (3.1.2) lib/action_view/template.rb:171:in `block in render'
activesupport (3.1.2) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.2) lib/action_view/template.rb:169:in `render'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:40:in `block (2 levels) in render_template'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:39:in `block in render_template'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:47:in `render_with_layout'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:38:in `render_template'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:12:in `block in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:9:in `render'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:120:in `_render_template'
actionpack (3.1.2) lib/action_controller/metal/streaming.rb:250:in `_render_template'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:114:in `render_to_body'
actionpack (3.1.2) lib/action_controller/metal/renderers.rb:30:in `render_to_body'
actionpack (3.1.2) lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:99:in `render'
actionpack (3.1.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.1.2) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.1.2) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.1.2) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.1.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:268:in `block in retrieve_response_from_mimes'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:195:in `call'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:195:in `respond_to'
app/controllers/admin_messages_controller.rb:33:in `new'
actionpack (3.1.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.2) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.2) lib/active_support/callbacks.rb:434:in `_run__1801240210143518790__process_action__2938188811796736454__callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.2) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.2) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:82:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:532:in `call'
sass (3.1.10) lib/sass/plugin/rack.rb:54:in `call'
warden (1.1.0) lib/warden/manager.rb:35:in `block in call'
warden (1.1.0) lib/warden/manager.rb:34:in `catch'
warden (1.1.0) lib/warden/manager.rb:34:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.5) lib/rack/etag.rb:23:in `call'
rack (1.3.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/cookies.rb:331:in `call'
activerecord (3.1.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.1.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.2) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.2) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.5) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.2) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.5) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.5) lib/rack/lock.rb:15:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.2) lib/rails/engine.rb:456:in `call'
rack (1.3.5) lib/rack/content_length.rb:14:in `call'
railties (3.1.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Update
If I try to inspect the #admin_message var in the controller #new action the error message changes to indicate and error in the controller instead of the view...
ArgumentError in AdminMessagesController#new
wrong number of arguments (1 for 0)
This happens if I add puts #admin_message.inspect to the controller action new
Moral of the story: Don't use send as a table column name!