Displaying 20 results from an estimated 500 matches similar to: "belongs_to, has_one, has_many question (again?)"
2006 Jan 05
3
ActiveRecord setting IDs on auto increment fields
Hi All, I''ve tried to do my searches, but can''t find reference to
this anywhere - My question is about ActiveRecord inserts and IDs. I
have a join table that both the models of the source tables join with
"has_and_belongs_to_many". It seems like ActiveRecord is setting the
"id" field for the join table- This should be an auto_increment and
2006 Apr 10
4
Many To Many''s Join table attributes + migrations
Hi all,
just joined and have only just kicked off with Rails (coming, but not
departing, from WebObjects development). And so far there seems to be
a lot of promise except for one thing I can''t figure out as yet --
the above problem.
Say I have the following conceptual relationships:
ITEMS <<--->> CARTS
i.e., each item can belong to one or more categories. So really
2006 Jun 21
1
Newbie Four Days on Rails
Hi all,
Having successfully gone through Bill Walton''s Tutorial ''Rollining with Ruby on [Instant] Rails''
I decided to tackle John McCreesh''s ''Four Days on Rails'' Tutorial.
I changed the Rails version as recommended in the tutorial.
All went well until I entered the following command:-
ruby script/generate model category
I got:-
2007 Sep 14
2
Testing nested controller
Hey everyone.
I really stuck on testing a nested controller. I''m trying to make a
request using get and afterwards checking the response by
response.should ...
My routes.rb looks like this:
map.resources :writers do |writers|
writers.resources :notes
end
In my notes_controller_spec.rb
def do_get
writer_id = 1
note_id = 1
get note_path(writer_id, note_id)
end
it "should
2006 Apr 07
4
How to generate mapping with migration
Hi there, I''ve tried to add a m:n mapping table using the migration
mechanism.
ruby script\generate migration add_categories_notes_mapping
and filled the migration file with:
class AddNotesCategoriesMapping < ActiveRecord::Migration
def self.up
create_table :categories_notes do |t|
t.column :category_id, :integer, :null=>false
t.column :note_id, :integer,
2005 Feb 27
12
Four Days on Rails
There are a number of really good beginner''s guides to Rails on the web
now - covering installation through to running the first ''scaffold''.
However, as a complete Ruby newbie, I found the next stage - moving on
to producing ''real'' applications - quite hard going.
To help others make the same journey, I''ve put together a ''next
2007 Sep 14
2
Testing a nested controller
Hey everyone.
I really stuck on testing a nested controller. I''m trying to make a
request using get and afterwards checking the response by
response.should ...
My routes.rb looks like this:
map.resources :writers do |writers|
writers.resources :notes
end
In my notes_controller_spec.rb
def do_get
writer_id = 1
note_id = 1
get note_path(writer_id, note_id)
end
it "should show
2009 Feb 09
3
Michael Graves post
Michael Grave just posted a question about surround conferences.
http://www.facebook.com/notes.php?id=564633430#/note.php?note_id=5009726
3908&id=564633430&index=0
I didn't see it posted on the ast-list, what do you think? Does
something like this have potential?
I'd love to listen in on one of these calls to see how it actually
sounds if someone builds a trial
2006 Apr 02
7
RANT: belongs_to -> refers_to
Every once in a while, I pipe up and whine that "belongs_to" should really
be ''refers_to" [http://dev.rubyonrails.org/ticket/2130]. It''s time again.
I''ve got a bunch of stuff going onto eBay, so, like any good engineer, I
don''t just post it manually: I design a Rails-based inventory database that
creates a semantically-correct XHTML/CSS auction
2007 Apr 19
1
Use of Markdown Extra in a forum
from : benoit at transmekong.com
to : markdown-discuss at six.pairlist.net
Subj.: Use of Markdown Extra in a forum
Date : Apr 19th 2007, 15:24:25 (GMT+7)
Dear all,
I have tried to implement PHP Markdown Extra in a forum (PunBB) and found that however well each message is translated, there are collisions when different messages in the same page have the same inside link names (footnotes, title
2006 May 24
5
where can i find a good tutorial for has_one and belongs_to?
thanks for helps!
--
Posted via http://www.ruby-forum.com/.
2006 Apr 12
0
Sorting with SQL for has_one, belongs_to relationship
I''ve been using this sort helper to have sortable tables.
http://wiki.rubyonrails.com/rails/pages/Sort+Helper
I''ve encountered a situation where I need to sort a column that is not
part of a table, but it''s related table.
For example, say I have db tables called foos and bars. Foos have
fields called name and title. And bars have fields called note and
foo_id. Foos
2014 Apr 19
0
How to has_one/belongs_to association only return the objects unassociated in combobox?
I have two models (Car and Driver) and a combobox to select which driver
belongs to which car. I want the combobox just show the objects that have
not yet been associated.
# vehicle belongs_to: driver
# driver has_one: vehicle
# simple_form # vehicle/_form.html.haml
= f.association: driver, label_method: :name, value_method: :id
How to ensure validation before saving, to avoid problems of
2006 Dec 01
0
How to save has_one belongs_to models?
How can I save two models that have has_one and belongs_to
relationship to each other? I want to save both the models by using
script/console. TIA.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to
2011 Jul 07
0
has_one through belongs_to
Hi.
My model data is the following:
- Place
- User
- Checkin
Instead of having a Checkin that belongs to both User and Place, I chose to
add another model, Program, that allows to list all the places a user can
checkin into, and also hide the checkins he''s no longer involved in (= the
user sign out of a specific program).
That give me crazy relationships:
Program has_many Checkin
2011 Oct 20
2
Access other model attributes directly with has_one, belongs_to ?
So, I have 2 models A and B that share 5 common attributes and all other
attributes are different. So I wanted to extract these 5 out into one
common table and use has_one, belongs_to to knit it back together. So
now there are 3 tables with 1 having the shared properties, we''ll call
this table C.
Table A
id
dollar_amount
Table B
id
quantity_on_hand
Table C
id
version
My question is,
2006 Jan 31
4
has_one without inverse belongs_to
I have two models called entity and user.
The entities table has a column called users_id that contains the user
id of the user that created the entity.
In entity I have...
has_one :user
... as I want to be able to show the user who created the entity from
the entity object.
But this produces the following error...
Mysql::Error: #42S22Unknown column ''users.entity_id'' in
2006 Jul 06
4
has_one, belongs_to - I am just not getting it
Let me preface by saying i''m a total noob at ruby/rails. :-)
For some reason, I am just not grasping the concept of has_one &
belongs_to...
I''m working on a project that includes user authentication, and 3
different types of user profiles.
User profiles are either "fan", "band", or "venue" objects, and user
logins are "user"
2006 Oct 13
3
Validation errors in has_one/belongs_to relationships.
I have two objects, QuoteInput and Insured.
QuoteInput has one Insured and Insured belongs to QuoteInput.
I don''t understand what I''m seeing.
I assign an Insured to a QuoteInput. The Insured object has invalid
data.
I call save! on the quote input. QuoteInput has no validations.
I expect two things to happen - 1) an exception should be thrown,
indicating that there was a
2010 May 11
1
has_one/belongs_to -- accessing the subordinate
With a has_one/belongs_to relationship, what''s the best way to guarantee
that the belongs_to object gets created and is accessible alongside the
has_one object? I *think* the after_create callback is a good choice,
but I discovered an oddity while trying it.
F''rinstance, if every horse has a carriage:
============
ActiveRecord::Schema.define do
create_table(:horses) {|t|