small medium large xlarge

21 Mar 2013, 23:34
ron campbell (22 posts)

getting this error when I hit the Add button

uninitialized constant LineItemsController::CurrentCart

Try running rake routes for more information on available routes.

In this chapter, though the scaffold was not told to do it, we jump to the concerns/current_cart.rb, I created the folder, and the file, but it is not recognizing it.

22 Mar 2013, 12:17
Sam Ruby (633 posts)

With Rails 4.0.0.beta1, the directory should already be there. Verify that you are running the right version of Rails using “rails -v” from within the depot directory. Verify that the concerns directory is there using:

ls app/controllers/concerns

If you are using Windows, use the following command instead:

dir app\controllers\concerns
25 Mar 2013, 00:30
Daniel Becker (2 posts)

I’m getting the same thing. “rails -v” shows “Rails 4.0.0.beta1”. “dir app\controllers\concerns” shows that the folder exists with one file, “current_cart.rb”.

Contents of current_cart.rb and line_items_controller.rb match exactly to the source on

The first time I hit “Add to Cart” I get the uninitialized constant error he mentions above. But if I hit back and then “Add to Cart” again, the second (and third, fourth…) time I get:

Unknown action

The action ‘create’ could not be found for LineItemsController. —

I’ve tried all sorts of other things too but can’t get it to work. Originally I had this app set up under Rails 3.2.13 and was getting this error, so I upgraded to 4.0.0.beta1 to try and fix it (and overwrote all necessary files) but still can’t get it working.

26 Mar 2013, 00:52
Daniel Becker (2 posts)

Scratch that, when I started my server back up today I hit a few other Rails 4.0.0.beta1 errors (deprecation warnings etc). Once I dealt with all of those, everything seems to be working as expected. Maybe I was stuck in 3.2.13 or something.

02 Apr 2013, 15:57
Psist Wu (2 posts)

I also encounter this problem

uninitialized constant LineItemsController::CurrentCart

I am using rails 3.2.13 and ruby 1.9.3p0. However, I found this problem can be solved by adding the following line in @depot/config/application.rb@

config.autoload_paths += %W(#{config.root}/app/controllers/concerns)

It seems in rails 3.2.13, @depot/app/controllers/concerns@ is not included in the path list by default, so I solve this problem by adding it manually.

Hope my experience would prove useful to you.

You must be logged in to comment