I can't figure out how to pass a value from the following object build in 
the controller:

class TimesheetsController < AC
...
  def new
    @timesheet = current_user.timesheets.new
    now = Date.today
    #generating 7 time entries: monday through sunday
    (now.beginning_of_week..now.end_of_week).step { |date| 
@timesheet.time_entries.build(:workdate; date)
  end
end
...

In the Timesheet model I defined accepts_nested_attributes for time_entries 
association:

class Timesheet < AR
  has_many :time_entries, :dependent: :destroy
  accepts_nested_attributes_for :time_entries, reject_if: proc { |attr| 
attr['worktime].blank? }
end

in the Timesheet 'new' page:

<%= form_for @timesheet do |f|%>
  <%= f.label :status%>
  <%= f.text_field :status %>
  <%= fields_for :time_entries do | entry_form| %>
# how to display at this place the needed workdate for every time entry ?
*    <%= entry_form.label, value: ???? %>*
    <%= entry_form.text_field :worktime%> #worked time to be entered here 
as 0.5 or 1 day
  <% end%>
<% end %

Thanks and regards

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/fWDXeID3W4EJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to