Hi I have two tables Projects and Tasks each with their own respective Ms Vs and Cs
In my add task view I want to have a drop down box with Project names. I cant get it to work though. Ive read posts here, the api and i dotn really understand what the use of the first two arguments are? Are they used as tags for styling or is it the address of where the selected value is stored in params? (im using an old version of 1.2.3 while i complete a book but dont think this is related to this problem)
Here is the add view
<% form_for :task do |form| %> <fieldset> <legend>Task Details</legend> <label for="title">Title:</label> <%= form.text_field :title %> <label for="description">Description:</label> <%= form.text_field :description %> <label for="priority">Priority:</label> <%= form.text_field :priority %> <label for="completed">Completed:</label> <%= form.check_box :priority %> <label for="project"> Project </label> <%= form.collection_select(:task, :project_id, Project.find(:all), :id, :get_title) %> <%= submit_tag "Add Task!", :class => "submit" %> </fieldset> <% end %>
here is my project model
class Project < ActiveRecord::Base has_many :tasks validates_presence_of :title
#returns title def get_title self.title end
end
here is the task model
class Task < ActiveRecord::Base belongs_to :project TITLE_WIDTH = 30 validates_presence_of :title
end
can anyone spot a mistake or help me out.