Hi Colin,
I can't see anything in my controller that indicates I have set
@resource to nil.
When I go directly to the resources form it renders fine and I can add
data about new resources. It's just when trying to render the form as a
partial within the universities/_form view.
Do I need to add something in the 'universities_controller' that gives
@resource a value. Perhaps '@resource = Resource.new'?
Below is the code from the 'universities_controller' so far:
class UniversitiesController < ApplicationController
#insure users are signed in before viewing these pages
before_filter :authenticate
# GET /universities
# GET /universities.xml
def index
@universities = University.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @universities }
end
end
# GET /universities/1
# GET /universities/1.xml
def show
@university = University.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @university }
end
end
# GET /universities/new
# GET /universities/new.xml
def new
@university = University.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @university }
resource = @university.resources.build
end
end
# GET /universities/1/edit
def edit
@university = University.find(params[:id])
end
# POST /universities
# POST /universities.xml
def create
@university = University.new(params[:university])
respond_to do |format|
if @university.save
format.html { redirect_to(@university, :notice => 'University
was successfully created.') }
format.xml { render :xml => @university, :status => :created,
:location => @university }
else
format.html { render :action => "new" }
format.xml { render :xml => @university.errors, :status =>
:unprocessable_entity }
end
end
end
# PUT /universities/1
# PUT /universities/1.xml
def update
@university = University.find(params[:id])
respond_to do |format|
if @university.update_attributes(params[:university])
format.html { redirect_to(@university, :notice => 'University
was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @university.errors, :status =>
:unprocessable_entity }
end
end
end
# DELETE /universities/1
# DELETE /universities/1.xml
def destroy
@university = University.find(params[:id])
@university.destroy
respond_to do |format|
format.html { redirect_to(universities_url) }
format.xml { head :ok }
end
end
end
Thanks,
Jen.
--
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+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.