similar to: 3 models, joining and nested queries

Displaying 20 results from an estimated 800 matches similar to: "3 models, joining and nested queries"

2013 Jan 29
2
Count entries in postgresql grouped by date
Hi! I have a table with visits with a visited_at: attribute which is a datetime field. They seem to be stored as UTC. Now I want to count all visits each day and return something like: { 2013-01-01: 8, 2013-01-02: 4, 2013-01-07: 9, ... } So, I did it like this which kind of works...: def self.total_grouped_by_day(start_date, end_date) visits = where(visited_at:
2010 Jun 08
2
type conversion with apply or not
Folks, i thought it should be straightforward but after a few hours poking around, I decided it's best to post my question on this list. I have a data frame consisting of a (large) number of date columns, which are read in from a csv file as character string. I want to convert them to Date type. Following is an example, where the first column is of integer type, while the rest are type
2008 Jun 24
10
Question on passing arguments inside a view.
I''m running into an issue undefined local variable or method `directoryid'' for #<EditorialsController:0x23f1bf8> I have two Models on a legacy database and only one controller called editorials with two actions index and display. I''m trying to pass in a parameter from the results of my search and getting the above error. Example: two tables one is editorial the
2006 Jun 18
4
uninitialized constant Datetime
I am building an application and I have generated the scaffold for a product. In the list method I include something like my_date = Datetime.now and the result I get from the webrick is an error uninitialized constant Datetime Do I have to add a line with a require? I am new at ruby on rails thanks in advance -- Posted via http://www.ruby-forum.com/.
2004 Nov 08
2
Matrix Indexing
Hi, I have the following problem. In a csv file I have under column A, the date, and column B, the prices. Thus, for example, the file looks something like this -> 1/31/04 2.5 2/1/04 2.6 ... 4/12/04 3.5 Basically, I use the function inputframe = read.csv( ) which reads the csv file into the inputframe. My question is, how can I make a function that has, as inputs,
2011 Nov 05
3
List of user installed packages
Hello, I am going to install the new version of R 2.14.1. After the installation, I want to copy my installed packages to the new library. But since over time I forgot which ones I installed I want to get a list of all the packages I installed among the packages installed initially by the R-installer. Is this possible? Cem Cem Girit, PhD Biopticon Corporation 182
2008 Nov 11
1
Every other week recurring event
I have the code for computing a weekly event: (start_date..end_date).select{|d| d.wday == wday} but I am wondering if anyone has any ideas for using this to figure out a recurring event for every other week. Is it possible to somehow specify every other within the .select method? Any other implementation ideas? --~--~---------~--~----~------------~-------~--~----~ You received this message
2007 Jul 08
2
datetime_select, is creating an instance of the Time class
Hello It seems that datetime_select, is creating an instance of the Time class. Why would that be? I found this while building a site where people can create vigils (prayer vigils, peace vigils, etc). When I added a validation method that compared start_date to created_at, it generated the error: ArgumentError (comparison of Time with DateTime failed): I was able to put a breakpoint in the
2008 Jan 16
4
How to test if one range of dates overlaps another?
Hi all, I have a situation with a recurring billing application where I need to test if one range of dates "overlaps" another range of dates. Does anyone know a rails find or mysql select statement that will test for this? Here are the details: * Recurringcharge items have a start_date and an end_date that represent the period of time that the charges should occur. * Statement items
2006 Mar 04
5
has_many and belongs_to example?
Hi! If i have 2 tables i.e. product and images and product has_many images, image belongs_to product - how to create _form.rhtml, new/create and edit/update methods in product controller, so in a single form i can add one product and MANY (let''s assume for now that this number is fixed) images for this product? Pleeeeease help me :) -- Posted via http://www.ruby-forum.com/.
2011 Mar 22
2
adding vertical segments to an xyplot in lattice
I have a dataframe that looks like this: > str(chr) 'data.frame': 84 obs. of 7 variables: $ county: Factor w/ 3 levels "Broome","Nassau",..: 3 3 3 3 3 3 3 3 3 3 ... $ item : Factor w/ 28 levels "Access to healthy foods",..: 21 19 20 18 16 3 2 6 17 8 ... $ value : num 8644 15 3.5 3.9 7.7 ... $ low : num 7897 9 2.5 2.6 7 ... $ high : num 9390
2011 Oct 17
3
Extracting results from a function output
Hello, I am having hard time obtaining a value from a function. "fit" is a survival function that produces some results, such as "median", "confidence intervals" etc. But str() function does not list these values. How can I extract these to be able use them? For example, I need "median" value for the group DrugA which is 48. "Print" function does
2011 Aug 26
2
how to convert Date to this json format
Hi I have to create a json date like {"startDate":"\/Date(1291145744713-0700)\/","endDate":"\/Date(1293824144713-0700)\/"} This is just an example. My case startdate = Time.now-2.day enddate = Time.now I dont know how to convert this to the above format. Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You
2009 Jun 07
17
ActiveRecord Classes
I''m having a little trouble with understanding how to work out the schematic for some of my classes using ActiveRecord when a file is in my lib directory: Brief example: Here''s the outline of the files in use: ....app ........controllers ............application_controller.rb ............rushing_offenses_controller.rb ........models ............rushing_offense.rb ....lib
2010 Oct 13
10
Rails 2.3.8 - What happens to a datetime field between a form being submitted and the controller receiving the params
I currently have a model that simply contains one datetime field: class CreateElectricityReadings < ActiveRecord::Migration def self.up create_table :clocks do |t| t.datetime :time_keeper t.timestamps end end def self.down drop_table :clocks end end If I enter the date string "13/10/2010" into this field its showing up in the controller as
2007 May 01
5
duplicate key violates unique constraint
I''ve run into an interesting issue. When setting up a table with data from a file (I''m doing this in a block). I find that I can''t create separate entries manually after the import. It complains about a duplicate primary key. I''ve tried Schedule.id += 1 but id= either isn''t defined or accessible in the class Here is my code:
2006 Jun 14
4
Using now() to determine what should be displayed
I''m trying to create a paginated list that will take note of the "end_date" field in my table. This is what I have: @post_pages, @posts = paginate(:posts, :per_page => 10, :order_by => ''end_date'') in the controller. And for the view: <h1>Posts ending soon</h1> <ul><% for post in @posts do %> <strong>Post Title:
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
2006 Feb 24
2
Model Inheritance?
Hello, I need some help with designing a model I have in mind. I''m not sure what the best way to do it in Ruby/Rails is, or even if what I''m thinking is possible. Basically, I have a system where I want to treat everything as a "message." A Message is a basic model object with a title and message_text. It can stand on it''s own, or it can be
2006 Jun 25
1
Sorting ferret results by column
I have the acts_as_ferret plugin installed. Everything searches great, but I would like to limit the results (i.e. by ''end_date'') and sort them (by ''end_date''). ''end_date'' is a valid column in my "posts" table. Here''s the code I have already: @posts = Post.find_by_contents(params[:query]) params[:query] comes from a form. I