Params and attributes confusion. Maybe my routes? I included

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 %>

<%= p.title %>

<%= 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}):
recognize_path' /vendor/rails/actionpack/lib/action_controller/routing.rb:1240:inrecognize’
/vendor/rails/railties/lib/dispatcher.rb:40:in dispatch' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:78:inprocess’
process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:618:inprocess_client’
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:inrun’
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:inrun’
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:inrun’
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/command.rb:211:inrun’

(404 Page Not Found)



Hi Mike

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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs