Hi,
I inserted required java script files in my html page that is
new.html.erb
Plaese verify the file...
#Projects/new.html.erb
<% form_for :project, :url => projects_path do |f| %>
<p>
Name: <%= f.text_field :name %>
</p>
<div id="tasks">
<%= render :partial => 'task', :collection => @project.tasks %>
</div>
<%= link_to_function "Add a Task" do |page|
page.insert_html:bottom, :tasks, :partial => 'task', :object =>
Task.new
end %>
<p><%= submit_tag "Create Project" %></p>
<% end %>
#My controller i.e projects
class ProjectsController < ApplicationController
def index
@projects = Project.find(:all)
end
def new
@project = Project.new
@project.tasks.build
end
def create
@project = Project.new(params[:project])
if @project.save
flash[:notice] = "Successfully created project and tasks."
redirect_to projects_path
else
render :action => 'new'
end
end
def edit
@project = Project.find(params[:id])
end
def update
params[:project][:existing_task_attributes] ||= {}
@project = Project.find(params[:id])
if @project.update_attributes(params[:project])
flash[:notice] = "Successfully updated project and tasks."
redirect_to project_path(@project)
else
render :action => 'edit'
end
end
end
--
Posted via http://www.ruby-forum.com/.
--
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 [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.