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?
Does :event_id
is accessible in your Review modul? Actually that would be better if not, but unless it is, then it won't work.
Try using this instead:
@event = Event.find(params[:id])
@review = @event.build_review
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.