Created
November 4, 2010 00:37
-
-
Save sideshowcoder/661962 to your computer and use it in GitHub Desktop.
ender :action => "new" does not call method new so all variables must be set in create
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def new | |
@a = A.new | |
@b = @a.b | |
end | |
def create | |
@a = A.new(params[:a]) | |
@a.b_id = B.find(params[:b_id]).id | |
@b = @a.b | |
if @a.save | |
redirect_to(@b) | |
else | |
render :action => "new" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment