Monday, April 30, 2012

How to store the id from the one table to another in ruby on rails 2

Hello i'm trying to make a simple review function on ruby on rails. i have create a scaffold with the following attributes




event_id:integer name:string review_text:text no_starts:integer




Then i made this change on the show (view) of my event




:review, :action => :new, :id => @event.id %>


now i configured the routes fine and on the controller of the review i made this changes.
on the new i have added this




@review = Review.new(:event_id => params[:id])
and removed this
@review = Review.new




Then the page loads the event id it cites on the page but when i'm trying to save it is not stored. i thing the problem is when i move from the new method to create it doesnt transfer the id of the event thats why but i'm still what i'm doing wrong in the new?





No comments:

Post a Comment