0

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?

George Panayi
  • 1,768
  • 6
  • 26
  • 42

1 Answers1

0

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
Matzi
  • 13,770
  • 4
  • 33
  • 50
  • Could you be more specific? Or could you copy the source of your model files? For example if you left ou the `belongs_to :event` and `has_many :review` from your moduls, that can be a problem. – Matzi Apr 29 '12 at 09:36
  • i found the problem thanks. i changes the filed of the events_ID on the new page to f.hidden_text – George Panayi Apr 29 '12 at 10:15