Displaying 20 results from an estimated 600 matches similar to: "Newbie - list based on joined query?"
2006 Mar 21
3
Newbie - ActiveRecord relationships
So I''ve worked through Agile Web Development with Rails and I''m now
trying my first little app to get into the swing of things. Its a task
tracking app where people can create tasks and assign them to others,
and also log time against the tasks.
I''m having trouble working out the model relationships. This is what
I''ve got so far, but its not right as
2006 May 01
3
Make a checkbox checked based on a condition?
I have a series of checkboxes in a form generated as follows:
<% for user in @active_users %>
<p><%= user.firstname + " " + user.surname%>
<%= check_box ''assigned_tasks'', ''user_id'', {:index => user.id},
user.id, nil %></p>
<% end %>
I''d like to have one of them selected when user.id is equal to the
2006 Apr 28
5
Newbie: using date-picker
Finally found a nice date chooser script
(http://projects.exactlyoneturtle.com/date_picker), but am a little
confused how to implement it.
So I put this where I need the date picker:
<a id="_name_link" href="#"
onclick="DatePicker.toggleDatePicker(''name'')"
class="demo_link">[ choose date ]</a>
<div
2006 Apr 30
4
Adding values from a db the rails way?
I have a log table which has a column recording the number of hours
worked on a task. So there''ll be multiple lines for a particular task.
I want to retrieve the total number of hours worked on a task, so that I
can include the information when one views the task details.
I can write a sql query to do this easily enough, like "SELECT
SUM(hours) AS total FROM tasklog WHERE
2008 Mar 19
2
problem with worker status
Hi,
I have a page were users can start jobs that may take several hours to
run. BackgrounDrb is perfect for me and seems to be working well most of
the time but some times I have the following problem:
My worker is set up like this:
class UploadWorker < BackgrounDRb::MetaWorker
set_worker_name :upload_worker
set_no_auto_load(true)
def create(args = nil )
file = args[:file]
2006 Jul 31
2
ambiguous column name in has_many :through
In my application model I have three classes: Accounts, Projects, and Items
class Accounts < ActiveRecord::Base
has_many :items, :through => :projects, :source => :items
has_many :late_items, :class_name => ''Item'', :through => :projects,
:conditions => [''due_on < ?'', Time.now], :source => :items
end
class Projects <
2008 Apr 23
0
self referential (n-n relationship) belongs many controller
Hi all,
I ve some troubles in my small acpplication (only 2 tables).
I want to follow up tasks but these tasks are linked to others tasks.
So I ve tried to do store the nn relationship in other table called
links
1st table : tasks
columns : id | infos neutral... (as title, description etc ...)
-----------------------------------------------------------------------------------
model :
class
2008 May 05
2
Deploying to a staging server using Capistrano: how to start up BackgrounDRb?
Hi.
I am using BackgrounDRb to process thumbnails and upload to S3 -
things are hunky-dory in development (thumbs are generated, these are
uploaded to S3, the metadata is saved to trhe DB, and I get a nice
status page updated by periodic calls via ask_status), but when I
tried to deploy to our staging server and stop/start BackgrounDRb via
Capistrano, things blew up - well, not exactly,
2006 May 23
1
Re: Wierd pagination problem - Unknown options:
> Unfortunately I still get the same error. Here is my code now (the
> commented line works):
>
> def list
> @upload_pages, @uploads = paginate(:uploads, :per_page =>
> 20, :order
> => ''id'')
> # @upload_pages, @uploads = paginate(:uploads, :per_page => 20)
> end
You may have an older version, try using the order_by clause
2006 Mar 31
2
Silly question
Hi there,
I know this is be a very minor issue, but considering
@users = User.find :all, :order => ''name''
_AND_
@user_pages, @users = paginate :user, :order_by => ''name''
by simplicity, shouldn''t the symbols :order and :order_by
be the same or both to both cases ?
I stumbled on them a couple of times yet :)
Thanks,
Andre
--
2006 Jul 16
4
Calculations across multiple tables
I have a time tracking app where (pseudo-code)
Client has_many Task has_many TimeRecord
TimeRecord
start_at, :datetime
end_at, :datetime
What I''m trying to do (and I have done using find_by_sql in the past) is get
a sum of the timespan given by ended_at - begun_at for each client.
Is it naive to imagine that AR''s calculations will span relations to provide
a grouped
2006 Apr 10
0
Rails form error message oddness...
To get error messages for my form to show up I have to repeat myself in
the controller so that the render of the view including error messages
show up.
-------------------------
My Controller:
-------------------------
class ClientsController < ApplicationController
#---- index --------------------------------
def index
list
render :action => ''list''
end
2005 Nov 20
1
mySQL 5.0 upgrade - incompatible DateTime format?
I''ve upgraded to mySQL 5.0, and it''s gone pretty smoothly except that on
DateTime.now doesn''t seem to return a value that mySQL likes any more,
as seen in the following exception:
Incorrect datetime value: ''2005-11-20T15:33:12-0800'' for column ''logged_at'' at row 1: UPDATE notes SET `due_on` = ''2005-11-20'',
2006 Apr 26
8
Newbie: Hide div I''ve just show using link_to_remote?
I''m using link_to_remote to show details for an item that''s clicked. I''d
like to hide the div with the next click, or alternatively have a "Hide"
link within my div.
What is the best way to accomplish this?
Here''s my existing code:
<% for task in @mytasks %>
<div class="rowFormat">
<%= link_to_remote(
2006 Aug 07
4
Problem with Pagination
Hi Guys,
I am trying to paginate the results from a search. When I use actual
constants in the search conditions, it works fine:
def query
@k2_result_pages, @k2_results = paginate (:k2_results,
:conditions => [''e_date >= ? AND
e_date <= ?'', ''2006-07-12'', ''2006-08-12''],
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
2018 Oct 16
2
high cpu load with share_conflict on browsing and opening files
Hello,
I have a server running samba version 4.7.1 on centos 7.5
1) A series of operations by a windows 10 (up to date) pc client consisting
of searching (or browsing)/opening/modifying/closing a (each time
different) file multiple times on a samba share containing many files (more
than 11000) goes fast for a while.
2) Then the same operation (or just the searching or opening) of the same
user
2012 Sep 13
3
Creating a link_to from a collection_select
I want to be able to change one attribute of a link_to to be what is the
current selection of the collection_select. And needless to say I can''t
quite figure it out.
app/views/tasks/show.html.erb
Who would you like to assign this task to?<br />
<%= link_to ''Myself'', :controller => ''task_queues'', :task_id => @task.id,
:action =>
2006 Apr 27
0
last stupid question today
(well, from me anyway. I promise)
Trying to follow the "Self-referential Many-to-Many Relationships" recipe
from the Rails Recipes book.
This is what I''m doing: Tasks can have a predecessor relationship with each
other. My Task class has this:
has_and_belongs_to_many :predecessors,
:class_name => "Task",
:join_table => "predecessor",
2008 Feb 19
0
Issue with Observers and has_one association...
Hey Guys,
I''m getting a peculiar bug working with Observers and has_one
associations. When a has_one association is invoked by an Observer it
always returns null. I looked in the development.log file and the SQL
for the has_one association isn''t even being executed. On the other
hand, when I replace the has_one association with just a hand crafted
method, it does get called