search for: bar_id

Displaying 15 results from an estimated 15 matches for "bar_id".

Did you mean: car_id
2006 Mar 22
2
Radio Button Defailt Value?
I have: <%= radio_button ''foo'', ''bar_id'', ''1'' %> <%= radio_button ''foo'', ''bar_id'', ''2'' %> <%= radio_button ''foo'', ''bar_id'', ''3'' %> I would like to have option #3 be selected if foo.bar_id...
2006 Oct 31
4
Auto-increment lost during migration.
...script removes the auto-increment property if you rename a column. This is a minimal example. create_table :foo, :primary_key => :foo_id do |t| t.column "name", :string end # renaming the primary key makes auto-increment disappear. rename_column :foo, :foo_id, :bar_id Is this a known problem, any beautiful solution available? Maybe use change_column instead? Best regards, Tobias Nurmiranta --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To p...
2011 May 30
5
rails habtm checkboxes with jquerymobile
...desktop and a mobile version. My mobile version is made with jquerymobile and I would like my checkboxes in the edit form to look like the checkboxes shown in http://jquerymobile.com/demos/1.0a4.1/#docs/forms/forms-checkboxes.html. My desktop code is the following: <%= check_box_tag "foo[bar_ids][]", bar.id, @foo.bars.include?(bar) %> ...and page source is the following: <input id="foo_bar_ids_" type="checkbox" value="19" name="foo[bar_ids][]" checked="checked"> Jquery <br> <input id="foo_bar_ids_" type=&...
2006 Mar 23
3
when (not) to use belongs_to
...nswers exactly what I''m after. I''m reasonably new to rails, and I''m having a bit of trouble with when to use belongs_to. On the rails wiki ( http://wiki.rubyonrails.org/rails/pages/belongs_to), it says "In general, the Foo model belongs_to :bar if the foo table has a bar_id foreign key column." But according to ForumExample ( http://wiki.rubyonrails.org/rails/pages/ForumExample) doesn''t always do this. A Message has_one author but there''s no ''belongs_to :message'' in the Author class. There are examples of when the author uses i...
2013 Feb 28
2
Create polymorphic resources
...in the Comments#create action, how am I supposed to create the comment through either Foo/Bar? If it is a comment for a Foo resource, I need to do: @commentable = Foo.find(params[:foo_id]) @commentable.comments.create(....) But if it''s Bar I need to do: @commentable = Bar.find(params[:bar_id]) @commentable.comments.create(....) What I do now is to use this method: def find_commentable params.each do |name, value| if name =~ /(.+)_id$/ return $1.classify.constantize.find(value) end end nil end and @commentable = find_commentable Which loops over all params for...
2006 Jan 03
0
Automatically mapping content_columns?
Hi all, Quick setup - I''ve got a table Foo. Foo has a foreign key (bar_id) to the table Bar. The Bar table has an "id" and "name" column. Assume a 1:1 relationship. The issue I''m trying to resolve (or rather, be lazy about) is with regards to Foo.content_columns. By default it doesn''t pickup the foreign key. What I''m...
2006 Jan 08
1
Using many-to-many relations in tests
Hello, I have some many-to-many relations, I would like to use in my tests. But I''m not sure what I should put in the fixtures for it? How do I add those relations in the testing environment? Greetings, Gitte Wange
2006 Jan 21
7
n-way joins
...4 way) joins in Rails (where the join tables contain extra data as well.) Let me give you my basic entities: foos id - pk name - unique bars id - pk name - unique bazs id - pk name - unique frozs id - pk name - unique then i have two separate join tables: foos_bars_bazs - 3 way join foo_id\ bar_id > primary key/unique baz_id/ value foos_bars_bazs_frozs - 4 way join froz_id\ foo_id \ bar_id \ primary key/unique baz_id / value Now, my use cases for access are: 1. Given a foo, find all { bar, baz, value } associated with it (i''d really like to get back bars and bazs, not jus...
2006 Sep 01
3
find_by_sql with :include?
...so that both objects get instantiated in the results, e.g. Foo.find(:all, :include => :bar). But when you use find_by_sql, is there a way to do this? You could definitely write the find_by_sql SQL to join Foo and Bar tables: Foo.find_by_sql("SELECT foo.*, bar.* from foo, bar where foo.bar_id = bar.id") But is there a way to instantiate not just the Foo object but also the Bar object in the results that come back? thanks, jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk&...
2006 May 17
10
HABTM << producing incorrect insert sql ?
Greetings railsers - I''m trying to add to a collection through HABTM, but the sql insert is trying to insert a PK rather than letting mysql produce the auto_increment''ed PK. ## @medication_dose holds a validated, saved model @medication_dose.medication_frequencies << MedicationFrequency.find (:all) The above bails with, Mysql::Error: #23000Duplicate
2007 Nov 14
1
New Foxy Fixtures (Rails 2) & STI (Single Table Inheritance)
I''ve got some problems right now using the new model for relationships in fixtures (by label, not by id) and STI. What I''ve got, is a couple of models: Attachment --> FileDownload Version Version has_one file_download with file_download_id on the versions table In my fixtures, I have two FileDownloads in my attachments.yml like so: hemingway_alpha_zip: size: 100
2006 Apr 24
3
Migration: How to make a column the primary key
Hi, I would like to write a migration that creates a table without auto-generating a primary key "id" column, and then make a integer-column of my choice the primary key. How can I do this? Ingo -- Posted via http://www.ruby-forum.com/.
2006 Feb 24
3
Migrations, data loads and changes to the model
Guys, I''ve run across an interesting scenario with my migrations, and I hope you might share some insight. Let''s say I have 3 migrations and two Models (Person and Car): 001_initial_schema.rb 002_data_load.rb 003_add_car_association.rb The first creates the initial schema...the second loads default data using model objects of Person to do so, and the third creates a new
2006 Jul 03
6
help!
Hi, i''m fairly new to ruby on rails, and i know the question at hand may seem simple at first, but i''m getting really caught up in trying to understand this and the docs aren''t giving me answer. i actually thought i knew how the sql commands work (like :include, :conditions, :etc) but obviously, i don''t. there are three models M1, M2, M3 joined by a habtam
2005 Aug 08
7
Problems with ./scripts/generate scaffold
Hi all, I''m new to rails after having used perl for most of these things, and am trying to get my head around the generate script for a project playing around with. If I do: ./scripts/generate controller Device I get app/controllers/device_controller.rb where I can then add: scaffold :device However, if I want to actually generate the scaffolding so I can make some changes: