I created controllers of project and task and appropraite html pages for
them and created two partials of fields and tasks and having link in
fields partial, when i call it it is throwing RJS error, please find the
code below and mention a solution for geting text box dynamically....

My Html page

<% form_for :project, :url => projects_path do |f| %>
  <%= render :partial => 'fields', :locals => { :f => f } %>
  <p><%= submit_tag "Create Project" %></p>
<% end %>


Fields Partial


<%= error_messages_for :project %>
<p>
  Name: <%= f.text_field :name %>
</p>
<div id="tasks">
  <%= render :partial => 'task', :collection => @project.tasks %>
</div>
<p>
<%= link_to_function('Add') do |page| page.visual_effect :highlight,
'tasks' end%>
</p>



Task partial

<% @task = task %>
<%= error_messages_for :task %>

<div class="task">
  <% fields_for_task(task) do |task_form| %>
  <p>
    Task: <%= task_form.text_field :name %>
    <%= link_to_function "remove", "$(this).up('.task').remove()" %>
  </p>
  <% end %>
</div>


My controller

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 rubyonrails-t...@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.

Reply via email to