Refactoring Rails Routes to still pass testing

I can't get this to pass:

  %w[home help about contact].each do |page|
    get :controller => 'static_pages', :action => page

I was trying to refactor this code:

  get 'static_pages/home'
  get 'static_pages/help'
  get 'static_pages/about'
  get 'static_pages/contact'

Please help.


static_pages = %w(home help about contact).map {|p| p.to_sym}

resources :static_pages, only: static_pages do
  static_pages.each do |page|
    get page, on: :collection


$ rake routes
   home_static_pages GET /static_pages/home(.:format)       static_pages#home
   help_static_pages GET /static_pages/help(.:format)       static_pages#help
   about_static_pages GET /static_pages/about(.:format)     static_pages#about
   contact_static_pages GET /static_pages/contact(.:format) static_pages#contact

use only: static_pages to not generate CRUD routes.

Need Your Help

Sort by average rating between 2 values

mysql sql

I have a table called ranks which stores a 1-7 value and connects it with an item and user id. An item's rating is the average of all ratings it has been given.

Maximum conditions inside if in javascript

javascript if-statement

Is there any maximum limit of conditions for If in Javascript? I am using following method to detect bombs in division "b". But it skips more than 3 or 4 conditions and hence less bombcount than the