Michael Steinfeld
2007-Jan-24 18:07 UTC
params and attributes confusion. Maybe my routes? I included my code and log snips.
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 %> <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 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:in `recognize'' /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:in `process'' /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:in `process_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:in `run'' /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:in `run'' /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:in `run'' /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:in `run'' /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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Darren Evans
2007-Jan-25 16:23 UTC
Re: params and attributes confusion. Maybe my routes? I incl
Hi Mike Have you tried using redirect_to instead of render_action (or just deleting this line)? Darren -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---