Re: Getting Started with RESTful Rails

How do you fix the functional test for the Albums after this? I'm not sure what causes those tests to get errors. Maybe the nested routes?

test_should_get_index(AlbumControllerTest):
ActionController::RoutingError: No route matches {:action=>"index", :controller=>"albums"}

Re: Getting Started with RESTful Rails

I know why it fails, but I don't know the proper way to fix it

  def test_should_get_index
    get :index
    assert_response :success
    assert assigns(:albums)
  end

theres no /albums route any more. it needs to be /artists/1/albums

hey, how would i get my /albums route back if i wanted a list of all the albums?

ah, then i'd have to fix the view to not ask for the artist... can of worms

Last edited by pleatherrebel (2007-02-09 17:00:31)

Re: Getting Started with RESTful Rails

woud it be better to do the artist finding stuff this way ?:

def find_artist
  @artist = Artist.find(params[:artist_id)
end

then in the view you can do @artist.id instead of all the params stuff all the time.

and you can do the find_artist in a before_filter!

would you put find_artist in the album controller ?

Re: Getting Started with RESTful Rails

Was running through this tutorial, and ran into a few problems. I got an error message when trying to use script/generate scaffold_resource. That it could not find that generate script. I also had several errors on the page after I tried to make a new album via http://localhost:3000/albums/new.

Re: Getting Started with RESTful Rails

agm_ultimatex wrote:

Was running through this tutorial, and ran into a few problems. I got an error message when trying to use script/generate scaffold_resource. That it could not find that generate script. I also had several errors on the page after I tried to make a new album via http://localhost:3000/albums/new.

I also met this problem with this tutorial, should be update to latest ..

for the rails 2.3.5( which I am using) , it changed back to ./script/general scaffold , not scaffold_resource any more.

and for the nested path, it should be like edit_artist_album_path(params[:artist_id], album), not edit_album_path(params[:artist_id], album).