I am trying to make a form and submit a skill and description into a database. I am almost done however I am getting this error after submitting my info:
NameError in SkillsController#create
uninitialized constant Skill::Description
and it points to this action in my controller:
def create
#skills = Skill.new(skill_params)
if #skills.save
redirect_to :action => 'index'
else
#skills = Skill.find(:all)
render :action => 'new'
end
end
I have a private method at the bottom defining params which states:
private
def skill_params
params.require(:skill).permit(:description)
end
This is the fullstack trace:
activerecord (4.1.2.rc1) lib/active_record/inheritance.rb:133:in `compute_type'
activerecord (4.1.2.rc1) lib/active_record/reflection.rb:221:in `klass'
activerecord (4.1.2.rc1) lib/active_record/associations/association.rb:214:in `raise_on_type_mismatch!'
activerecord (4.1.2.rc1) lib/active_record/associations/collection_association.rb:356:in `block in replace'
activerecord (4.1.2.rc1) lib/active_record/associations/collection_association.rb:356:in `each_char'
activerecord (4.1.2.rc1) lib/active_record/associations/collection_association.rb:356:in `replace'
activerecord (4.1.2.rc1) lib/active_record/associations/collection_association.rb:41:in `writer'
activerecord (4.1.2.rc1) lib/active_record/associations/builder/association.rb:118:in `description='
activerecord (4.1.2.rc1) lib/active_record/attribute_assignment.rb:45:in `public_send'
activerecord (4.1.2.rc1) lib/active_record/attribute_assignment.rb:45:in `_assign_attribute'
activerecord (4.1.2.rc1) lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes'
activerecord (4.1.2.rc1) lib/active_record/attribute_assignment.rb:26:in `each'
activerecord (4.1.2.rc1) lib/active_record/attribute_assignment.rb:26:in `assign_attributes'
activerecord (4.1.2.rc1) lib/active_record/core.rb:455:in `init_attributes'
activerecord (4.1.2.rc1) lib/active_record/core.rb:198:in `initialize'
activerecord (4.1.2.rc1) lib/active_record/inheritance.rb:30:in `new'
activerecord (4.1.2.rc1) lib/active_record/inheritance.rb:30:in `new'
app/controllers/skills_controller.rb:29:in `create'
actionpack (4.1.2.rc1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.2.rc1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.2.rc1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.2.rc1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.2.rc1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.2.rc1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.2.rc1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.2.rc1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.2.rc1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.2.rc1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.2.rc1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.2.rc1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.2.rc1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.2.rc1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.2.rc1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.2.rc1) lib/action_controller/metal.rb:196:in `dispatch'
actionpack (4.1.2.rc1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.2.rc1) lib/action_controller/metal.rb:232:in `block in action'
actionpack (4.1.2.rc1) lib/action_dispatch/routing/route_set.rb:82:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/routing/route_set.rb:82:in `dispatch'
actionpack (4.1.2.rc1) lib/action_dispatch/routing/route_set.rb:50:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.2.rc1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.2.rc1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/routing/route_set.rb:678:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.2.rc1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.2.rc1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.2.rc1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.2.rc1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.2.rc1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.2.rc1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.2.rc1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.2.rc1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.2.rc1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.2.rc1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.2.rc1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.2.rc1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.2.rc1) lib/rails/engine.rb:514:in `call'
railties (4.1.2.rc1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
C:/RailsInstaller/Ruby2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
and this is my schema:
create_table "skills", force: true do |t|
t.datetime "created_at"
t.string "description"
end
This is my skills/new.html.erb form:
<h1>Add new Skill</h1>
<%= form_tag ({action: "create"}) do %>
<p><label for="skill">Skill</label>:
<%= text_field 'skill', 'title' %></p>
<p><label for="skill_description">Description</label><br/>
<%= text_area 'skill', 'description' %></p>
<%= submit_tag "Create" %>
<% end %>
<%= link_to 'Back', {:action => 'index'} %>
I hope I have provided enough info to solve the issue and thank you anyone who knows what to do to initialize description. Thanks again and cheers!
index.html.erb:
<% if #skills.blank? %>
<p>There are not any skills currently saved in the system.</p>
<% else %>
<p>These are the current skills saved in our system</p>
<ul id="skills">
<% #skills.each do |c| %>
<li><%= link_to c.title, {:action => 'show', :id => c.id} -%></li>
<li>
<%= link_to c.title, {:action => 'show', :id => c.id} -%>
<b> <%= link_to 'Edit', {:action => 'edit', :id => c.id} %></b>
<b> <%= link_to "Delete", {:action => 'delete', :id => c.id},
:confirm => "Are you sure you want to delete this skill??" %></b>
</li>
<% end %>
</ul>
<p><%= link_to "Add new Skill", {:action => 'new' }%></p>
<% end %>
I do not have a title param available and it is causing problems.
skill.rb:
class Skill < ActiveRecord::Base
has_many :skill
has_many :description
end
hope this new info helps! Thanks again for taking a look with me.
Change the model skill.rb to this:
class Skill < ActiveRecord::Base
end
The has_many method is used to define Relations in the ORM context. There is no need to define the columns of the table itself. Rails get that information by itself.
You also have other issues in your index.html.erb and new.html.erb pages. You are referring to a title property of skill, but your migration does not show a title property.
I would recommend you delete controller, model, views, migration and data table itself (assuming that it is just a development project) and use scaffold to generate them using the command below:
$ bin/rails generate scaffold Skill title:string description:text
Please note that $ is not part of the command, its the prompt in your terminal.
Read up more on rails command line here
I think you'd better use form_for. There are no skill_params returning if you build the form that way.
form_tag is better for no model forms.
Try like this:
# skills_controller
def new
#skill = Skill.new
end
# new.html.erb
<%= form_for #skill do |f| %>
<%= f.text_area :description %>
# Other fields and tags...
<%= f.submit %>
<% end %>
Hope this helps.
Related
I have a project in which I am using omniauth for Facebook, Twitter, and LinkedIn. It is also using the Devise login gem. When a user goes to the sign-up page to create a login and inputs the e-mail and selects a password, the error page NameError in RegistrationsController#create shows up.
This appears in the terminal:
Started POST "/users" for 127.0.0.1 at 2014-07-25 14:42:30 -0400
Processing by RegistrationsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"MMYGtL6b6AyEuWIWwpxMg7qn8TWGXinMZTQ2K0GDsyU=", "user"=>{"email"=>"Phil9767#yahoo.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Sign up"}
(0.1ms) begin transaction
User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = 'phil9767#yahoo.com' LIMIT 1
(0.1ms) rollback transaction
Completed 500 Internal Server Error in 91ms
NameError (undefined local variable or method `confirmed_at' for #<User:0x00000106162ef0>):
activemodel (4.1.1) lib/active_model/attribute_methods.rb:435:in `method_missing'
activerecord (4.1.1) lib/active_record/attribute_methods.rb:206:in `method_missing'
devise (3.2.4) lib/devise/models/confirmable.rb:88:in `confirmed?'
devise (3.2.4) lib/devise/models/confirmable.rb:163:in `confirmation_required?'
activesupport (4.1.1) lib/active_support/callbacks.rb:424:in `block in make_lambda'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `block (2 levels) in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `each'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `all?'
activesupport (4.1.1) lib/active_support/callbacks.rb:142:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.1) lib/active_record/callbacks.rb:306:in `create_record'
activerecord (4.1.1) lib/active_record/timestamp.rb:57:in `create_record'
activerecord (4.1.1) lib/active_record/persistence.rb:482:in `create_or_update'
activerecord (4.1.1) lib/active_record/callbacks.rb:302:in `block in create_or_update'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
activerecord (4.1.1) lib/active_record/callbacks.rb:302:in `create_or_update'
activerecord (4.1.1) lib/active_record/persistence.rb:103:in `save'
activerecord (4.1.1) lib/active_record/validations.rb:51:in `save'
activerecord (4.1.1) lib/active_record/attribute_methods/dirty.rb:21:in `save'
activerecord (4.1.1) lib/active_record/transactions.rb:268:in `block (2 levels) in save'
activerecord (4.1.1) lib/active_record/transactions.rb:329:in `block in with_transaction_returning_status'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `block in transaction'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:219:in `within_new_transaction'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/database_statements.rb:211:in `transaction'
activerecord (4.1.1) lib/active_record/transactions.rb:208:in `transaction'
activerecord (4.1.1) lib/active_record/transactions.rb:326:in `with_transaction_returning_status'
activerecord (4.1.1) lib/active_record/transactions.rb:268:in `block in save'
activerecord (4.1.1) lib/active_record/transactions.rb:283:in `rollback_active_record_state!'
activerecord (4.1.1) lib/active_record/transactions.rb:267:in `save'
devise (3.2.4) app/controllers/devise/registrations_controller.rb:15:in `create'
actionpack (4.1.1) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:189:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:113:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:229:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:166:in `block in halting'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:149:in `block in halting_and_conditional'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `call'
activesupport (4.1.1) lib/active_support/callbacks.rb:86:in `run_callbacks'
actionpack (4.1.1) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `block in instrument'
activesupport (4.1.1) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.1.1) lib/active_support/notifications.rb:159:in `instrument'
actionpack (4.1.1) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.1.1) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.1.1) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.1.1) lib/abstract_controller/base.rb:136:in `process'
actionview (4.1.1) lib/action_view/rendering.rb:30:in `process'
actionpack (4.1.1) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.1.1) lib/action_controller/metal.rb:231:in `block in action'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:80:in `dispatch'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:48:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/mapper.rb:45:in `call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:71:in `block in call'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `each'
actionpack (4.1.1) lib/action_dispatch/journey/router.rb:59:in `call'
actionpack (4.1.1) lib/action_dispatch/routing/route_set.rb:676:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/strategy.rb:186:in `call!'
omniauth (1.2.1) lib/omniauth/strategy.rb:164:in `call'
omniauth (1.2.1) lib/omniauth/builder.rb:59:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:35:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/cookies.rb:560:in `call'
activerecord (4.1.1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.1.1) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in `call'
activerecord (4.1.1) lib/active_record/migration.rb:380:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.1) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/reloader.rb:73:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.1.1) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.1) lib/rails/engine.rb:514:in `call'
railties (4.1.1) lib/rails/application.rb:144:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `service'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
/Users/TheMac/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/webrick/server.rb:295:in `block in start_thread'
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (0.8ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (1.2ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (10.6ms)
Rendered /Users/TheMac/.rvm/gems/ruby-2.1.1/gems/actionpack-4.1.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb within rescues/layout (28.6ms)
I have done many searches on stackoverflow, and it doesn't appear to be whether authentications is pluralized in the associations, nor does it seem to be related to skipping the authentication in devise. I created a registrations controller, but it didn't seem to help. Any ideas on what the issue could be?
Here is my user model
class User < ActiveRecord::Base
has_many :authentications
TEMP_EMAIL_PREFIX = 'change#me'
TEMP_EMAIL_REGEX = /\Achange#me/
# Include default devise modules. Others available are:
# :lockable, :timeoutable
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable, :omniauthable
validates_format_of :email, :without => TEMP_EMAIL_REGEX, on: :update
def self.find_for_oauth(auth, signed_in_resource = nil)
# Get the identity and user if they exist
identity = Identity.find_for_oauth(auth)
# If a signed_in_resource is provided it always overrides the existing user
# to prevent the identity being locked with accidentally created accounts.
# Note that this may leave zombie accounts (with no associated identity) which
# can be cleaned up at a later date.
user = signed_in_resource ? signed_in_resource : identity.user
# Create the user if needed
if user.nil?
# Get the existing user by email if the provider gives us a verified email.
# If no verified email was provided we assign a temporary email and ask the
# user to verify it on the next step via UsersController.finish_signup
email_is_verified = auth.info.email && (auth.info.verified || auth.info.verified_email)
email = auth.info.email if email_is_verified
user = User.where(:email => email).first if email
# Create the user if it's a new registration
if user.nil?
user = User.new(
name: auth.extra.raw_info.name,
#username: auth.info.nickname || auth.uid,
email: email ? email : "#{TEMP_EMAIL_PREFIX}-#{auth.uid}-#{auth.provider}.com",
password: Devise.friendly_token[0,20]
)
user.skip_confirmation!
user.save!
end
end
# Associate the identity with the user if needed
if identity.user != user
identity.user = user
identity.save!
end
user
end
def email_verified?
self.email && self.email !~ TEMP_EMAIL_REGEX
end
end
This is my schema.rb
ActiveRecord::Schema.define(version: 20140724042203) do
create_table "identities", force: true do |t|
t.integer "user_id"
t.string "provider"
t.string "uid"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "identities", ["user_id"], name: "index_identities_on_user_id"
create_table "users", force: true do |t|
t.string "provider"
t.string "uid"
t.string "name"
t.string "oauth_token"
t.datetime "oauth_expires_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end
Your model Users is missing the "confirmed_at" attribute.
you can create it with a new migration:
rails g migration add_unconfirmed_to_devise
and put in:
class AddUnconfirmedToDevise < ActiveRecord::Migration
def change
change_table(:users) do |t|
#t.string :confirmation_token
#t.datetime :confirmed_at
#t.datetime :confirmation_sent_at
#t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
#t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
#t.string :unlock_token # Only if unlock strategy is :email or :both
#t.datetime :locked_at
end
end
end
Just uncomment each attribute you need.
I am having trouble with adding comments to posts in a simple blog. Using Haml, Rails 3, ActiveAdmin, and Spree.
NoMethodError in Posts#show
Showing /app/views/posts/show.html.haml where line #25 raised:
undefined method `model_name' for NilClass:Class
Extracted source (around line #25):
22: .comments
23: %h3 Leave a Reply
24: / = #comment.inspect
25: = form_for #comments do |f|
26: .row-fluid
27: = f.hidden_field :post_id
28: .row-fluid
Application Trace | Framework Trace | Full Trace
activemodel (3.2.13) lib/active_model/naming.rb:163:in `model_name_from_record_or_class'
activemodel (3.2.13) lib/active_model/naming.rb:158:in `param_key'
actionpack (3.2.13) lib/action_view/helpers/form_helper.rb:369:in `form_for'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:146:in `form_for_with_haml'
haml (4.0.3) lib/haml/helpers/action_view_xss_mods.rb:28:in `form_for_with_haml_xss'
app/views/posts/show.html.haml:25:in `block in _1d7665fe0e4edacd3f10a86fba89b0fb'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `block in capture_with_haml'
haml (4.0.3) lib/haml/helpers.rb:368:in `call'
haml (4.0.3) lib/haml/helpers.rb:368:in `block in capture_haml'
haml (4.0.3) lib/haml/helpers.rb:617:in `with_haml_buffer'
haml (4.0.3) lib/haml/helpers.rb:364:in `capture_haml'
haml (4.0.3) lib/haml/helpers/xss_mods.rb:61:in `capture_haml_with_haml_xss'
haml (4.0.3) lib/haml/helpers/action_view_mods.rb:45:in `capture_with_haml'
actionpack (3.2.13) lib/action_view/helpers/capture_helper.rb:138:in `content_for'
app/views/posts/show.html.haml:1:in `_1d7665fe0e4edacd3f10a86fba89b0fb'
actionpack (3.2.13) lib/action_view/template.rb:145:in `block in render'
activesupport (3.2.13) lib/active_support/notifications.rb:125:in `instrument'
actionpack (3.2.13) lib/action_view/template.rb:143:in `render'
deface (0.9.1) lib/deface/action_view_extensions.rb:37:in `render'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:47:in `block (2 levels) in render_template'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/abstract_renderer.rb:38:in `instrument'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:46:in `block in render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:54:in `render_with_layout'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:45:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/template_renderer.rb:18:in `render'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.2.13) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:110:in `_render_template'
actionpack (3.2.13) lib/action_controller/metal/streaming.rb:225:in `_render_template'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:103:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/renderers.rb:28:in `render_to_body'
actionpack (3.2.13) lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:88:in `render'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/miriam.williams/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/benchmark.rb:296:in `realtime'
activesupport (3.2.13) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.2.13) lib/action_controller/metal/implicit_render.rb:5:in `send_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.2.13) lib/active_support/callbacks.rb:425:in `_run__1713495783671643053__process_action__2295715638951091725__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `block in instrument'
activesupport (3.2.13) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (3.2.13) lib/active_support/notifications.rb:123:in `instrument'
actionpack (3.2.13) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.2.13) lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
activerecord (3.2.13) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.2.13) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.2.13) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.2.13) lib/action_controller/metal.rb:203:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.2.13) lib/action_controller/metal.rb:246:in `block in action'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:36:in `call'
journey (1.0.4) lib/journey/router.rb:68:in `block in call'
journey (1.0.4) lib/journey/router.rb:56:in `each'
journey (1.0.4) lib/journey/router.rb:56:in `call'
actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
warden (1.2.3) lib/warden/manager.rb:34:in `catch'
warden (1.2.3) lib/warden/manager.rb:34:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.4.5) lib/rack/etag.rb:23:in `call'
rack (1.4.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
rack (1.4.5) lib/rack/session/abstract/id.rb:210:in `context'
rack (1.4.5) lib/rack/session/abstract/id.rb:205:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/cookies.rb:341:in `call'
activerecord (3.2.13) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.2.13) lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `_run__2801646708740260414__call__1745177411958485085__callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:405:in `__run_callback'
activesupport (3.2.13) lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
activesupport (3.2.13) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.2.13) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/reloader.rb:65:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.13) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.13) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.13) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.5) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.13) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.5) lib/rack/lock.rb:15:in `call'
actionpack (3.2.13) lib/action_dispatch/middleware/static.rb:63:in `call'
railties (3.2.13) lib/rails/engine.rb:479:in `call'
railties (3.2.13) lib/rails/application.rb:223:in `call'
rack (1.4.5) lib/rack/content_length.rb:14:in `call'
railties (3.2.13) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.5) lib/rack/handler/webrick.rb:59:in `service'
Request
Parameters:
{"title"=>"TEST 2 Post"}
app/controllers/posts_controller.rb
class PostsController < ApplicationController
def index
if params[:search]
#posts = Post.find(
:all,
:conditions => ['text LIKE ? or title LIKE ?', "%#{params[:search]}%", "%#{params[:search]}%"], :order => "created_at DESC")
else
#posts = Post.find(:all, :order => "created_at DESC")
end
#posts_by_month = #posts.group_by { |post| post.created_at.strftime("%B %Y") }
#recent_posts = Post.order('created_at DESC').limit(5)
if params[:date]
date = Time.parse(params[:date])
date1 = date.beginning_of_month
date2 = date.end_of_month
range = date1
#posts = Post.find(
:all, :order => "created_at DESC",
:conditions => ["created_at <= ? AND created_at >= ?", date2, date1])
end
end
def show
Rails.logger.debug("My object: #{#comment.inspect}")
title = params[:title]
#post = Post.where('title' => title).first
#comment = Comment.new( :post => #post )
end
End
app/models/post.rb
class Post < ActiveRecord::Base
attr_accessible :image, :text, :title, :image_file_name
has_attached_file :image, :styles => { :thumb => "150x150>", :full => "315x250>" }
has_many :comments, :dependent => :destroy
end
app/controller/comments_controller.rb
class CommentsController < ApplicationController
def create
#comment = Comment.new(params[:comment])
if #comment.save
flash[:notice] = 'Comment was successfully created.'
redirect_to(#comment.post)
else
flash[:notice] = "Error creating comment: #{#comment.errors}"
redirect_to(#comment.post)
end
end
def new
#post = Post.find(params[:post_id])
end
End
app/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
attr_accessible :comment, :email, :name, :website
validates :name,:email, :comment, :presence => true
validates :name, length: 2..20
End
routes.rb
devise_for :admin_users, ActiveAdmin::Devise.config
# This line mounts Spree's routes at the root of your application.
# This means, any requests to URLs such as /products, will go to Spree::ProductsController.
# If you would like to change where this engine is mounted, simply change the :at option to something different.
#
# We ask that you don't use the :as option here, as Spree relies on it being the default of "spree"
mount Spree::Core::Engine, :at => '/products'
root :to => 'pages#index'
get "history" => 'pages#history', :as => :history
get 'about' => 'pages#about', :as => :about
get 'pajama' => 'pages#pajama', :as => :pajama
get 'comfort' => 'pages#comfort', :as => :comfort
get 'contact' => 'pages#contact', :as => :contact
get 'cookbook' => 'pages#cookbook', :as => :cookbook
get 'charity' => 'pages#charity', :as => :charity
get 'retailers' => 'pages#retailers', :as => :retailers
get 'media' => 'pages#media', :as => :media
get 'official-rules' => 'pages#official_rules', :as => :official_rules
get 'terms-privacy' => 'pages#terms_privacy', :as => :terms_privacy
get "posts/archives" => 'posts#show', :as => :archives
match "posts/archives/:year/:month" => "posts#archives", :constraints => { :year => /\d{4}/, :month => /\d{2}/}
post 'messages' => 'messages#create', :as => :messages
resources :posts do
resources :comments
end
ActiveAdmin.routes(self)
End
App/views/show.html.haml
.row-fluid
.comments
%h3 Leave a Reply
/ = #comment.inspect
= form_for #comment do |f|
.row-fluid
= f.hidden_field :post
.row-fluid
= label_tag(:name, "Name", :id => 'name-label')
= f.text_field :name
.row-fluid
= label_tag(:email, "Email", :id => 'email-label')
= f.text_field :email
.row-fluid
= label_tag(:website, "Website", :id => 'website-label')
= f.text_field :website
.row-fluid
= label_tag(:comment, "Comment", :id => 'comment-label')
= f.text_area :comment
.row-fluid.submit
= f.submit("Post Comment", :id => "submit")
You're calling form_for with #comments
22: .comments
23: %h3 Leave a Reply
24: / = #comment.inspect
25: = form_for #comments do |f|
26: .row-fluid
27: = f.hidden_field :post_id
28: .row-fluid
, you have not instantiated it in the controller action
def show
Rails.logger.debug("My object: #{#comment.inspect}")
title = params[:title]
#post = Post.where('title' => title).first
#comment = Comment.new( :post => #post ) end
I'm following a sortable list tutorial in here , but unfortunately the article is bit old (but very useful) and I'm having some issues when try to implement it with
Rails 3.2.x
coffeescript
Jquery
My issue is , view is not passing request to controller and instead gives a routing error
Following is my view
#index.html.erb
<h1>Listing books</h1>
<ul id="books"> <% #books.each do |book| %>
<li class="book<%= book.id %>"><span class="handle">[drag]</span><%= book.name %></li>
<% end %></ul>
<%= link_to 'New book', new_book_path %>
and this is my coffeescript
#books.js.coffee
jQuery ->
$('#books').sortable
axis: 'y'
handle: '.handle'
update: ->
$.post($(this).data('#books'), $(this).sortable('serialize'))
and this is my controller
#books_controller.rb
def sort
#books = Book.all
#books.each do |book|
book.position = params['book'].index(book.id.to_s) + 1
book.save
end
render :nothing => true
end
and this is my routes
#config/routes.rb
resources :books do
collection do
post :sort
end
end
this is the error I'm getting
Started POST "/undefined" for 127.0.0.1 at 2012-11-28 16:13:29 +0530
ActionController::RoutingError (No route matches [POST] "/undefined"):
actionpack (3.2.9) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
railties (3.2.9) lib/rails/rack/logger.rb:32:in `call_app'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `block in call'
activesupport (3.2.9) lib/active_support/tagged_logging.rb:22:in `tagged'
railties (3.2.9) lib/rails/rack/logger.rb:16:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/request_id.rb:22:in `call'
rack (1.4.1) lib/rack/methodoverride.rb:21:in `call'
rack (1.4.1) lib/rack/runtime.rb:17:in `call'
activesupport (3.2.9) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.4.1) lib/rack/lock.rb:15:in `call'
actionpack (3.2.9) lib/action_dispatch/middleware/static.rb:62:in `call'
railties (3.2.9) lib/rails/engine.rb:479:in `call'
railties (3.2.9) lib/rails/application.rb:223:in `call'
rack (1.4.1) lib/rack/content_length.rb:14:in `call'
railties (3.2.9) lib/rails/rack/log_tailer.rb:17:in `call'
rack (1.4.1) lib/rack/handler/webrick.rb:59:in `service'
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/home/sameera/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Rendered /home/sameera/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.9/lib/action_dispatch/middleware/templates/rescues/routing_error.erb within rescues/layout (0.7ms)
Any help will be greatly appreciated,
thanks
I believe $.post requires a url parameter like this:
$.post('/books/sort', $(this).data('#books'), $(this).sortable('serialize'))
I just can't seem to figure this one out...
As far as I know, you have to provide an instance variable to the form_for view helper, but it raises an error when I do that...
For a simple scaffold form_for I get an argument error wrong number of arguments (1 for 0) when supplying the instance of the model on a new action.
The relevan code:
Controller
class AdminMessagesController < ApplicationController
before_filter :authenticate_user!
load_and_authorize_resource
def new
#admin_message = AdminMessage.new
logger.debug instance_variables
respond_to do |format|
format.html # new.html.erb
format.json { render json: #admin_message }
end
end
Controller instance_variables
[:#_routes, :#_action_has_layout, :#_view_context_class, :#_headers, :#_status, :#_request, :#_response, :#_env, :#_prefixes, :#_lookup_context, :#_action_name, :#_response_body, :#_config, :#_params, :#current_user, :#current_ability, :#admin_message, :#_authorized]
Model
class AdminMessage < ActiveRecord::Base
validates_presence_of :subject, :body
end
Roles (CanCan)
class Ability
include CanCan::Ability
def initialize(user)
# Define abilities for the passed in user here. For example:
user ||= User.new # guest user (not logged in)
if user.admin?
can :manage, :all
elsif user
can :manage, [Profile, BackgroundImage], :user_id => user.id
can :manage, Page, :profile => { :user_id => user.id }
can :read, [Profile]
else
can :read, [Profile]
end
New View
- #title = "New Message"
= link_to 'Back', admin_messages_path, class: 'button'
%hr
%h1= #title
= render 'form'
Form View
= form_for #admin_message do |f|
-if #admin_message.errors.any?
#error_explanation
%h2= "#{pluralize(#admin_message.errors.count, "error")} prohibited this admin_message from being saved:"
%ul
- #admin_message.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :subject
= f.text_field :subject
.field
= f.label :body
= f.text_area :body
.field
= f.label :send
= f.check_box :send
.actions
= f.submit 'Save'
Routes
resources :admin_messages
Stack Trace
ArgumentError in Admin_messages#new
Showing /example/app/views/admin_messages/_form.html.haml where line #4 raised:
wrong number of arguments (1 for 0)
Extracted source (around line #4):
1: -# - puts self.public_methods
2: -# - puts self.instance_variables
3:
4: = form_for #admin_message do |f|
5: -if #admin_message.errors.any?
6: #error_explanation
7: %h2= "#{pluralize(#admin_message.errors.count, "error")} prohibited this admin_message from being saved:"
Full Stack Trace
activerecord (3.1.2) lib/active_record/attribute_methods/read.rb:89:in `_send'
activerecord (3.1.2) lib/active_record/attribute_methods/primary_key.rb:8:in `to_key'
actionpack (3.1.2) lib/action_controller/record_identifier.rb:76:in `record_key_for_dom_id'
actionpack (3.1.2) lib/action_controller/record_identifier.rb:57:in `dom_id'
actionpack (3.1.2) lib/action_view/helpers/form_helper.rb:388:in `apply_form_for_options!'
actionpack (3.1.2) lib/action_view/helpers/form_helper.rb:365:in `form_for'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:182:in `form_for_with_haml'
haml (3.1.3) lib/haml/helpers/xss_mods.rb:132:in `form_for_with_haml_xss'
app/views/admin_messages/_form.html.haml:4:in `_app_views_admin_messages__form_html_haml__1654301332507974170_70145208768920'
actionpack (3.1.2) lib/action_view/template.rb:171:in `block in render'
activesupport (3.1.2) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.2) lib/action_view/template.rb:169:in `render'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:256:in `render_partial'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:228:in `block (2 levels) in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:227:in `block in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
actionpack (3.1.2) lib/action_view/renderer/partial_renderer.rb:219:in `render'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:41:in `render_partial'
actionpack (3.1.2) lib/action_view/helpers/rendering_helper.rb:27:in `render'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:11:in `block in render_with_haml'
haml (3.1.3) lib/haml/helpers.rb:90:in `non_haml'
haml (3.1.3) lib/haml/helpers/action_view_mods.rb:11:in `render_with_haml'
app/views/admin_messages/new.html.haml:6:in `_app_views_admin_messages_new_html_haml__1382734216418550338_70145179834340'
actionpack (3.1.2) lib/action_view/template.rb:171:in `block in render'
activesupport (3.1.2) lib/active_support/notifications.rb:55:in `instrument'
actionpack (3.1.2) lib/action_view/template.rb:169:in `render'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:40:in `block (2 levels) in render_template'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:33:in `instrument'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:39:in `block in render_template'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:47:in `render_with_layout'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:38:in `render_template'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:12:in `block in render'
actionpack (3.1.2) lib/action_view/renderer/abstract_renderer.rb:22:in `wrap_formats'
actionpack (3.1.2) lib/action_view/renderer/template_renderer.rb:9:in `render'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:36:in `render_template'
actionpack (3.1.2) lib/action_view/renderer/renderer.rb:17:in `render'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:120:in `_render_template'
actionpack (3.1.2) lib/action_controller/metal/streaming.rb:250:in `_render_template'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:114:in `render_to_body'
actionpack (3.1.2) lib/action_controller/metal/renderers.rb:30:in `render_to_body'
actionpack (3.1.2) lib/action_controller/metal/compatibility.rb:43:in `render_to_body'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:99:in `render'
actionpack (3.1.2) lib/action_controller/metal/rendering.rb:16:in `render'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
activesupport (3.1.2) lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/benchmark.rb:310:in `realtime'
activesupport (3.1.2) lib/active_support/core_ext/benchmark.rb:5:in `ms'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:40:in `block in render'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:78:in `cleanup_view_runtime'
activerecord (3.1.2) lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:39:in `render'
actionpack (3.1.2) lib/action_controller/metal/implicit_render.rb:10:in `default_render'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:268:in `block in retrieve_response_from_mimes'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:195:in `call'
actionpack (3.1.2) lib/action_controller/metal/mime_responds.rb:195:in `respond_to'
app/controllers/admin_messages_controller.rb:33:in `new'
actionpack (3.1.2) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.2) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.2) lib/abstract_controller/callbacks.rb:18:in `block in process_action'
activesupport (3.1.2) lib/active_support/callbacks.rb:434:in `_run__1801240210143518790__process_action__2938188811796736454__callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.2) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `block in instrument'
activesupport (3.1.2) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.2) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.2) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.2) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.2) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (3.1.2) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.2) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.2) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.2) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.2) lib/action_controller/metal.rb:236:in `block in action'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `block in call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `block in recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:82:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.2) lib/action_dispatch/routing/route_set.rb:532:in `call'
sass (3.1.10) lib/sass/plugin/rack.rb:54:in `call'
warden (1.1.0) lib/warden/manager.rb:35:in `block in call'
warden (1.1.0) lib/warden/manager.rb:34:in `catch'
warden (1.1.0) lib/warden/manager.rb:34:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.5) lib/rack/etag.rb:23:in `call'
rack (1.3.5) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.5) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.5) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/cookies.rb:331:in `call'
activerecord (3.1.2) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.1.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.2) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.2) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.5) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.2) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.5) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.5) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.2) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.5) lib/rack/lock.rb:15:in `call'
actionpack (3.1.2) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.2) lib/rails/engine.rb:456:in `call'
rack (1.3.5) lib/rack/content_length.rb:14:in `call'
railties (3.1.2) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.3.5) lib/rack/handler/webrick.rb:59:in `service'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
/Users/victorstan/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Update
If I try to inspect the #admin_message var in the controller #new action the error message changes to indicate and error in the controller instead of the view...
ArgumentError in AdminMessagesController#new
wrong number of arguments (1 for 0)
This happens if I add puts #admin_message.inspect to the controller action new
Moral of the story: Don't use send as a table column name!
I am calling the index action for a class which gives the following error:
Started GET "/images" for 127.0.0.1 at Sun Aug 28 06:14:41 +0200 2011
Processing by ImagesController#index as HTML Completed 500 Internal
Server Error in 1ms
ArgumentError (wrong number of arguments (2 for 0)):
There is nothing in the application trace, meaning that the failure occurs before any of the files that I created for app get processed. The full trace is here:
activesupport (3.0.8) lib/active_support/callbacks.rb:97:in `send'
activesupport (3.0.8) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (3.0.8) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `instrument'
activesupport (3.0.8) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.0.8) lib/active_support/notifications.rb:52:in `instrument'
actionpack (3.0.8) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.0.8) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.0.8) lib/abstract_controller/base.rb:119:in `process'
actionpack (3.0.8) lib/abstract_controller/rendering.rb:41:in `process'
actionpack (3.0.8) lib/action_controller/metal.rb:138:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.0.8) lib/action_controller/metal.rb:178:in `action'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:62:in `dispatch'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:27:in `call'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:148:in `call'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:93:in `recognize'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:82:in `optimized_each'
rack-mount (0.6.14) lib/rack/mount/code_generation.rb:92:in `recognize'
rack-mount (0.6.14) lib/rack/mount/route_set.rb:139:in `call'
actionpack (3.0.8) lib/action_dispatch/routing/route_set.rb:493:in `call'
sass (3.1.7) lib/sass/./sass/plugin/rack.rb:54:in `call'
warden (1.0.5) lib/warden/manager.rb:35:in `call'
warden (1.0.5) lib/warden/manager.rb:34:in `catch'
warden (1.0.5) lib/warden/manager.rb:34:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/head.rb:14:in `call'
rack (1.2.3) lib/rack/methodoverride.rb:24:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/flash.rb:182:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/session/abstract_store.rb:149:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/cookies.rb:302:in `call'
activerecord (3.0.8) lib/active_record/query_cache.rb:32:in `call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/query_cache.rb:28:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:12:in `cache'
activerecord (3.0.8) lib/active_record/query_cache.rb:31:in `call'
activerecord (3.0.8) lib/active_record/connection_adapters/abstract/connection_pool.rb:354:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:46:in `call'
activesupport (3.0.8) lib/active_support/callbacks.rb:419:in `_run_call_callbacks'
actionpack (3.0.8) lib/action_dispatch/middleware/callbacks.rb:44:in `call'
rack (1.2.3) lib/rack/sendfile.rb:107:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.0.8) lib/rails/rack/logger.rb:13:in `call'
rack (1.2.3) lib/rack/runtime.rb:17:in `call'
activesupport (3.0.8) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
rack (1.2.3) lib/rack/lock.rb:11:in `synchronize'
rack (1.2.3) lib/rack/lock.rb:11:in `call'
actionpack (3.0.8) lib/action_dispatch/middleware/static.rb:30:in `call'
railties (3.0.8) lib/rails/application.rb:168:in `call'
railties (3.0.8) lib/rails/application.rb:77:in `send'
railties (3.0.8) lib/rails/application.rb:77:in `method_missing'
railties (3.0.8) lib/rails/rack/log_tailer.rb:14:in `call'
rack (1.2.3) lib/rack/content_length.rb:13:in `call'
rack (1.2.3) lib/rack/handler/webrick.rb:52:in `service'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:162:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:95:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:92:in `each'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:92:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:23:in `start'
/home/jon/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/webrick/server.rb:82:in `start'
rack (1.2.3) lib/rack/handler/webrick.rb:13:in `run'
rack (1.2.3) lib/rack/server.rb:217:in `start'
railties (3.0.8) lib/rails/commands/server.rb:65:in `start'
railties (3.0.8) lib/rails/commands.rb:30
railties (3.0.8) lib/rails/commands.rb:27:in `tap'
railties (3.0.8) lib/rails/commands.rb:27
script/rails:6:in `require'
script/rails:6
Here is the relevant code from lib/active_support/callbacks.rb, which I modified to print out the method arguments
def run_callbacks(kind, *args, &block)
p *args
p &block
p kind
send("_run_#{kind}_callbacks", *args, &block)
end
Here is the output with the above code:
"callback arguments"
:checkout
"callback arguments"
"index"
:process_action
Started GET "/images" for 127.0.0.1 at Sun Aug 28 06:40:37 +0200 2011
Processing by ImagesController#index as HTML Completed 500 Internal
Server Error in 1ms
ArgumentError (wrong number of arguments (2 for 0)):
Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_trace.erb
(1.5ms) Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb
(8.6ms) Rendered
/home/jon/.rvm/gems/ruby-1.8.7-p334/gems/actionpack-3.0.8/lib/action_dispatch/middleware/templates/rescues/diagnostics.erb
within rescues/layout (20.9ms)
Here is the DB schema:
create_table "images", :force => true do |t|
t.string "photo"
t.integer "w"
t.integer "h"
t.integer "eyes"
t.integer "head_top"
t.integer "head_bottom"
t.integer "user_id"
t.string "face_params", :limit => 2000
t.string "smiling"
t.string "facing"
t.string "filename"
t.string "content_type"
t.binary "data", :limit => 16777215
t.datetime "created_at"
t.datetime "updated_at"
end
Here is the relevant controller code:
def index
p "made it to index action--------------------------"
if user_signed_in?
#user = current_user
#selected_image = #user.get_selected_image
#problems = #selected_image ? #selected_image.problems.all : Array.new
#images = #user.images - Array[#selected_image]
#image = #user.image_build
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => #images }
end
else
redirect_to root_path
end
end
All the other controllers seem to work. Other actions for this controller give the same error.
Any ideas?
EDIT: Added Routes.rb as per comment below
Id::Application.routes.draw do
resources :payment_notifications
resources :addresses
resources :orders do
member do
get "select_address_for"
put "set_address_for"
get "complete"
end
end
resources :prints do
member do
post "email"
get "confirm_email"
end
end
resources :images do
member do
put "select"
get "thumb"
get "send"
end
end
resources :docs do
member do
get "image_for"
end
end
devise_for :users
##This will redirect the user after sign-in or sign-up.
##Otherwise is will default to the 'root' route, defined below
#devise_for :users do
# get 'users', :to => 'docs#index', :as => :user_root # Rails 3
#end
resources :admins
resources :assistants
resources :books
resources :links
resources :categories
resources :tips
resources :rules
resources :countries
resources :types
resources :continents
# match ':controller(/:action(/:id(.:format)))'
# match ':controller/:action/:id'
# match ':controller/:action/:id.:format'
# match ':controller/:action.:format'
end
You're redefining the send method in your images controller, which is a base ruby method. Rename it to something else and your problem should disappear.