fydelio
fydelio

Reputation: 953

Uninistialized Controller in Rails

I'm fairly new to rails and I am at a point, where I'd be happy for some help. My application can't find the controller it should (error message: Uninistialized Controller)

I have the following routes

get 'order/shipped/:id', to: 'orderstats#shipped', as: :order_shipped
get 'order/paid/:id', to: 'orderstats#paid', as: :order_paid
get 'order/status/:id/open', to: 'orderstats#shipping_status_open!', as: :status_change_open
get 'order/status/:id/complete', to: 'orderstats#shipping_status_complete!', as: :status_change_complete

Further I've created the following Controller in the app/controllers folder with the name order_stats_controller.rb

class OrderStatsController < ApplicationController
...
end

But each time I run the application I get the following message: uninitialized constant OrderstatsController. What am I missing?

Changing the to: 'OrderStatus#shipped' didn't work. When firing up Rails I'll be getting the message:

.../.rvm/gems/ruby-2.3.1/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/mapper.rb:313:in `block (2 levels) in check_controller_and_action': 'OrderStats' is not a supported controller name. This can lead to potential routing problems. See http://guides.rubyonrails.org/routing.html#specifying-a-controller-to-use (ArgumentError)

Upvotes: 0

Views: 64

Answers (1)

Anand
Anand

Reputation: 6531

your controller name should be order_stats (name of file)in routes

get 'order/shipped/:id', to: 'order_stats#shipped', as: :order_shipped
get 'order/paid/:id', to: 'order_stats#paid', as: :order_paid
get 'order/status/:id/open', to: 'order_stats#shipping_status_open!', as: :status_change_open
get 'order/status/:id/complete', to: 'order_stats#shipping_status_complete!', as: :status_change_complete

Upvotes: 1

Related Questions