Displaying 20 results from an estimated 2000 matches similar to: "managing belongs_to fields in a form"
2006 Jan 12
2
Can A Model Have Many belongs_to?
I am very new to Rails. After skimming through the documentation over
the last several days, I''m struggling with the appropriate use of
belongs_to. My main question is whether a model can have several
belongs_to declarations. I have not seen any examples online show that
usage. If it can, then I would like to know if it''s poor form or what
the best practices are around
2006 Jul 04
13
NewBie question
Hi,
I m very new to Ruby.
I bought a book "Ruby on Rails" and I think I understand some concepts.
My question is :
Is there a way to not use "Cookies" or "Sessions Variables" to keep some
information about the user.
I ask this question because I would like to prevent some cases where the
user browser won''t accept cookies.
I m from Asp 3.0, and I
2006 Jan 26
1
Transactions for multiple models
I have users and companies tables where users belongs_to companies.
def signup
@company = Company.new(params[:company])
@user = User.new(params[:company])
@user.company = @company
if @user.valid? and @company.valid?
@company.save
@user.save
end
end
How can I make this into a transaction? Is this a candidate for a
distributed transaction?
If so, from what I understand from the API,
2006 Jul 08
2
Creating/Saving dependent objects
Folks,
Am new to RoR and am building an example to get myself familiar. I am
running into a simple issue while creating a user registration page.
I have a User and Address models defined as below (partial/relevant code
included below). User has_one address and Address belongs_to user. I have a
foreign key defined in address table that refers to user(id)
In a form I take in username, password,
2006 Jun 03
8
confused about ActiveRecord relationships
I am very confused about where to put the belongs_to and the has_one
(and other relationship identifiers). I have read the RDoc and the
agile book many times about this and I think i still see it backwards.
Let me outline my app so you have an understanding...
I have 2 tables:
Schools { id, school_name, address_id }
and
Addresses { street1, street2, city, state, zip, country }
*** this
2006 Feb 03
6
Saving a User Object while in the Address Controller
Hi,
My saves are failing me and I can''t figure out why.
I am trying to save an address id to a user object just after I create
the address.
This isn''t the exact code, but it shows what I am trying to do.
class AddressesController < ApplicationController
def create
@address = Address.new(params[:address])
saved_address = @address.save
@user =
2006 Jan 09
3
Design Question
I am sure some of you can give me an insight into this. This is more
towards the database design for the scenario below:
Say for example,
I have a person table and this person can have different address types.
One could be Home and the other could be say Office.
Should be model this
Table people
id
fname
lname
Table addresses
id
person_id
addr1
addr2
....
or
Table people
id
fname
lname
2006 Apr 07
4
belongs_to and lookup tables
I have two classes, Listing and Warranty. A Listing (think of it as a
product) may or may not have a Warranty from a lookup table.
When I want the Warranty.company for a given Listing I want to say the
following:
@listing = Listing.find(4)
@company = @listing.warranty.company
In order to do that I did the following:
class Listing < ActiveRecord::Base
belongs_to :warranty
end
and
2006 Feb 28
2
Need help with a Power Find()
I was hoping someone would be able to help me with creating a method.
I have two tables. What I am trying to do is create a list of all the id''s
from table2 that aren''t currently referenced by Table1''s address_id column.
That way, when I create a new customer I can have a drop down list in the
view of all the addresses that are not currently being used.
##### Database
2007 May 16
7
bilingual site: exclude fields set from query
Hi all,
Is there a way to have searches no use some indexed fields, when
processing a query?
context:
I have a model Foo that holds some information in two languages :
- text1_nl, text2_nl, text3_nl
and
- text1_en, text2_en, text3_en
Some other fields are common to both languages and indexed as well
- first_name, last_name
Depending on the visitor language choice I need to exclude the
2006 Jul 02
1
multitable form
Hi all,
Although I''m experienced with programming I''m a beginner with ruby, RoR
and MVC
So I follow examples from books and so on and all is ok.
I can make a model who is a class and who match to a table in my
database and then I generate pretty forms on a webpage.
I would like to know how I can do to make forms who interact with more
than one table.
For an example lets
2006 Jul 05
19
associations question
Hello,
I have a People table and a Addresses table. A person can have one or
more addresses, but should at least have one, so there is a address_id
field in People.
Now, I would like to have a form to fill the name of a new person and
its address from the same place. I could use person.address.country, for
example (it works), but I would like to simply use person.country for
some reasons
2007 May 19
4
button_to_function with image?
Hi:
does button_to_function allow the use of an image? I tried it in place
of the text with "image_tag" and it doesn''t work. Maybe some form of
button_to?
Any direction you can give would be great!
Mike
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
2005 Nov 16
1
HABTM: deleting records based on attributes
Hello All,
I am new to ROR, and can''t seem to get HABTM to cooperate entirely...
however I might be abusing it! Before I try a different strategy I
thought I''d ask here and see if I''m missing something simple.
So say Projects and Companies are related. Projects can have multiple
Companies, and Companies can be on multiple Projects. But, the same
Company can also
2006 Feb 08
5
beginner - problem with understanding relationships
Hi folks,
I''m new to this... so hopefully someone can help me.
I have a few objects... Property and Address and Landlord... where a
Property has an address and a landlord has an address also.
I''ve modelled this in the db with the properties table having an
address_id and the landlord table having an address id.
My rb looks like:
class Property < ActiveRecord::Base
2006 Feb 25
7
Help with DRY: too much code in my view
I''m a newbie to rails, and really to the whole DRY and MVC thing as
well, except where I accidentally fell into things doing it my own way
in the past.
I''ve got a fairly complex DB structure I want to create an interface for
using Rails. Getting simple tables to display, edit, save, not too much
problem there. But where I''m having trouble is figuring out where to
2007 Jan 24
6
dojo and prototype compatibility?
are there any compatible issues that exist when trying to use both
prototype and dojo at the same time?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group.
To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this
2005 Dec 16
13
How to pass a collection to paginate?
There must be a better way to write this code:
@project_pages, @projects= paginate :project,
:per_page => 10,
:conditions => ["account_id = ?", account]
?!
If only I could pass the sub-collection
account = ...
@projects = account.project
to paginate, instead of letting it extract it with a find :all + sql
conditions
Alain.
--
Posted via
2006 May 17
13
Using NTLM for S.S.O. in Rails
Greetings all,
To all the good souls that happen to know NTLM and Rails....
Short version:
--------------
- I''m looking for server code to extract credentials through NTLM dialog
with the client (IE)
- I found nothing usable/useful (as they both implement the client side
code) in
- rubyntlm on rubyforge
- lib ntlm-ruby by Jonathan Bastien-Filiatrau
LONG version:
2005 Dec 21
7
Are there any disadvantages to using locomotive
Hi:
I had some issues and so switched to locomotive. I find it awesome. 1
click and its done.
My question - what disadvantages are there, if any? What do I lose by
using such a convenient solution.
speculation as well as facts are welcome but please define which you
are putting forwards.
Thanks in advance,
bruce