Rails routes and model woes

Posted by Chris Maness on Stack Overflow See other posts from Stack Overflow or by Chris Maness
Published on 2010-06-17T16:30:33Z Indexed on 2010/06/17 16:33 UTC
Read the original article Hit count: 254

Filed under:
|

I'm a little new to rails sorry if this seems basic

Alright so here's the deal I'm creating an application that will have many users and all the users have many songs. However when I try to create a song I get the following error:No action responded to 1. Actions: create and new and my browser is at the url: http://0.0.0.0:3000/users/1/songs which is not the correct route it should have redirected to songs/create

Here is my controller code:

class SongsController < ApplicationController

  def index
    @user = current_user
    @songs = @user.songs
  end

  def new 
 @user = current_user
 @song = @user.songs.build
  end

  def create
 @user = current_user
 @song = @user.songs.build(params[:song])
 if @song.save
  redirect_to user_song_url(@user, @song)
 else
  render :action => "new"
 end
  end

end

If anyone can help I would greatly appreciate it.

© Stack Overflow or respective owner

Related posts about ruby

Related posts about routes