Jump to content

The ultimate community for Ruby on Rails developers.


Unknown action

  • Please log in to reply
1 reply to this topic

#1 JanI



  • Members
  • 2 posts

Posted 12 March 2014 - 10:41 AM

Dear Ruby Community,


yesterday I was trying to code a button which allows me to define/enter the number of periods for an linear optimization problem. The button was intended to split the entered number into a string (e.g. enter 5 and ruby automatically knows that we're having periods 1,2,3,4, and 5) and write it in the "periods" model. However, as soon as I click the button, I receive an "unknown action" exception, although I definately have it in the respective controller. Here's the code:


def Anzahl_uebernehmen                  <- Translation: accept_amount

   # request, whether the number of elements (periods) equals the data in the table 
      @aktuelle_Anzahl = ProductA.count
      while  @aktuelle_Anzahl != Period.first.period_nr
        if @aktuelle_Anzahl > Period.first.period_nr
          @nrlast = ProductA.last.period

      #Anfang des Erstellens neuer Elemente, wenn aktuelle Anzahl kleiner als Feldvorgabe ist
        idnew = ProductA.create!(period: ProductA.count + 1, demand: 0, opening_inventory: 0, storage_cost: 0, production_coefficient_labour: 0, production_coefficient_machines: 0).id

      #Ende des Erstellens neuer Elemente, wenn aktuelle_Anzahl kleiern als Feldvorgabe ist
        @aktuelle_Anzahl = ProductA.count
   @product_as = ProductA.all
   render :template => "product_as/index"


Here's my respective code from the route.rb:


 root to: 'static_pages#home'

  match '/signup',  to: 'users#new'
  match '/signin',  to: 'sessions#new'
  match '/signout', to: 'sessions#destroy', via: :delete

  match '/help', to: 'static_pages#help'
  match '/about', to: 'static_pages#about'
  match '/contact', to: 'static_pages#contact'

  match 'results_product_as/delete_solution', :to => 'results_product_as#delete_solution'
  match 'results_product_as/optimize', :to => 'results_product_as#optimize'
  match 'periods/Anzahl_uebernehmen', :to =>'periods#Anzahl_uebernehmen'



#2 himanshu339



  • Members
  • 9 posts

Posted 17 March 2014 - 08:01 AM

You can make following changes to make this work:

  1. action name must start with lowercase letter.
  2. make sure that action in controller is public. It should not be written under private/protected keywords.

I hope this helps!

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users