Forum: Ruby on Rails params and attributes confusion. Maybe my routes? I included

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bb71d4877b2f770208509ea5933eaaac?d=identicon&s=25 Michael Steinfeld (Guest)
on 2007-01-24 19:21
(Received via mailing list)
hi all,

I am using Ruby 1.8.4 and Rails 1.2.1 recently updated in the middle of
app development.

The controller I have to explicitly set the action "view" shouldn't that
automatic since I have a view.rhtml file?

for some reason the code I have in the view never get's displayed. I
listed my methods and the error I am getting in my logs. Maybe I am
overseeing something or just flat out doing something wrong. Any help
be appreciated.

--Post Model--
   def self.find_all_by_slug(slug)
     Post.find(:all, :conditions => ["slug = ?", slug])

  def view
    @post = Post.find_all_by_slug(params[:slug])
    render_action "view"


  map.connect "posts/:year/:month/:day",
            :controller => "blog",
            :action => "find_by_date",
            :requirements => { :year => /(19|20)\d\d/,
                                :month => /[01]?\d/,
                                :day => /[0-3]?\d/},
            :day => nil,
            :month => nil,
            :slug => ''

  map.connect "posts/view/:slug"


<% for p in @post %>
<h1><%= p.title %></h1>
<%= p.text_html %>
<% end %>

--log file--

i see that the slug is NULL in the sql query, I don't know why in this
the slug "First-Post" is being assigned to id. I am guessing this is all
part of my problems.

Processing BlogController#view (for at 2007-01-24
  Session ID: 86a14c90a137fe4afb8075799005253c
  Parameters: {"action"=>"view", "id"=>"First-Post",
   [4;35;1mPost Load (0.000531) [0m    [0mSELECT * FROM posts WHERE
(slug =
NULL)  [0m
Rendering statusfileblog/viewlayoutfalseuse_full_pathtrue within
Rendering blog/view
Completed in 0.00552 (181 reqs/sec) | DB: 0.00053 (9%) | 200 OK []

Processing Base#index (for at 2007-01-24 12:53:26) [GET]
  Session ID: 86a14c90a137fe4afb8075799005253c
  Parameters: {}

ActionController::RoutingError (no route found to match
"/images/footer_logo.gif" with {:method=>:get}):
    /vendor/rails/railties/lib/dispatcher.rb:40:in `dispatch'

(404 Page Not Found)

D5ca9a8e0973ac2a1871a53c6e67b0d8?d=identicon&s=25 Darren Evans (darrenevans2)
on 2007-01-25 17:23
Hi Mike

Have you tried using redirect_to instead of render_action (or just
deleting this line)?

This topic is locked and can not be replied to.