similar to: Multiple fields on table X linked to one field on table Y

Displaying 20 results from an estimated 20000 matches similar to: "Multiple fields on table X linked to one field on table Y"

2006 Jan 19
2
select vs. select_tag
I have a "Users" object and a "Timesheets" object. Each timesheet entry belongs to a User, which is selected from a drop-down list. The timesheet has a user_id field. (The user needs to have an option to select a different user due to the way our system works.) If i use the "select" object, which is bound to the Timesheet model, using this code: <%= select
2005 Dec 30
3
Select SUM(?) Query
When using PHP, I was able to enter a query against my list of invoices such as : Select SUM(amount) from invoices where project="123" This would give me the total amount of all invoices for project 123. In rails, how would I do this? I tried using "find_by_sql," but couldn''t figure out how to extract the results out of this. Thanks!
2005 Feb 09
1
cant map foreign key in list view
Hi I have been struggling to get a foreign key in a list map to a readable value in a lookup table I have a list of projects and each project has a project_manager. Project.rb class Project < ActiveRecord::Base has_one :project_manager, :class_name => "Users", :foreign_key => "manager_id" end The association above sais that a project_manager is in
2006 Jan 08
1
Options_from_collection_for_select -> Multiple fields in display
The following code shows a list of the users, with username being each person''s initials (mine would be DM). &lt;%= options_from_collection_for_select @users,"id","username" %&gt; However, I''d like to have the display of the SELECT box be "DM - Dylan Markow" instead of "DM." Is this possible using
2006 Jan 22
2
File_column not keeping value during page reloads
I''m trying to use the file_column plug-in to attach a file to a newsletter posting. It works fine if I get the form right the first time, but if I get an error, such as not typing in a required field, and the form re-displays, my file selection box reverts to "no file selected." Here''s my relevant controller code: def new @newsletterpost = Newsletterpost.new
2010 Mar 31
1
How to assign currently logged in user name to a table field
I have 3 tables items (columns are: id, name , type) history(columns are: id, date, username, item_id, user_id) user(id , username, password) When a user "ABC" logs in and creates a new item, a history record gets created with the following after_create filter. How to set the username field in history table to "ABC". class Item < ActiveRecord::Base has_many :histories
2006 Jan 09
3
Custom flash[:notice]
For the most part, my flash[:notice] messages fall into one of two categories: either a message stating that something happened successfully (which is colored green), or messages showing errors (which I would like to be red). Is it possible to set some sort of flag on these messages to choose which color I want to show, or would I need to base it on CSS and set the class in the text, i.e.
2011 Jan 23
0
Bundle installs/Cannot run dbconsole
When I run bundle install from the command line I get the following below installed in my project directory under sqlite3--with-sqlite3lib Folder. Fetching source index for http://rubygems.org/ Installing rake (0.8.7) Installing abstract (1.0.0) Installing activesupport (3.0.3) Installing builder (2.1.2) Installing i18n (0.5.0) Installing activemodel (3.0.3) Installing erubis (2.6.6) Installing
2006 May 23
2
additional fields in session DB table
I am using active record sessions and everything works fine. I am integrating it with phpbb however so i need some extra fields populated in the session table. In application.rb i put a before_filter to update the session table I have a model for the sessions $ more app/models/session.rb class Session < ActiveRecord::Base set_primary_key "session_id" set_table_name
2005 Dec 29
2
options_for_select order
I''m trying to create a Select box using the following code: &lt;%= select ''project'', ''status'', { "Active" =&gt; "Active", "MD" =&gt; "MD",  "HOLD" =&gt; "HOLD", "Dead" =&gt; "Dead"   }  %&gt; You''d think the select box would keep them in
2009 May 11
0
updating join table (HMT) with checkbox and extra fields
Hi, I''ve been breaking my head over this thing with no success. Here is my table layout - class User < AR has_many :memberships has_many :groups, :through => :memberships ... class Group < AR has_many :memberships has_many :users, :through => :memberships ... class Membership < AR belongs_to :user, :class_name => "User", :foreign_key =>
2005 Dec 24
2
Textilize on ajax update
I''m writing a basic to-do application. I''m using a form_remote_tag to submit the entry to my controller, which then returns the entry to be displayed in the table of to-do items. However, I''d like to be able to "textilize" the entry without having to reload the page. Is there any way to have my ajax function textilize the text before displaying it in the list?
2005 Dec 14
3
why would an int column in a join table be a String class in model?
i''ve got an issue with integer columns in the database becoming strings in the model and I''m not sure why this is happening. perhaps someone can explain. given the following setup (simplified for example) tables: users ---------- id - int name - varchar(60) roles ---------- id - int name - varchar(60) roles_users (join table) ---------- role_id - int user_id - int
2006 Jan 09
6
Nil column results, possible to ignore?
For a table "clients" there are city, state, and zip fields. However, for some clients we only have a state with no actual address. The following code throws a "You have a nil object" error when outputting my client list. Is there a way around this, short of writing a specific case for each possibility? &lt;%= client.city + '', '' + client.state +
2006 Jan 31
2
Design question: Storing user fields
Hello- I have a database/rails design question. I''d like the user to be able to specify a set of fields they would like associated with items. Imagine a shopping cart where each item has a description and price. But a particular customer may choose to associated a color with all her items. (it will be site-wide, so every item listed for this particular user will have this
2009 Apr 03
3
plyr and table question
Dear all, I'm puzzled by the following example inspired by a recent question on R-help, cc <- textConnection("user_id website time 20 google 0930 21 yahoo 0935 20 facebook 1000 25 facebook 1015 61 google 0940") d <- read.table(cc, head=T) ; close(cc) table(d$user_id) # count the
2005 Dec 19
3
created_on, created_at defaulting to 2000/01/01 00:00:00
Hello all, Rails 1.0.0 created_on is being set to 2000/01/01 00:00:00 Any ideas on this ? Thanks! Schema is create table user_login_history ( id int identity(1,1) not null, user_id int not null, created_on datetime default(getdate()) not null, created_at datetime default(getdate()) not null, updated_on datetime default(getdate()) not null, constraint pk_user_login_history primary key clustered
2006 May 23
1
Validating a required relationship.
Hello, I''m not sure if I''m missing something blindingly obvious here. All the relationships that Rails comes with assume 0..n, yes? It''s not a strict 1 to 1 or 1 to n because it''s optional. My question is this - What is the best way to implement a required relationship? For example, if I require that a comment is made by a user (a user has many
2006 Mar 16
0
Conflicting Attributes in Model and Join Table...
Hi all, I''ve got a Post and User classes. The Post has a user_id attribute to point to the user that created it. I want to implement favorites, so I made Post and User both "has_and_belongs_to_many" and created a favorites join table. The join table has a post_id and a user_id column. Now when I get my post everything seems to be okay, but in some contexts, the user_id
2006 Jan 13
4
missing foreign key fields in scaffold views
Is there any reason that foreign key fields do not show in any of the scaffold views ? project table: id serial primary key, category_id integer, user_id integer, name varchar, morestuff varchar foreign key (category_id) references categories(id), foreign key (user_id) references users(id) scaffold generated views only show name, morestuff fields