Displaying 9 results from an estimated 9 matches for "time_entries".
2013 Mar 30
1
How to use group in nested associations
The below query fails:
Timesheet.joins(:time_entries).select("timesheets.*,
sum(time_entries.worktime) as total").group("timesheets.start_date")
The models have the following relations:
Timesheet < AR
has_many :activities, dependent: :destroy, inverse_of: :timesheet
has_many :time_entries, through: :activities
accepts_...
2013 Mar 25
1
validates presence of foreign key fails in nested form
I''m using accepts_nested_attributes as follows:
class Timesheet < ActiveRecord::Base
attr_accessible :status, :user_id, :start_date, :end_date,
:activities_attributes
has_many :activities, dependent: :destroy
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities, allow_destroy: true
end
class Activity < ActiveRecord::Base
attr_accessible :task_id, :timesheet_id, :time_entries_attributes
validates :task_id, presence: true, uniqueness: { scope: ''timesheet_id''}
belon...
2013 Mar 04
0
fields_for with accepts_nested_attributes: how to pass a value to a label
...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].b...
2013 Mar 04
2
accepts_nested_attributes: undefined method 'association'_attributes
I have 2 models Timesheet and TimeEntry:
class Timesheet < ActiveRecord::Base
attr_accessible :status, :user_id, :time_entries_attributes
has_many :time_entries, dependent: :destroy
accepts_nested_attributes_for :time_entries, :reject_if => proc {
|attributes| attributes[''worktime''].blank? }
end
class TimeEntry < ActiveRecord::Base
attr_accessible :task_id, :timesheet_id, :workdate, :worktim...
2005 Sep 28
0
search engine, select the selected option
...=>"last_name ASC")
@geotags = Geotag.find_all_by_firm_id(firm_id, :order =>"address1 ASC")
@employee_id = params[:employee][:id].blank? ? '''' : params[:employee][:id]
@geotag_id = params[:geotag][:id].blank? ? '''' : params[:geotag][:id]
@time_entries = TimeEntry.find(:all, :conditions =>["time_entries.firm_id =
? AND employee_id like ? and geotag_id like ?", firm_id,
"%#{@employee_id}%", "%#{@geotag_id}%"], :order => "time_entries.start_time
DESC", :include=>[:employee,:geotag])
2006 Sep 20
2
Not receiving form data using form_remote_for
Hi.
I''m having a problem that I am sure there is a simple solution for, but
I can''t see it.
I have the following partial:
<% form_for :time_entry, TimeEntry.new,
:url => hash_for_time_entries_url(:period => @period, :action =>
''new''),
:html => { :id => ''time-entry-form'' } do |f| %>
<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tr>
<td><label for="...
2013 Mar 26
0
nested forms: use validate :some_method works in update mode only
...es_attributes
SUBMITTED = ''Submitted''
APPROUVED = ''Approuved''
REJECTED = ''Rejected''
STATUS_VALUES = [SUBMITTED, APPROUVED, REJECTED]
belongs_to :user
has_many :activities, dependent: :destroy, inverse_of: :timesheet
has_many :time_entries, through: :activities
accepts_nested_attributes_for :activities, allow_destroy: true
validates :user_id, presence: true
validates :status, presence: true, inclusion: {in: STATUS_VALUES}
validate :maximum_worktime_per_day
after_update :check_an_activity_present
after_initializ...
2006 Nov 04
0
Controller don''t receives form parameters using form_remote_for
Hi.
I''m having a problem that I am sure there is a simple solution for, but
I can''t see it.
I have the following partial:
<% form_for :time_entry, TimeEntry.new,
:url => hash_for_time_entries_url(:period => @period, :action => ''new''),
:html => { :id => ''time-entry-form'' } do |f| %>
<table border="0" cellspacing="0" cellpadding="5" width="100%">
<tr>
<td><label for="...
2006 Jan 28
0
calling javascript via "eval(request.resopnseText") help needed.
I have a link_to_remote method:
<%= link_to_remote image_tag("clock_run.gif", :border=>''0''),
:update => @task.id,
:complete=>"eval(request.responseText);",
:url => {:controller => ''time_entries'',
:action => ''punch_in'',
:id => @task} %>
The controller ultimately renders a partial:
render :partial => "partial/punch_out_link"
The partial renders fine, but I''m unable to call any of the javascript
methods insid...