Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I was following this railscast to implement a simple solution to deal with static pages:

The specific problem I'm having is getting the update method in my pages controller to work.

My routes file:

Jog::Application.routes.draw do
root :to => 'categories#index'
devise_for :categories
devise_for :users
resources :categories do
  resources :gists
resources :sub_categories, :gists, :pages, except: "show, edit, update, destory" 
get ':id', to: 'pages#show', as: :page 
get ':page/edit', to: 'pages#edit', as: :edit_page 
put ':page', to: 'pages#update', as: :update_page
delete ':page', to: 'pages#destroy', as: :destroy_page  

Here is my model:

class Page < ActiveRecord::Base
attr_accessible :content, :name, :permalink
validates_uniqueness_of :permalink

def to_param

My controller update method:

def update
@page = Page.find_by_permalink!(params[:page])

respond_to do |format|
  if @page.update_attributes(params[:page])
    format.html { redirect_to @page, notice: 'Page was successfully updated.' }
    format.json { head :no_content }
    format.html { render action: "edit" }
    format.json { render json: @page.errors, status: :unprocessable_entity }

My error: undefined method `stringify_keys' for "test":String

I've researched other 'stringify_keys' errors but couldn't find anything similar to this. Thanks for your help.

share|improve this question

In your routing file, change the value from a string to an array of symbols. I don't think it understands what methods you are trying to exclude.

resources :sub_categories, :gists, :pages, except: [:show, :edit, :update, :destroy]

If that isn't it, can you point out the line number that the error is pointing to? where the test variable is being used?

share|improve this answer
That wasn't it because all the other methods are working (I tried it also to make sure). Here is the error line, test is the page name: app/controllers/pages_controller.rb:72:in block in update' app/controllers/pages_controller.rb:71:in update' – Anthony Oct 19 '12 at 23:52
These are the lines being referenced in the update method: respond_to do |format| if @page.update_attributes(params[:page]) – Anthony Oct 20 '12 at 0:39
ah, what about something like this link? so you would change line 71 to something like @page.update_attributes(:page => params[:page]) – jstim Oct 20 '12 at 2:04
I tried that but it leads to another series of errors like: unknown attribute: page – Anthony Oct 20 '12 at 22:19

String_keys error is thrown up when the function is expecting a collection rather than a string or symbol. The :except option in the resources function above expect an array having the name of the actions in the symbol form...

Also tell me where the test variable is used and the line where the error is being raised...

share|improve this answer
Test is the name of the page, I find the pages by their permalink. def update @page = Page.find_by_permalink!(params[:id]) respond_to do |format| if @page.update_attributes(:id => params[:page]) – Anthony Oct 20 '12 at 22:44

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.