similar to: Getting Foreign Key to work!

Displaying 20 results from an estimated 30000 matches similar to: "Getting Foreign Key to work!"

2006 Jan 19
5
limits of has_and_belongs_to_many
I''m experimenting with Rails on the Recipes example first before I dive into applying it to my intended application. I''m exploring which will be more work: to rename all the primary id''s in the legacy database, or to work around the fact that the primary id''s are not called ''id'' within RoR instead. I''ve been successful in using a
2006 May 07
6
RuntimeError in Recipe#edit
I have tried to learn ruby on rails from scratch by going into a tutorial at the following website. http://instantrails.rubyforge.org/tutorial/index.html I followed the suggestions and encountered 3 problems so far. 1. Couldn''t start the Apache server. Error message "Port 80 was used by some other process." I over-came the problem by going into configuration and change the
2006 Dec 06
2
validates_uniqueness_of where scope euqals created_by "magic" field
I have the following ActiveRecord objects: class Recipe < ActiveRecord::Base has_many :ratings, :dependent => true . . . end class Rating < ActiveRecord::Base validates_uniqueness_of :created_by, :scope => :recipe_id belongs_to :recipe, :counter_cache => true . . . end The created_by field on Rating is implemented as a "magic" field similar to this:
2012 Apr 02
0
active admin saving selection from collection_select and passing to controller
hi i am using active admin for my app i have a partial with a drop down list where the menu and recipe are populated this page is to group the recipe in a menu _menu_recipe.html.erb <%= semantic_form_for [:admin, @menu_recipe] do |f| %> <p> <%= f.collection_select :recipe_id, Recipe.all,:id,:name,:prompt => true%> </p> <p> <%= f.collection_select :menu_id,
2006 Jan 11
1
Composite primary key
Hi All, How do I specify a composite primary key for a table in ActiveRecord? For example the table Recipe which has the primary key [cookie id, version number] where cookie id is also a foreign key referencing Cookie. Also: Thanks to Nic and Adam for helping with the Cookie -> Cooky problem. /Hugo --SQL * CREATE* *TABLE* `Raw_Materials`* (* id *INT*
2006 May 09
6
Still Stumbled on First things in trying RubyOnRails
Still Stumbled on First things in trying RubyOnRails http://www.digitalmediaminute.com/article/1816/top-ruby-on-rails-tutorials http://www.onlamp.com/pub/a/onlamp/2005/01/20/rails.html http://instantrails.rubyforge.org/tutorial/index.html http://rails.homelinux.org/ I had tried the first of the top 12 tutorials and got stuck after adding a new field ?category_id?in the table recipes,
2011 Feb 19
2
Active Record Query
A course has many lessons and a lesson has many topics. A topic can have a recipe or vice versa, a recipe has many topics (optional). I need to come up with the most efficient way of querying the database to find those topics belonging to a course (via lessons of course) which have a recipe (in other words recipe_id is not null for this topic record). Simple but challenging :) Thanks for your
2006 Apr 21
3
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
Hi I am a newbie to Ruby on Rails, but experienced in programming. I am trying out Rolling with Ruby on Rails article by Curt Hibbs on onlamp.com. I have encountered following error: Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id I searched the archives of the list and found that similar question was left unanswered. I do understand from
2006 Mar 07
1
Error when trying Rolling with Ruby On Rails
Hi everyone! Please excuse my ignorance! I was working through the Rolling with Ruby tutorial to get a feel of things. Everything seems to work until I tried editing as in the last example in part 2 when I got the following error - |Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id ||| Extracted source (around line *#8*): |5: <body> 6:
2006 May 07
6
Unable to get past Tutorial 1 in RubyOnRails
Unable to get past Tutorial 1 in RubyOnRails On 29 April 2006 I met some one in a Microsoft sponsored developers? community gahering. I was told that ruby on rails is a free software, easy to use, and in no time will have my mind blown with all the wonderful prospects and possibilities. After almost a week, I am still unable to get past tutorial 1 and still unable to make any tutorials work
2006 Jan 03
4
validates_presence_of *_id attributes
Hi all, I am a newbie to Rails. Please enlighten me on how to do this appropriately, the Rails and the Ruby way: Suppose I have a Recipe model. Let''s simplify things and pretend that it has only 2 attributes, a :name and the other is a ''category_id''. In the recipes table, category_id is a foreign key to field id of table categories. We also assume that I have generate
2006 Jun 21
1
Migration with foreign key won''t work
Hi all I use the plugin which supports foreign keys with migrations: http://wiki.rubyonrails.org/rails/pages/Foreign+Key+Schema+Dumper+Plugin/versions/12 I have created the following migration file: class AddArtistsTable < ActiveRecord::Migration def self.up create_table :artists, :force => true do |t| t.column :name, :string, :limit => 100 t.column :artist_type_id,
2006 Jul 28
1
Foreign columns
Hi you all: I''m reading "Rolling with Rails I" by C. Hibbs and in his example, establishes a foreign key in a table (recipes), related to the column of another table (categories). The thing is that he establishes this matching in the code, but in the database he does not establish the foreign key as such. My question is, can the "foreign" aspects in a database be
2006 Jan 19
6
One Last Question for me..
And then I should be ready to roll with my project.. I have some fine tuning of the looks to do after, but funtionality first! This is probably a rails question.. but I''m not sure where to sign up for the rails questions email group? (I guess I turned this into a 2 question email). I''ll ask here and then if someone will send me the url of where I go to sign up for the rails
2006 Mar 22
2
n00b question
Total Ruby N00b here with a question about the Hibbs OnLamp tutorial. I''m trying to hook up to my cookbook database and I''m getting: ActiveRecord::StatementInvalid in Recipe#index Mysql::Error: #42S02Table ''cookbook.recipes'' doesn''t exist: SELECT COUNT(*) FROM recipes RAILS_ROOT: ./script/../config/.. My thoughts: I think I''m not actually
2006 Mar 01
2
Validating that a foreign key is present and ok
How do I validate that a model object''s attribute is a valid foreign key? The problem is, I can''t check if the attribute is a valid foreign key if the attribute doesn''t even exist. For example, every employee must be in a department. In the following code, if an employee''s department_id is not present then Department.find_by_id(department_id) might cause
2006 Feb 03
1
Database Foreign Key - Basic question
Hi all I''m still waiting on my Agile Rails book to arrive - in the meantime ... As an exercise I''m making a Help Desk application. If I have a Problems table with two foreign keys to a People table, how do I set up my models, problems_controller list method, and then simply display say my problem submitter person? Here is what I have so far: Problems table with columns: 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
2008 Apr 04
1
rails unit testing removes foreign key constraints in test database?
I''ve noticed that when testing is finished that at some point Rails has removed the foreign key constraints from my test database. Does anyone know where this foreign key constraint deletion occurs in the source code. I''d like to turn it off. Thanks, Peter --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google
2007 Oct 07
2
How specify foreign key column name in model?
In a model declaration I can specify the name of the primary key column with set_primary_key "CUSTOMER_NUMBER" How can I set the name of a foreign key column that does not conform to the RoR naming convention. Does the following work? set_foreign_key "CUSTOMER_NUMBER" If not, how can I specify the name of the foreign key column? Thanks.