similar to: Variables in find

Displaying 20 results from an estimated 40000 matches similar to: "Variables in find"

2007 Oct 09
2
Help with gamm errors
Dear All Hopefully someone out there can point out what I am missing! I have a (large, several hundred) dataset of gardens in which over two years the presence/absence of a particular bird species is noted each week. I have good reason to believe there is a difference between the two years in the weekly proportion of gardens and would like to assess this, before going on to look in more detail at
2007 Jun 05
1
Mysterious Javascript showing up & trashing page
Every time I edit a particular page, a bit of javascript myseteriously shows up when I save it. After that, the page does not lie correctly, and the items at the end of the list are covered over by elements from the stylesheet. The script is as follows: <p>&nbsp; </p> <p align="center"><font face="Times New Roman"><font
2006 Jan 11
5
Noob - Associated Tables Find Query
I''m trying to write a football prediction game. I have a Matches table and a Predictions table. Each Match :has_many Predictions, and each Prediction :belongs_to a Match Each Match has (amongst other things) a Match.match_date field. Each Prediction has (amongst other things) a User_id field I''m trying to get a list of all Predictions a particular User has made which
2008 Apr 18
3
has_many and belongs_to with non-primary foreign keys
Hi, I''m having a bit of trouble with my first Rails app. ---- I have two tables: create_table :items do |t| t.column :created_at, :timestamp t.column :user_id, :int t.column :text, :text end create_table :users do |t| t.column :user_id, :int t.column :name, :string end ---- I''m trying to use the "user_id" field to link both tables, with each user
2006 May 28
7
Self-referential has_many :through relationship
Hi, I have a self-referential has_many :through relationship setup to track relationships between users. Basically relationships are modeled as a join table with an extra column ''relation''. create table relationships ( user_id integer unsigned not null, friend_id integer unsigned not null, relation char(1) not null, ) --- relations --- f = friend r = request to
2007 Oct 18
9
with_scope issue
I have the following code: class User < ActiveRecord::Base has_many :requests do def find_active(options = {}) with_scope :find => { :conditions => ["requests.active = ?", true] } do find(:all, options) end end end end Executing user.requests.find_active results in the following SQL: SELECT * FROM requests WHERE (( requests.user_id = 10 ) AND (
2010 Aug 18
6
Once I added this HABTM, one of my 'through' relationships, on a non-habtm model, seems to have broke?
I''m a rails newb and have been Googling about this, but I''m still stumped. Not showing everything here, but basically it should be a pretty common setup so I''m sure others know what I''m doing wrong. - A meter can belong to many meter_groups - A meter_group can have many meters. - A user can ''subscribe'' to viewing a meter_group (Subscription)
2011 Jan 15
3
has_many :through with Single Table inheritance
I have the following model structure setup. class User < ActiveRecord::Base end class Parent < User has_many :relationships has_many :children, :class_name => "Student", :through => :relationships, :conditions => "related_as = ''parent''" end class Student < User has_many :relationships
2009 Jan 26
5
Please help with a routing problem
Hi All I''m having some issues with the following routes problem. The routes.rb file ... map.resources :users map.connect ''/users/view_payments/:user_id'', :controller => ''users'', :action => ''view_payments'' The users_controller.rb file ... def view_payments @user = User.find[:params[:user_id]] @payments =
2009 Nov 09
3
How can I improve a Ruby on Rails code that hast a lot of SQL as strings?
Hello Railists, I have a piece of Ruby on Rails code that has a complex SQL query (well, not that complex, but as far as I know beyond the ORM capabilities) and for my taste it has too many strings and harcoded values. I''d like to improve it as much as possible, so my question is open ended, what else can I do to improve it? Some particular issues I have - Is there a way to get a table
2006 May 13
4
undesireable lazy loading
Hi, My work with Rails has been fairly straightforward, until yesterday... I''ve encountered rather a peculiar problem that I''m not able to solve myself as a rails-newbie. The model code looks like this: class Link < ActiveRecord::Base has_one :user_vote end class UserVote < ActiveRecord::Base belongs_to :user belongs_to :link end I have a SQL query that is
2006 Nov 02
4
Still Having Problems With :through When Going To Same Table... Help... please :-(
I am having a problem with doing a :through that goes back to the same table. The following are my two classes: >>>>> class User < ActiveRecord::Base has_many :spanks has_many :spanked, :through => :spanks, :source => :spanked_user has_many :was_spanked_by, :through => :spanks, :source => :user end class Spank < ActiveRecord::Base belongs_to :spanker,
2006 Dec 05
1
has_many :through questions
I have a database with 4 tables Months has_many :weeks Weeks has_many :days Days has_many :hours Hours Weeks belong_to :month Days belong_to :week hours belong_to :day I need to access the month_id in the Hour.rb model. find(:first, :conditions => ["user_id = ? AND month_id = ?", user_id, month_id]) Thanks -- Posted via http://www.ruby-forum.com/.
2006 Feb 27
4
2 belongs_to to the same parent table
Hello! I have 2 table: users and buddies User: id, name, ... Buddy: id, user_id, user_buddy_id, ... So if you have 2 users 1,jack and 2,fred and fred is a buddy of jack, there is a Buddy object: id=1, user_id=1, user_buddy_id=2 I can declare only one belongs_to in Buddy and one has_many in User. And there is conflict if I had the second one (the first one is discarded) class User has_many
2006 Oct 31
1
Help with DRY. I feel like im doing more then I have to.
Throughout my Message controller, I do this a lot: @message = Message.find(params[:id],:conditions => ["user_id = ?", @session[''user''].id]) Since you need to authenticate to use this app, is there a way i can tie the Accounts model in with the Message model so I dont have to pass in the user_id everytime? --~--~---------~--~----~------------~-------~--~----~ You
2006 Jul 26
8
team captain - habtm w/has_one...
the below... class User < ActiveRecord::Base has_and_belongs_to_many :teams class Team < ActiveRecord::Base has_and_belongs_to_many :users has_one :captain, :class_name => ''User'' produces the error... Mysql::Error: Unknown column ''users.team_id'' in ''where clause'': SELECT * FROM users WHERE (users.team_id = 1) LIMIT 1 i
2006 Jan 06
1
has_many with :finder_sql question
hi all, I have a Class, Client, which has_many projects (Project class). the projects depend on a session_id variable, however. So the question is, how can I do the following: has_many :projects, :finder_sql => "SELECT p.* FROM projects p INNER JOIN projects_users pu ON pu.project_id = p.id WHERE pu.user_id = #{session[:user_id]}" The problem is that I need to filter a
2005 Dec 29
2
has_many & belongs_to with Plugins (login_engine)
Hello list, Probably a newbie question but couldn''t find the answer in the archives. I am using the login_engine Plugin to implement the login functionality. I have a JournalEntry model that interacts with the journal_entries table. I would like to link the journal entries to the user who entered it. Essentially, it is a one to many relationship between the model User(from
2006 Jul 04
1
Has_many :through with checkboxes?
Just when I started getting the hang of has_and_belongs_to_many relationships, I realize that I should probably convert several of my app''s joins to has_many :through type relationships. One example, pairing users with categories via subscriptions, where each user can be the "owner" of a category, has given me particular trouble when I try to update a user''s
2009 Dec 03
2
Dynamic Paths
Hey there, I''m in the muck of a major rails project, and need a bit of advice. Google isn''t much help in this case, so I came here. I''m trying to set up a URL structure as follows: url.com/username/blog/post_id where the user has_many posts and the post belongs_to user. I''m using the friendly_id plugin to enable easy lookup with the user''s username,