I am trying to upgrade my application from Rails 2.3.5 to Rails 3.0.3.
Models:
Project.rb
has_many :project_roles, :dependent => :destroy
alias :roles :project_roles
after_create :create_cal_for_project, :make_project_owner
def create_calendar_for_project
self.calendars.create(:name => "default")
end
def make_project_owner
#Make owner of project when created
self.roles.create(:user => User.curr_user, :name => 'O')
end
ProjectRole.rb
belongs_to :project
belongs_to :user
project_roles table columns are user_id, project_id, name
I am getting a hard time with the following error, please suggest.
Thanks.
→ rails c
> Loading development environment (Rails 3.0.3)
ruby-1.9.2-p0> User.curr_user = User.first
=> #<User id: 1, username: "tispratik", login_email: "tispratik#gmail.com", > is_email_verified: nil, crypted_password: "deed6fa27ffefa57e63592a9b59295abf2660447cf281f34857...", password_salt: "YsD2nLte3pZy1FZ78GD", persistence_token: "84e44908be77b2dc1e41f8dfeacf9ef20c30050ff0c53854e0d...", single_access_token: "cp1bqVSheDh7vl9J48V", perishable_token: "6pGPzdw48nJnJAHsIZQW", last_login_ip: nil, last_login_at: nil, created_at: "2010-11-23 06:00:09", updated_at: "2010-11-23 06:00:09">
ruby-1.9.2-p0> p = Project.create(:name => "ad", :description => "add")
NoMethodError: undefined method `name' for nil:NilClass
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/whiny_nil.rb:48:in `method_missing'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:57:in `block in visit_Arel_Nodes_InsertStatement'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:56:in `map'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:56:in `visit_Arel_Nodes_InsertStatement'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:15:in `visit'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/visitor.rb:5:in `accept'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:19:in `block in accept'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/connection_pool.rb:110:in `with_connection'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/visitors/to_sql.rb:17:in `accept'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/tree_manager.rb:19:in `to_sql'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/arel-2.0.4/lib/arel/select_manager.rb:191:in `insert'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/relation.rb:14:in `insert'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/persistence.rb:270:in `create'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/timestamp.rb:47:in `create'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/callbacks.rb:281:in `block in create'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.3/lib/active_support/callbacks.rb:413:in `_run_create_callbacks'
... 30 levels...
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/attribute_methods/dirty.rb:21:in `save'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:in `block (2 levels) in save'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:289:in `block in with_transaction_returning_status'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:204:in `transaction'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:237:in `block in save'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:248:in `rollback_active_record_state!'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/transactions.rb:236:in `save'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/activerecord-3.0.3/lib/active_record/base.rb:498:in `create'
from (irb):2
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:44:in `start'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands/console.rb:8:in `start'
from /home/pratik/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.3/lib/rails/commands.rb:23:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
The problem is in the make_project_owner callback. create_calendar_for_project runs just fine.
I changed make_project_owner to the following still the same problem occurs.
def make_project_owner
#Make owner of project when created
#role.create(:user => User.curr_user, :name => 'O')
ProjectRole.create(:user => User.curr_user, :project => self, :name => "O")
end
I tried downgrading rails:
rails 3.0.2 -> has same problem
rails 3.0.1 -> has different error
undefined method `name' for #<Arel::Value:0x00000005795090>
Application Trace | Framework Trace | Full Trace
arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in `block in create'
arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in `each'
arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in `detect'
arel (1.0.1) lib/arel/engines/sql/engine.rb:26:in `create'
arel (1.0.1) lib/arel/algebra/relations/writes.rb:24:in `call'
arel (1.0.1) lib/arel/session.rb:17:in `create'
arel (1.0.1) lib/arel/algebra/relations/relation.rb:159:in `insert'
activerecord (3.0.1) lib/active_record/relation.rb:14:in `insert'
activerecord (3.0.1) lib/active_record/persistence.rb:271:in `create'
activerecord (3.0.1) lib/active_record/timestamp.rb:47:in `create'
activerecord (3.0.1) lib/active_record/callbacks.rb:281:in `block in create'
activesupport (3.0.1) lib/active_support/callbacks.rb:413:in `_run_create_callbacks'
activerecord (3.0.1) lib/active_record/callbacks.rb:281:in `create'
activerecord (3.0.1) lib/active_record/persistence.rb:247:in `create_or_update'
activerecord (3.0.1) lib/active_record/callbacks.rb:277:in `block in create_or_update'
activesupport (3.0.1) lib/active_support/callbacks.rb:423:in `_run_save_callbacks'
activerecord (3.0.1) lib/active_record/callbacks.rb:277:in `create_or_update'
activerecord (3.0.1) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.1) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.1) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.1) lib/active_record/transactions.rb:237:in `block (2 levels) in save'
activerecord (3.0.1) lib/active_record/transactions.rb:289:in `block in with_transaction_returning_status'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.1) lib/active_record/transactions.rb:204:in `transaction'
activerecord (3.0.1) lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
activerecord (3.0.1) lib/active_record/transactions.rb:237:in `block in save'
activerecord (3.0.1) lib/active_record/transactions.rb:248:in `rollback_active_record_state!'
activerecord (3.0.1) lib/active_record/transactions.rb:236:in `save'
activerecord (3.0.1) lib/active_record/base.rb:498:in `create'
app/models/project.rb:70:in `make_project_owner'
activesupport (3.0.1) lib/active_support/callbacks.rb:463:in `_run_create_callbacks'
activerecord (3.0.1) lib/active_record/callbacks.rb:281:in `create'
activerecord (3.0.1) lib/active_record/persistence.rb:247:in `create_or_update'
activerecord (3.0.1) lib/active_record/callbacks.rb:277:in `block in create_or_update'
activesupport (3.0.1) lib/active_support/callbacks.rb:428:in `_run_save_callbacks'
activerecord (3.0.1) lib/active_record/callbacks.rb:277:in `create_or_update'
activerecord (3.0.1) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.1) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.1) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.1) lib/active_record/transactions.rb:237:in `block (2 levels) in save'
activerecord (3.0.1) lib/active_record/transactions.rb:289:in `block in with_transaction_returning_status'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.1) lib/active_record/transactions.rb:204:in `transaction'
activerecord (3.0.1) lib/active_record/transactions.rb:287:in `with_transaction_returning_status'
activerecord (3.0.1) lib/active_record/transactions.rb:237:in `block in save'
activerecord (3.0.1) lib/active_record/transactions.rb:248:in `rollback_active_record_state!'
activerecord (3.0.1) lib/active_record/transactions.rb:236:in `save'
app/controllers/projects_controller.rb:34:in `create'
actionpack (3.0.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.0.1) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.1) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.1) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.1) lib/active_support/callbacks.rb:460:in `_run__2176748434120211400__process_action__1031157339911956458__callbacks'
activesupport (3.0.1) lib/active_support/callbacks.rb:409:in `_run_process_action_callbacks'
activesupport (3.0.1) lib/active_support/callbacks.rb:93:in `run_callbacks'
actionpack (3.0.1) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.1) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.1) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.1) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.1) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.1) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.1) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.1) lib/abstract_controller/rendering.rb:40:in `process'
actionpack (3.0.1) lib/action_controller/metal.rb:133:in `dispatch'
actionpack (3.0.1) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.1) lib/action_controller/metal.rb:173:in `block in action'
actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:75:in `optimized_each'
rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.1) lib/action_dispatch/routing/route_set.rb:492:in `call'
haml (3.0.24) lib/sass/plugin/rack.rb:41:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.1) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/cookies.rb:287:in `call'
activerecord (3.0.1) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.1) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.1) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:355:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.1) lib/active_support/callbacks.rb:415:in `_run_call_callbacks'
actionpack (3.0.1) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.1) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/show_exceptions.rb:46:in `call'
railties (3.0.1) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.1) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.1) lib/rack/lock.rb:11:in `call'
actionpack (3.0.1) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.1) lib/rails/application.rb:168:in `call'
railties (3.0.1) lib/rails/application.rb:77:in `method_missing'
railties (3.0.1) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.1) lib/rack/content_length.rb:13:in `call'
rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service'
/home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/pratik/.rvm/rubies/ruby-1.9.2-p0/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
I had a similar problem, but i was able to solve this with the following code:
module Connection
class DB1 < ActiveRecord::Base
self.abstract_class = true
establish_connection(Rails.env)
end
class DB2 < ActiveRecord::Base
self.abstract_class = true
establish_connection("#{Rails.env}_db2")
end
end
class Project < Connection::DB1
Maybe it worked for me because of the usages of establish_connection in all models.
I don't have time to test this so I cannot say for sure, but this line looks suspect to me:
self.calendars.create(:name => "default")
I would think it should be like this:
Calendar.create(:name => "default", :project_id => self.id)
Related
Im making an application in rails and my upload is throwing an error. Here are the details. My photos_controller.rb
def create
#photo = Photo.new(params[:photo])
respond_to do |format|
if #photo.save
format.html { redirect_to #photo, notice: 'Photo was successfully created.' }
format.json { render json: #photo, status: :created, location: #photo }
else
format.html { render action: "new" }
format.json { render json: #photo.errors, status: :unprocessable_entity }
end
end
end
my form
<%= f.file_field :binary_data %>
<%= f.submit %>
database model
t.string :photon
t.column :lat, :string
t.column :lon, :string
t.column :pname, :string
t.column :uname, :string
t.column :content_type, :string
t.column :filename, :string
t.column :binary_data, :binary
t.timestamps
I tried some ways which was mentioned in some blogs. None of them worked.
Here is the full trace
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:25:in `block in initialize'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `yield'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `default'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:27:in `block in initialize'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `yield'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `default'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:447:in `block in dump_ivars'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:445:in `each'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:445:in `dump_ivars'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:124:in `visit_Object'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:102:in `accept'
/usr/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:66:in `push'
/usr/lib/ruby/1.9.1/psych.rb:242:in `dump'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/quoting.rb:38:in `quote'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract_mysql_adapter.rb:203:in `quote'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:8:in `block in to_sql'
arel (3.0.3) lib/arel/visitors/bind_visitor.rb:17:in `call'
arel (3.0.3) lib/arel/visitors/bind_visitor.rb:17:in `visit_Arel_Nodes_BindParam'
arel (3.0.3) lib/arel/visitors/visitor.rb:19:in `visit'
arel (3.0.3) lib/arel/visitors/to_sql.rb:111:in `block in visit_Arel_Nodes_Values'
arel (3.0.3) lib/arel/visitors/to_sql.rb:109:in `map'
arel (3.0.3) lib/arel/visitors/to_sql.rb:109:in `visit_Arel_Nodes_Values'
arel (3.0.3) lib/arel/visitors/visitor.rb:19:in `visit'
arel (3.0.3) lib/arel/visitors/to_sql.rb:74:in `visit_Arel_Nodes_InsertStatement'
arel (3.0.3) lib/arel/visitors/visitor.rb:19:in `visit'
arel (3.0.3) lib/arel/visitors/visitor.rb:5:in `accept'
arel (3.0.3) lib/arel/visitors/to_sql.rb:19:in `accept'
arel (3.0.3) lib/arel/visitors/bind_visitor.rb:11:in `accept'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `to_sql'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:89:in `insert'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/query_cache.rb:14:in `insert'
activerecord (3.2.2) lib/active_record/relation.rb:66:in `insert'
activerecord (3.2.2) lib/active_record/persistence.rb:363:in `create'
activerecord (3.2.2) lib/active_record/timestamp.rb:57:in `create'
activerecord (3.2.2) lib/active_record/callbacks.rb:268:in `block in create'
activesupport (3.2.2) lib/active_support/callbacks.rb:403:in `_run__4454296851553403224__create__1976589364162331536__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_create_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.2) lib/active_record/callbacks.rb:268:in `create'
activerecord (3.2.2) lib/active_record/persistence.rb:344:in `create_or_update'
activerecord (3.2.2) lib/active_record/callbacks.rb:264:in `block in create_or_update'
activesupport (3.2.2) lib/active_support/callbacks.rb:403:in `_run__4454296851553403224__save__1976589364162331536__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_save_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
activerecord (3.2.2) lib/active_record/callbacks.rb:264:in `create_or_update'
activerecord (3.2.2) lib/active_record/persistence.rb:84:in `save'
activerecord (3.2.2) lib/active_record/validations.rb:50:in `save'
activerecord (3.2.2) lib/active_record/attribute_methods/dirty.rb:22:in `save'
activerecord (3.2.2) lib/active_record/transactions.rb:241:in `block (2 levels) in save'
activerecord (3.2.2) lib/active_record/transactions.rb:295:in `block in with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:208:in `transaction'
activerecord (3.2.2) lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
activerecord (3.2.2) lib/active_record/transactions.rb:241:in `block in save'
activerecord (3.2.2) lib/active_record/transactions.rb:252:in `rollback_active_record_state!'
activerecord (3.2.2) lib/active_record/transactions.rb:240:in `save'
app/controllers/photos_controller.rb:47:in `block in create'
actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:278:in `call'
actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:278:in `retrieve_collector_from_mimes'
actionpack (3.2.2) lib/action_controller/metal/mime_responds.rb:194:in `respond_to'
app/controllers/photos_controller.rb:46:in `create'
actionpack (3.2.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.2) lib/active_support/callbacks.rb:414:in `_run__1057882058708114548__process_action__3391181575290593173__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.2) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.2) lib/action_controller/metal/params_wrapper.rb:205:in `process_action'
activerecord (3.2.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.2) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.2) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:67:in `dispatch'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:30:in `call'
/usr/lib/ruby/vendor_ruby/journey/router.rb:68:in `block in call'
/usr/lib/ruby/vendor_ruby/journey/router.rb:56:in `each'
/usr/lib/ruby/vendor_ruby/journey/router.rb:56:in `call'
actionpack (3.2.2) lib/action_dispatch/routing/route_set.rb:594:in `call'
actionpack (3.2.2) 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:35:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.2) 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.2) lib/action_dispatch/middleware/cookies.rb:338:in `call'
activerecord (3.2.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:443:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `_run__255478243604444547__call__1976589364162331536__callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.2) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.2) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.2) lib/rails/rack/logger.rb:26:in `call_app'
railties (3.2.2) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.2) 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.2) 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.2) lib/action_dispatch/middleware/static.rb:61:in `call'
railties (3.2.2) lib/rails/engine.rb:479:in `call'
railties (3.2.2) lib/rails/application.rb:220:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:138:in `service'
/usr/lib/ruby/1.9.1/webrick/httpserver.rb:94:in `run'
/usr/lib/ruby/1.9.1/webrick/server.rb:191:in `block in start_thread'
parameters
{"utf8"=>"✓",
"authenticity_token"=>"1zvkibcE9YuaT2sR2ofHx06MlpH7JtK7QiK/sExTNVY=",
"photo"=>{"binary_data"=>#<ActionDispatch::Http::UploadedFile:0x007fdc144411a8 #original_filename="1.jpg",
#content_type="image/jpeg",
#headers="Content-Disposition: form-data; name=\"photo[binary_data]\"; filename=\"1.jpg\"\r\nContent-Type: image/jpeg\r\n",
#tempfile=#<File:/tmp/RackMultipart20140417-28258-142dwwo>>},
"commit"=>"Create Photo"}
server log
Started POST "/photos" for 127.0.0.1 at 2014-04-17 03:21:40 +0530
Processing by PhotosController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"1zvkibcE9YuaT2sR2ofHx06MlpH7JtK7QiK/sExTNVY=", "photo"=>{"binary_data"=>#<ActionDispatch::Http::UploadedFile:0x007fdc144411a8 #original_filename="1.jpg", #content_type="image/jpeg", #headers="Content-Disposition: form-data; name=\"photo[binary_data]\"; filename=\"1.jpg\"\r\nContent-Type: image/jpeg\r\n", #tempfile=#<File:/tmp/RackMultipart20140417-28258-142dwwo>>}, "commit"=>"Create Photo"}
(0.1ms) BEGIN
(0.2ms) ROLLBACK
Completed 500 Internal Server Error in 23ms
NoMethodError (undefined method `name' for nil:NilClass):
app/controllers/photos_controller.rb:47:in `block in create'
app/controllers/photos_controller.rb:46:in `create'
I am trying to implement a form with a many to many association (with :through) using active_admin. I am receiving undefined method `call' for nil:NilClass error message.
I am new to ruby and rails.
My models:
article.rb
class Article < ActiveRecord::Base
has_many :tagged_articles
has_many :tags, :through => :tagged_articles, :source => :tag, :class_name => TaggedArticle
accepts_nested_attributes_for :tags
end
tagged_article.rb
class TaggedArticle < ActiveRecord::Base
belongs_to :article
belongs_to :tag
end
tag.rb
class Tag < ActiveRecord::Base
has_many :tagged_articles
has_many :articles, :through => :tagged_articles
end
view
_form.html
<%= semantic_form_for #article, :html => {:id => "new_article",
:novalidate => "novalidate"} do |f| %>
app/admin/article.rb (active_admin file)
ActiveAdmin.register Article do
form partial: 'form'
form do |f|
f.has_many :tags, heading: 'Tags', allow_destroy: true, new_record: true
f.actions
end
show do
# renders app/views/admin/posts/_some_partial.html.erb
render 'preview'
end
#permit_params :title, :text,
# tags_attributes: [:name]
permit_params do
permitted = [:title, :text,
tags_attributes: [:name]]
# permitted << :other if resource.something?
permitted
end
end
I get this error (when opening the form)
Application trace
Extracted source (around line #1):
1
insert_tag renderer_for(:new)
app/admin/article.rb:6:in `block (2 levels) in <top (required)>'
Full trace
Application Trace | Framework Trace | Full Trace
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:61:in `block in has_many'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `call'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `block (2 levels) in inputs_for_nested_attributes'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:20:in `block in inputs'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:20:in `inputs'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:373:in `block in inputs_for_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1864:in `block in fields_for_nested_model'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:699:in `fields_for'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1863:in `fields_for_nested_model'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1849:in `block in fields_for_with_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `each'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `fields_for_with_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1521:in `fields_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:391:in `inputs_for_nested_attributes'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:176:in `block in js_for_has_many'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:176:in `js_for_has_many'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:99:in `block in has_many'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:160:in `block in without_wrapper'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:160:in `without_wrapper'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/form_builder.rb:90:in `has_many'
app/admin/article.rb:6:in `block (2 levels) in <top (required)>'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/form.rb:23:in `instance_exec'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/form.rb:23:in `block in main_content'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:435:in `form_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:167:in `block in semantic_form_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:190:in `with_custom_field_error_proc'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:166:in `semantic_form_for'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/view_helpers/form_helper.rb:9:in `active_admin_form_for'
arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/form.rb:22:in `main_content'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:83:in `block (2 levels) in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:82:in `block in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:81:in `build_main_content_wrapper'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:65:in `block in build_page_content'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:64:in `build_page_content'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:47:in `block (2 levels) in build_page'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:44:in `block in build_page'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:43:in `build_page'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/lib/active_admin/views/pages/base.rb:10:in `build'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/app/views/active_admin/resource/new.html.arb:1:in `block in __home_javkhlan__rvm_gems_ruby_______bundler_gems_active_admin__ca___f__ab__app_views_active_admin_resource_new_html_arb__4076692881198465766_51912660'
arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/app/views/active_admin/resource/new.html.arb:1:in `new'
/home/javkhlan/.rvm/gems/ruby-2.1.0/bundler/gems/active_admin-9ca081f47ab4/app/views/active_admin/resource/new.html.arb:1:in `__home_javkhlan__rvm_gems_ruby_______bundler_gems_active_admin__ca___f__ab__app_views_active_admin_resource_new_html_arb__4076692881198465766_51912660'
actionpack (4.0.2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/javkhlan/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:233:in `default_render'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:161:in `to_html'
responders (1.0.0) lib/responders/flash_responder.rb:104:in `to_html'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:154:in `respond'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:147:in `call'
actionpack (4.0.2) lib/action_controller/metal/mime_responds.rb:330:in `respond_with'
inherited_resources (1.4.1) lib/inherited_resources/actions.rb:19:in `new'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.2) lib/active_support/callbacks.rb:433:in `_run__1569366334490291269__process_action__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680: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:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241: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.0.2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__782737588198479971__call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.2) 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.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.2) lib/rails/engine.rb:511:in `call'
railties (4.0.2) lib/rails/application.rb:97: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'
/home/javkhlan/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/home/javkhlan/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/home/javkhlan/.rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Any idea on how i can make it working?
I think that the reason for nilclass error was that there were no assigned fields for the nested form.
Adding
f.has_many :tags do |cf|
cf.input :tag, :label => "Tag"
end
solved the nilclass problem
In the end, the following code worked. And there was no need to wirte _form.html.erb in this particular case.
form do |f|
f.has_many :tags do |cf|
cf.input :tag, :label => "Tag"
end
f.actions
end
If you're using allow_destroy: true in the form fields, you also need to use it on accepts_nested_attributes_for.
class Article < ActiveRecord::Base
has_many :tagged_articles
has_many :tags, :through => :tagged_articles, :source => :tag, :class_name => TaggedArticle
accepts_nested_attributes_for :tags, allow_destroy: true
end
I use Activeadmin, paperclip and Rails 4.
When i want to create a new article with multi images, I have this Error :
ArgumentError in Admin::Articles#new
wrong number of arguments (1 for 0)
When I try with just one image I have the same error.
ActiveAdmin : article.rb
ActiveAdmin.register Article do
controller do
def permitted_params
params.permit article: [:title, :images_attributes => [:picture, :id, :_destroy]]
end
end
form do |f|
f.inputs "Project Details" do
f.input :title
f.has_many :images do |p|
p.inputs do
p.input :_destroy, :as => :boolean, :label => "Destroy?" unless p.object.new_record?
p.input :picture, :as => :file, :hint => p.object.new_record? ? "" : f.template.image_tag(p.object.picture.url(:thumb))
end
end
end
f.actions
end
end
Models : article.rb
class Article < ActiveRecord::Base
has_many :images, :dependent => :destroy
accepts_nested_attributes_for :images, :allow_destroy => true
end
Models : image.rb
class Image < ActiveRecord::Base
belongs_to :article
has_attached_file :picture, :styles => { :large => "960x640>", :medium => "300x300>", :thumb => "150x150>" }, :default_url => "/images/:style/missing.png"
end
Migration :
class CreateImages < ActiveRecord::Migration
def change
create_table :images do |t|
t.belongs_to :article
t.attachment :picture
t.timestamps
end
end
end
Full trace of my error :
paperclip (4.1.1) lib/paperclip/has_attached_file.rb:83:in `block in add_required_validations'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:39:in `call'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:39:in `validator_relevant?'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:27:in `block in validations'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:26:in `select'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:26:in `validations'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:129:in `validations?'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/validations.rb:136:in `required?'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:25:in `requirement_text_or_proc'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:29:in `requirement_text'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:20:in `label_text'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/labelling.rb:9:in `label_html'
formtastic (2.3.0.rc2) lib/formtastic/inputs/file_input.rb:36:in `block in to_html'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (2.3.0.rc2) lib/formtastic/inputs/base/wrapping.rb:11:in `input_wrapping'
formtastic (2.3.0.rc2) lib/formtastic/inputs/file_input.rb:35:in `to_html'
formtastic (2.3.0.rc2) lib/formtastic/helpers/input_helper.rb:241:in `input'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:26:in `block in input'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:26:in `input'
app/admin/article.rb:16:in `block (5 levels) in <top (required)>'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs'
app/admin/article.rb:14:in `block (4 levels) in <top (required)>'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:61:in `call'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:61:in `block in has_many'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `call'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:375:in `block (2 levels) in inputs_for_nested_attributes'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:373:in `block in inputs_for_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1864:in `block in fields_for_nested_model'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:699:in `fields_for'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1863:in `fields_for_nested_model'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1849:in `block in fields_for_with_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `each'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1847:in `fields_for_with_nested_attributes'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:1521:in `fields_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:391:in `inputs_for_nested_attributes'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:176:in `block in js_for_has_many'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:176:in `js_for_has_many'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:99:in `block in has_many'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:160:in `block in without_wrapper'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:160:in `without_wrapper'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:90:in `has_many'
app/admin/article.rb:13:in `block (3 levels) in <top (required)>'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:143:in `block in field_set_and_list_wrapping'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
formtastic (2.3.0.rc2) lib/formtastic/helpers/fieldset_wrapper.rb:32:in `field_set_and_list_wrapping'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:142:in `field_set_and_list_wrapping'
formtastic (2.3.0.rc2) lib/formtastic/helpers/inputs_helper.rb:292:in `inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `block in inputs'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:151:in `with_new_form_buffer'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/form_builder.rb:20:in `inputs'
app/admin/article.rb:10:in `block (2 levels) in <top (required)>'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:23:in `instance_exec'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:23:in `block in main_content'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `block in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in `with_output_buffer'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in `capture'
actionpack (4.0.2) lib/action_view/helpers/form_helper.rb:435:in `form_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:167:in `block in semantic_form_for'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:190:in `with_custom_field_error_proc'
formtastic (2.3.0.rc2) lib/formtastic/helpers/form_helper.rb:166:in `semantic_form_for'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/view_helpers/form_helper.rb:9:in `active_admin_form_for'
arbre (1.0.1) lib/arbre/element.rb:175:in `method_missing'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/form.rb:22:in `main_content'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:83:in `block (2 levels) in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:82:in `block in build_main_content_wrapper'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:81:in `build_main_content_wrapper'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:65:in `block in build_page_content'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:64:in `build_page_content'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:47:in `block (2 levels) in build_page'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:31:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:14:in `div'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:44:in `block in build_page'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:49:in `with_current_arbre_element'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:43:in `build_page'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/lib/active_admin/views/pages/base.rb:10:in `build'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:30:in `block in build_tag'
arbre (1.0.1) lib/arbre/context.rb:92:in `with_current_arbre_element'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:26:in `build_tag'
arbre (1.0.1) lib/arbre/element/builder_methods.rb:39:in `insert_tag'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `block in __home_bibou__rvm_gems_ruby_______p____bundler_gems_active_admin___de_f__ae_d_app_views_active_admin_resource_new_html_arb__2699006568721876069_69819426589980'
arbre (1.0.1) lib/arbre/context.rb:45:in `instance_eval'
arbre (1.0.1) lib/arbre/context.rb:45:in `initialize'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `new'
/home/bibou/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-66de2f86ae1d/app/views/active_admin/resource/new.html.arb:1:in `__home_bibou__rvm_gems_ruby_______p____bundler_gems_active_admin___de_f__ae_d_app_views_active_admin_resource_new_html_arb__2699006568721876069_69819426589980'
actionpack (4.0.2) lib/action_view/template.rb:143:in `block in render'
activesupport (4.0.2) lib/active_support/notifications.rb:161:in `instrument'
actionpack (4.0.2) lib/action_view/template.rb:141:in `render'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:49:in `block (2 levels) in render_template'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:48:in `block in render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:56:in `render_with_layout'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:47:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:17:in `render'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:23:in `render'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:127:in `_render_template'
actionpack (4.0.2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:120:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:33:in `render_to_body'
actionpack (4.0.2) lib/action_controller/metal/renderers.rb:26:in `render_to_body'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:97:in `render'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block (2 levels) in render'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:in `block in render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:84:in `cleanup_view_runtime'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:25:in `cleanup_view_runtime'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:40:in `render'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:233:in `default_render'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:161:in `to_html'
responders (1.0.0) lib/responders/flash_responder.rb:104:in `to_html'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:154:in `respond'
actionpack (4.0.2) lib/action_controller/metal/responder.rb:147:in `call'
actionpack (4.0.2) lib/action_controller/metal/mime_responds.rb:330:in `respond_with'
inherited_resources (1.4.1) lib/inherited_resources/actions.rb:19:in `new'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (4.0.2) lib/active_support/callbacks.rb:433:in `_run__2406119207582674973__process_action__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:136:in `process'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:in `process'
actionpack (4.0.2) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.0.2) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680: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:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241: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.0.2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
activerecord (4.0.2) lib/active_record/migration.rb:369:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__1775309793310121907__call__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.0.2) 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.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.0.2) lib/rails/engine.rb:511:in `call'
railties (4.0.2) lib/rails/application.rb:97: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'
/home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/home/bibou/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
Thank you for your help
Edit :
I use this gem for my project :
gem 'devise'
gem 'cancan'
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'annotate'
gem 'ckeditor'
gem "paperclip", "~> 4.1"
My OS is a Ubuntu and I use ImageMagick-6.8.8-7.
When I run which convert
I have : /usr/local/bin/convert
development.rb
PaperclipActiveadmin::Application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false
# Do not eager load code on boot.
config.eager_load = false
# Show full error reports and disable caching.
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
# Don't care if the mailer can't send.
config.action_mailer.raise_delivery_errors = false
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
# Raise an error on page load if there are pending migrations
config.active_record.migration_error = :page_load
# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# configure paperclip
Paperclip.options[:command_path] = "/usr/local/bin/"
end
Solution :
add require: false to my input :
p.input :picture, :as => :file, :hint => p.object.new_record? ? "" : f.template.image_tag(p.object.picture.url(:thumb)), required: false
And in my image.rb add a validates_attachment_content_type :
validates_attachment_content_type :picture, :content_type => ["image/jpg", "image/jpeg", "image/png"]
Thank You Philip Hallstrom for your help and your solution
Per https://github.com/justinfrench/formtastic/issues/999 the temporary solution is to add require: false to your input. Like so:
f.input :image, required: false
Just tried it and it works for me.
I recently had a RoR application developed for me by a third party and now I'm on my own to add future features that I want. It works on Heroku, but when I try to run it on localhost:3000, I get an ArgumentError. I have not changed any of the code, I just pulled it from github and tried to run it on a local development server to implement new changes. I've asked them about this problem, but they are not sure of the cause, so here goes...
We're running ruby 1.9.2, rails 3.0.7
Whenever I try to save a project on my site, or whenever .save is called on an object, I get an ArgumentError, wrong number of arguments (2 for 0).
Application Trace
app/controllers/users/projects_controller.rb:24:in `create'
Full Trace
activesupport (3.0.7) lib/active_support/ordered_hash.rb:16:in `block in to_yaml'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:19:in `call'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/deprecated.rb:19:in `block in quick_emit'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:296:in `dump_coder'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:61:in `accept'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:36:in `<<'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/psych.rb:165:in `dump'
activerecord (3.0.7) lib/active_record/base.rb:1720:in `block in arel_attributes_values'
activerecord (3.0.7) lib/active_record/base.rb:1713:in `each'
activerecord (3.0.7) lib/active_record/base.rb:1713:in `arel_attributes_values'
activerecord (3.0.7) lib/active_record/persistence.rb:265:in `create'
activerecord (3.0.7) lib/active_record/timestamp.rb:47:in `create'
activerecord (3.0.7) lib/active_record/callbacks.rb:277:in `block in create'
activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_create_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:277:in `create'
activerecord (3.0.7) lib/active_record/persistence.rb:246:in `create_or_update'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `block in create_or_update'
activesupport (3.0.7) lib/active_support/callbacks.rb:424:in `_run_save_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `create_or_update'
activerecord (3.0.7) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.7) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block (2 levels) in save'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block in save'
activerecord (3.0.7) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.7) lib/active_record/transactions.rb:239:in `save'
app/controllers/users/projects_controller.rb:24:in `create'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.7) lib/active_support/callbacks.rb:448:in `_run__334044120__process_action__677517956__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block in recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:68: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.7) lib/action_dispatch/routing/route_set.rb:493:in `call'
warden (1.0.6) lib/warden/manager.rb:35:in `block in call'
warden (1.0.6) lib/warden/manager.rb:34:in `catch'
warden (1.0.6) lib/warden/manager.rb:34:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.4) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.4) lib/rack/sendfile.rb:106:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.4) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.4) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.4) lib/rack/lock.rb:11:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.7) lib/rails/application.rb:168:in `call'
railties (3.0.7) lib/rails/application.rb:77:in `method_missing'
railties (3.0.7) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.4) lib/rack/content_length.rb:13:in `call'
rack (1.2.4) lib/rack/handler/webrick.rb:52:in `service'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2- p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2- p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/squizzleflip/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
the code from projects_controller, line 24 is the if statement
def create
#project = Project.new(params[:project])
#project.memberships.build(:user_id => current_profile.id, :pending => false)
if #project.save
redirect_to destination, :notice => 'Project was successfully created.'
else
build_project_associations_for_nested_forms
render :action => 'new'
end
end
I'm a bit new at this, so I'm not quite sure what else is needed to determine the problem.
Have you tried running something other than WEBrick (assuming you're using that)? Try installing Thin (gem install thin) and see if the problem persists.
Make sure that you have got all the required gem, run bundle install:
bundle install
Restart the app, hopefully that helps.
When trying to update one of my models I get the exception can't define singleton method "encode_with" for BigDecimal. I am using Rails 3.0.7 & Ruby 1.9.2.
SkateparksController
def update
#skatepark.update_attributes(params[:skatepark])
end
Full Trace
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/deprecated.rb:16:in `singleton_method_added'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/deprecated.rb:16:in `define_method'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/deprecated.rb:16:in `quick_emit'
activesupport (3.0.7) lib/active_support/core_ext/big_decimal/conversions.rb:15:in `to_yaml'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:55:in `accept'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:227:in `block in visit_Hash'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:225:in `each'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:225:in `visit_Hash'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:63:in `accept'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/visitors/yaml_tree.rb:36:in `<<'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:165:in `dump'
rspec-mocks (2.6.0) lib/rspec/mocks/extensions/psych.rb:5:in `dump_with_mocks'
/Users/Kyle/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych/core_ext.rb:13:in `psych_to_yaml'
paper_trail (2.2.5) lib/paper_trail/has_paper_trail.rb:158:in `object_to_string'
paper_trail (2.2.5) lib/paper_trail/has_paper_trail.rb:113:in `record_update'
activesupport (3.0.7) lib/active_support/callbacks.rb:415:in `_run_update_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:281:in `update'
activerecord (3.0.7) lib/active_record/persistence.rb:246:in `create_or_update'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `block in create_or_update'
activesupport (3.0.7) lib/active_support/callbacks.rb:444:in `_run_save_callbacks'
activerecord (3.0.7) lib/active_record/callbacks.rb:273:in `create_or_update'
activerecord (3.0.7) lib/active_record/persistence.rb:39:in `save'
activerecord (3.0.7) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block (2 levels) in save'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block in save'
activerecord (3.0.7) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.7) lib/active_record/transactions.rb:239:in `save'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:245:in `block in update_address'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:9:in `without_callback'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:244:in `update_address'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:218:in `block in attach_geocode'
activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_geocoding_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:216:in `attach_geocode'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:151:in `block in validates_as_geocodable'
activesupport (3.0.7) lib/active_support/callbacks.rb:470:in `_run_validate_callbacks'
activemodel (3.0.7) lib/active_model/validations.rb:212:in `run_validations!'
activemodel (3.0.7) lib/active_model/validations/callbacks.rb:67:in `block in run_validations!'
activesupport (3.0.7) lib/active_support/callbacks.rb:424:in `_run_validation_callbacks'
activemodel (3.0.7) lib/active_model/validations/callbacks.rb:67:in `run_validations!'
activemodel (3.0.7) lib/active_model/validations.rb:179:in `valid?'
activerecord (3.0.7) lib/active_record/validations.rb:55:in `valid?'
activerecord (3.0.7) lib/active_record/validations.rb:75:in `perform_validations'
activerecord (3.0.7) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block (2 levels) in save'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block in save'
activerecord (3.0.7) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.7) lib/active_record/transactions.rb:239:in `save'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:245:in `block in update_address'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:9:in `without_callback'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:244:in `update_address'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:218:in `block in attach_geocode'
activesupport (3.0.7) lib/active_support/callbacks.rb:414:in `_run_geocoding_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:216:in `attach_geocode'
acts_as_geocodable (2.0.2) lib/acts_as_geocodable.rb:151:in `block in validates_as_geocodable'
activesupport (3.0.7) lib/active_support/callbacks.rb:470:in `_run_validate_callbacks'
activemodel (3.0.7) lib/active_model/validations.rb:212:in `run_validations!'
activemodel (3.0.7) lib/active_model/validations/callbacks.rb:67:in `block in run_validations!'
activesupport (3.0.7) lib/active_support/callbacks.rb:424:in `_run_validation_callbacks'
activemodel (3.0.7) lib/active_model/validations/callbacks.rb:67:in `run_validations!'
activemodel (3.0.7) lib/active_model/validations.rb:179:in `valid?'
activerecord (3.0.7) lib/active_record/validations.rb:55:in `valid?'
activerecord (3.0.7) lib/active_record/validations.rb:75:in `perform_validations'
activerecord (3.0.7) lib/active_record/validations.rb:43:in `save'
activerecord (3.0.7) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block (2 levels) in save'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/transactions.rb:240:in `block in save'
activerecord (3.0.7) lib/active_record/transactions.rb:251:in `rollback_active_record_state!'
activerecord (3.0.7) lib/active_record/transactions.rb:239:in `save'
activerecord (3.0.7) lib/active_record/persistence.rb:128:in `block in update_attributes'
activerecord (3.0.7) lib/active_record/transactions.rb:292:in `block in with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/database_statements.rb:139:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:207:in `transaction'
activerecord (3.0.7) lib/active_record/transactions.rb:290:in `with_transaction_returning_status'
activerecord (3.0.7) lib/active_record/persistence.rb:126:in `update_attributes'
app/controllers/admin/skateparks_controller.rb:54:in `update'
actionpack (3.0.7) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:150:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rendering.rb:11:in `process_action'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.0.7) lib/active_support/callbacks.rb:472:in `block in _run__3889911993370107397__process_action__388168845574438513__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:221:in `block in _conditional_callback_around_218'
activesupport (3.0.7) lib/active_support/callbacks.rb:331:in `around'
activesupport (3.0.7) lib/active_support/callbacks.rb:315:in `_callback_around_33'
activesupport (3.0.7) lib/active_support/callbacks.rb:220:in `_conditional_callback_around_218'
activesupport (3.0.7) lib/active_support/callbacks.rb:436:in `_run__3889911993370107397__process_action__388168845574438513__callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:410:in `_run_process_action_callbacks'
activesupport (3.0.7) lib/active_support/callbacks.rb:94:in `run_callbacks'
actionpack (3.0.7) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `block in instrument'
activesupport (3.0.7) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.7) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.7) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.7) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.7) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.7) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.7) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.7) lib/action_controller/metal.rb:178:in `block in action'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.7) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `block in call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `block 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.7) lib/action_dispatch/routing/route_set.rb:493:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/builder.rb:30:in `call'
sass (3.1.3) lib/sass/plugin/rack.rb:54:in `call'
warden (1.0.4) lib/warden/manager.rb:35:in `block in call'
warden (1.0.4) lib/warden/manager.rb:34:in `catch'
warden (1.0.4) lib/warden/manager.rb:34:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
flash_cookie_session (1.1.1) lib/flash_cookie_session/middleware.rb:18:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.7) lib/active_record/query_cache.rb:32:in `block in call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.7) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.7) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:46:in `block in call'
activesupport (3.0.7) lib/active_support/callbacks.rb:416:in `_run_call_callbacks'
actionpack (3.0.7) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.7) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.7) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `block in call'
<internal:prelude>:10:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.7) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.7) lib/rails/application.rb:168:in `call'
railties (3.0.7) lib/rails/application.rb:77:in `method_missing'
railties (3.0.7) 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/chunked.rb:15:in `call'
thin (1.2.11) lib/thin/connection.rb:84:in `block in pre_process'
thin (1.2.11) lib/thin/connection.rb:82:in `catch'
thin (1.2.11) lib/thin/connection.rb:82:in `pre_process'
thin (1.2.11) lib/thin/connection.rb:57:in `process'
thin (1.2.11) lib/thin/connection.rb:42:in `receive_data'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
thin (1.2.11) lib/thin/backends/base.rb:61:in `start'
thin (1.2.11) lib/thin/server.rb:159:in `start'
rack (1.2.3) lib/rack/handler/thin.rb:14:in `run'
rack (1.2.3) lib/rack/server.rb:217:in `start'
railties (3.0.7) lib/rails/commands/server.rb:65:in `start'
railties (3.0.7) lib/rails/commands.rb:30:in `block in <top (required)>'
railties (3.0.7) lib/rails/commands.rb:27:in `tap'
railties (3.0.7) lib/rails/commands.rb:27:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<main>'
It might be because of a YAML parser error. I had a similar error which I fixed using the following code:
#in config/boot.rb
require 'rubygems'
require 'yaml'
YAML::ENGINE.yamler= 'syck'
# Set up gems listed in the Gemfile.
gemfile = File.expand_path('../../Gemfile', __FILE__)
......
I have seen this error in ubuntu 10.10+ machines
I had a similar problem using jruby 1.6.5, ruby 1.9 and rails 2.3.14 on windows
$ jruby -v
jruby 1.6.5 (ruby-1.9.2-p136) (2011-10-25 9dcd388) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_29) [Windows 7-amd64-java]
I was able to get around this by looking at the fix for rails 3. All I had to do was to add a file (I called it fix_big_decimal.rb) to my config/initializers:
module ActiveSupport
module CoreExtensions
module BigDecimal
module Conversions
def encode_with(coder)
string = to_s
coder.represent_scalar(nil, YAML_MAPPING[string] || string)
end
# Backport this method if it doesn't exist
unless method_defined?(:to_d)
def to_d
self
end
end
end
end
end
end