# Question from Super-Novice regarding Permalink

**URL:** <https://www.ruby-forum.com/t/question-from-super-novice-regarding-permalink/91583>\
**Category:** Rails\
**Created:** [April 10, 2007, 6:30pm UTC](https://www.ruby-forum.com/t/question-from-super-novice-regarding-permalink/91583 "2007-04-10T18:30:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [April 10, 2007, 6:30pm UTC](https://www.ruby-forum.com/t/question-from-super-novice-regarding-permalink/91583/1 "2007-04-10T18:30:38Z")

</div>

Hi-

I am two weeks new to Ruby on Rails and I am working through the  
SitePoint book. Specifically Chapter 7. I am trying to do the  
permalink example for a story posting in their example, but I am  
getting an undefined method error. I have checked all the textmate  
files, and they match. And I have gone into the ruby console to pull  
the story up, find the name, but when i write:  
s.update\_attribute :permalink, ‘my-shiny-weblog’. I get a the  
following:

> > s.update\_attribute :permalink, ‘my-shiny-weblog’  
> > NoMethodError: undefined method `permalink=' for #<Story:0x328d3c4> from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/ active_record/base.rb:1858:in `method\_missing’  
> > from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/  
> > active\_record/validations.rb:772:in `send' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/ active_record/validations.rb:772:in `update\_attribute’  
> > from (irb):25

==========

When I run a full trace on  
[http://localhost:3000/story/show/my-shiny-weblog](http://localhost:3000/story/show/my-shiny-weblog),  
I get this:

NoMethodError in StoryController#show

undefined method `find\_by\_permalink’ for Story:Class  
RAILS\_ROOT: script/…/config/…

Application Trace | Framework Trace | Full Trace  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.15.2/lib/  
active\_record/base.rb:1197:in `method_missing' app/controllers/story_controller.rb:15:in `show’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:1095:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:1095:in `perform\_action\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:632:in `call_filter' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/filters.rb:619:in `perform\_action\_without\_benchmark’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/benchmarking.rb:66:in  
`perform_action_without_rescue' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/rescue.rb:83:in `perform\_action’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:430:in `send' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/base.rb:430:in `process\_without\_filters’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/filters.rb:624:in  
`process_without_session_management_support' /usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/ action_controller/session_management.rb:114:in `process’  
/usr/local/lib/ruby/gems/1.8/gems/actionpack-1.13.2/lib/  
action\_controller/base.rb:330:in `process' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/dispatcher.rb:41:in `dispatch’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick\_server.rb:  
113:in `handle_dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick_server.rb: 79:in `service’  
/usr/local/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' /usr/local/lib/ruby/1.8/webrick/httpserver.rb:65:in `run’  
/usr/local/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' /usr/local/lib/ruby/1.8/webrick/server.rb:95:in `start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:92:in `each' /usr/local/lib/ruby/1.8/webrick/server.rb:92:in `start’  
/usr/local/lib/ruby/1.8/webrick/server.rb:23:in `start' /usr/local/lib/ruby/1.8/webrick/server.rb:82:in `start’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/webrick\_server.rb:  
63:in `dispatch' /usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/servers/ webrick.rb:59 /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem\_original\_require’  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`require' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:495:in `require’  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/  
active\_support/dependencies.rb:342:in `new_constants_in' /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/ active_support/dependencies.rb:495:in `require’  
/usr/local/lib/ruby/gems/1.8/gems/rails-1.2.2/lib/commands/server.rb:  
39  
/usr/local/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in  
`gem_original_require' /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’  
script/server:3

---

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [April 10, 2007, 6:52pm UTC](https://www.ruby-forum.com/t/question-from-super-novice-regarding-permalink/91583/2 "2007-04-10T18:52:40Z")

</div>

On 4/10/07, Zak [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> following:
> 
> > >
> 
> ==========
> 
> When I run a full trace on [http://localhost:3000/story/show/my-shiny-weblog](http://localhost:3000/story/show/my-shiny-weblog),  
> I get this:
> 
> NoMethodError in StoryController#show
> 
> undefined method `find\_by\_permalink’ for Story:Class  
> RAILS\_ROOT: script/…/config/…

First step in debugging this is to look at the error message. Your  
controller called Story.find\_by\_permalink, and it blew up. Normally,  
you’d just realize you either misspelled the method name, or are  
calling it on the wrong object. Or, maybe you got drunk and deleted  
it from your class 🙂

However, ActiveRecord has “Dynamic attribute-based finders” (read  
about them at  
[http://rails.rubyonrails.org/classes/ActiveRecord/Base.html](http://rails.rubyonrails.org/classes/ActiveRecord/Base.html)).  
Basically, you can call Story.find\_by\_permalink as a shortcut for  
Story.find(:first, :conditions =\> {:permalink =\> ‘foo’}). So, if THIS  
is failing, it probably means you have no permalink attribute in the  
model’s database table. Check and make sure it exists, you’re  
accessing the right DB, migrations have been run, etc etc.

The first update\_attribute error supports this assumption as well.

–  
Rick O.  
[http://lighthouseapp.com](http://lighthouseapp.com)  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![zak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/8e7dd6/32.png) [@zak](https://www.ruby-forum.com/u/zak)\
**Post date:** [April 10, 2007, 7:14pm UTC](https://www.ruby-forum.com/t/question-from-super-novice-regarding-permalink/91583/3 "2007-04-10T19:14:41Z")

</div>

Thnx. If my db only has the columns (schema\_info, stories, and votes)  
should I add a column called “permalink”? Or should the column be  
another name?

-Zak
