[Rails] Forms within other object views
I'm sure I'm overlooking something really obvious, but I'm trying to
figure out how to do a form for an object associated with the current
view object.
Specifically, I have an itinerary that has events. When I'm looking at
an itinerary I should be able to add new events. My relationship
between the two is:
class Itinerary < ActiveRecord::Base
has_many :event
end
class Event < ActiveRecord::Base
has_one :itinerary
end
In the itineraries_controller, I have a show method defined like this:
def show
@itinerary = Itinerary.find(params[:id])
@new_event = Event.new
end
However, it is clearly puking on the Event.new, and I'm looking for a
good place to learn about how to work through all of these
associations. If this isn't the place, I'd love a link to where this
is taught.
Thanks in advance.
--
Melih O.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home