hi there,
i thing i just have a logical problem.

i have following models.

class Area < ActiveRecord::Base
        belongs_to :taskschedule
        belongs_to :service
end

class Service < ActiveRecord::Base
        has_many :taskschedules, :through => :areas
        has_many :areas
end

class Taskschedule < ActiveRecord::Base
        has_many :services, :through => :areas
        has_many :areas
end


Following View

Taskschedule#new
<h2>New Taskschedule</h2>

<%= form_for @taskschedule, :url=>taskschedules_path do |f| %>
        <p>Area: <%= f.text_field :name %></p>
        <% for service in Service.find(:all) %>
                <p><%= check_box_tag :service_ids, service.id,
@taskschedule.services.include?(service), :name =>
'taskschedule[service_ids][]' -%> <%= service.name %></p>


        <% end %>
        <%= submit_tag "Submit" %>
<% end -%>

Taskschedule Controller
class TaskschedulesController < ApplicationController
        def index
                @taskschedules = Taskschedule.find(:all)
        end

        def new
                @taskschedule = Taskschedule.new
                @taskschedule.build.build_area
        end

        def create
                @taskschedule = Taskschedule.new(params[:taskschedule])
                if @taskschedule.save
                        redirect_to taskschedules_path
                end
        end

        def edit
                @taskschedule = Taskschedule.find(params[:id])
        end

        def update
                @taskschedule = Taskschedule.find(params[:id])
                if @taskschedule.update_attributes(params[:taskschedule])
                        redirect_to taskschedules_path
                else
                        render 'edit'
                end
        end

end

i have a text_field in areas that i want to be able to use in the
taskschedule#new view?
Thanks for any help.
ed





-- 
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.

Reply via email to