Rails3 nomethod error #<ActiveRecord::Relation>

Posted by Dodi on Stack Overflow See other posts from Stack Overflow or by Dodi
Published on 2011-01-16T20:28:58Z Indexed on 2011/01/16 20:53 UTC
Read the original article Hit count: 152

Filed under:

Hi!
I'm writing a static page controller.
I get the menuname in the routes.rb and it's call the static controller show method.

match '/:menuname' => 'static#show'

And static_controller.rb:

@static=Staticpage.where("menuname = ?", params[:menuname])

But if I want print @static.title in the view, I get this error:

undefined method `title' for #

Whats wrong?

the SQL query looks good:

SELECT staticpages.* FROM staticpages WHERE (menuname = 'asd')

© Stack Overflow or respective owner

Related posts about ruby-on-rails