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
my
app development.

The controller I have to explicitly set the action “view” shouldn’t that
be
automatic since I have a view.rhtml file?

for some reason the code I have in the view never get’s displayed. I
have
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
would
be appreciated.

–Post Model–
def self.find_all_by_slug(slug)
Post.find(:all, :conditions => [“slug = ?”, slug])
end

–Controller–
def view
@post = Post.find_all_by_slug(params[:slug])
render_action “view”
end

–Routes–

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”

–view.rhtml–

<% 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
case
the slug “First-Post” is being assigned to id. I am guessing this is all
part of my problems.

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

Processing Base#index (for 68.34.158.137 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/actionpack/lib/action_controller/routing.rb:1250:in
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’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/rails.rb:76:in
process' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:618:inprocess_client’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:617:in
process_client' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:736:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel.rb:720:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:271:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/configurator.rb:270:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:127:in
run' /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/lib/mongrel/command.rb:211:inrun’
/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.0/bin/mongrel_rails:243
/usr/local/bin/mongrel_rails:18

Rendering
/Users/mike/code/mikesrepo/betablog/config/…/vendor/rails/actionpack/lib/action_controller/templates/rescues/layout.rhtml
(404 Page Not Found)

Thanks,

-mike

Hi Mike

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

Darren

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