Rails routes and model woes
- by Chris Maness
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.