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