I keep having this problem with map.resources.
Basically, I generated a model called Blog, with 3 fields in it.
I then added a controller: ruby script/generate controller Blog index
I did rake db:migrate
I modified the index portion, so now I can visit my site at: localhost:3000/blog
i then made an application.html.erb template. I wanted to be able to view a blog entry like so: localhost:3000/blog/1.
I added a new file to my blog folder in app/views called "show.html.erb".
I did add all of the DB scripting, I know thats right.
I then added this to my routing file:
map.resources :blog
I now get an error: blog_url failed to generate from {:action=>"show", :controller=>"blog"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["blog", :id] - are they all satisfied?
when I visit localhost:3000/blog.
If I change map.resources :blog to map.resource :blog it works, but I would have to view a blog entry like so: localhost:3000/blog/show/1
What am I doing wrong.
---------------------------
Edit: in my application.erb.html I was using blog_path, and that was causing the error above. Now that map.resources works, my show still does not. When I go to localhost:3000/blog/1, it now displays:
Unknown action
No action responded to 1. Actions: index and show
here is my controller code:
Thanks.class BlogController < ApplicationController
def index
@section = "Jaikob Create - Home" # section we are in.
@blogs = Blog.find :all,rder => 'created_at DESC', :limit => '0,10' # List all blog entries Limit 10.
end
def show
@blog = Blog.find(params[:id])
@section = @blog.title
end
end


rder => 'created_at DESC', :limit => '0,10' # List all blog entries Limit 10.

Bookmarks