Displaying 20 results from an estimated 2000 matches similar to: "newbie - HABTM confused..."
2006 Jul 07
3
Newbie Model question (HABTM?)
All,
If I have a table that has several discrete fields that all point to
the same associated field, how do I model it.
Specifically,
If I have a project table that has 2 fields: specifying_company, and
responsible_company.
And one table of associated companies, how do I do the :belongs_to /
:has_many stuff
ie. For a given project company A may be writing the spec, but company
B may be paying
2006 Feb 10
15
"Ruby for Rails" in early access release
Hi --
My book "Ruby for Rails" is now being released one chapter at a time
through the Manning Early Access Program, with the whole book
due to appear on May 1.
If you''re interested, see http://www.manning.com/books/black
(I guess I could have just sent my sig with no body, but anyway :-)
David
--
David A. Black (dblack@wobblini.net)
Ruby Power and Light
2006 Apr 27
5
ERb on he command line re: Ruby For Rails book
Hi,
I am working thru the Ruby for rails book. On page 30 David Black
talks about running erb from the command line i.e. $ erb erbdemo.rb
just as you would a normal ruby prog ($ ruby erbdemo.rb) but when I
try to do this I get command not found. How do I make this work? I am
running Linux (Ubuntu Breezy)
Regards,
Paul
2006 May 11
7
[ANN/ADV] Ruby for Rails now published in paper!
Hi --
I''m on the road, so I haven''t laid eyes on it yet -- but word on the
virtual street is that "Ruby for Rails: Ruby techniques for Rails
developers" is now out in paper.
It will probably take a little longer to trickle to your neighborhood
Barnes and Noble... but you can order it now from the publisher. See
http://www.manning.com/black. And trickle it will, too.
2006 May 31
7
How to render from with <%%> ?
I have a loop that I iterate through in my view.
<%
coll.each do |itm|
puts(itm.value)
end
%>
How do I render the itm.value without using a <%= %> tag? Should puts
not work?
Joerg
P.S. There is a good enough reason for me wanting to do this :-)
--
Posted via http://www.ruby-forum.com/.
2006 Mar 20
11
has_many brings back ''uninitialized constant''
hello. first things first - I am new to ruby on rails (ruby, too), so
I''m figuring this is just a basic newbie error.
I''m creating a basic photography website. And I have two tables with a
relationship:
photos:
- id (set up as PK)
- title
- shutter
- aperture
- date
- the_order
...etc
photo_comments:
- id (set up as a PK)
- photos_id (set up as a FK)
- author
- date
-
2006 Jul 30
8
Method_missing from Ruby for Rails book
I''m having a problem getting this example from the book to work:
class Cookbook
attr_accessor :title, :author
def initialize
@recipes = []
end
def method_missing(m, *args, &block)
@recipes.send(m, *args, &block)
end
end
cb = Cookbook.new
cb << recipe_for_cake
cb << recipe_for_chicken
beef_dishes = cb.find_all {|recipes| recipe.main_ingredient ==
2006 Jun 09
1
any errata for second printing of "Ruby for Rails"?
Hi all --
The second printing of "Ruby for Rails" is happening soon. If you''ve
spotted any small errors, let me know... like... *very* soon :-)
(I want to know about large errors too, but those fixes won''t make it
into this printing :-)
Thanks!
David
--
David A. Black (dblack@wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)
See what
2006 Aug 08
12
delete_if doesn''t work for has_and_belongs_to_many
I''m using Rails-1.1.4 with Ruby-1.8.4
So let''s say I have 2 model classes:
class Item
has_and_belongs_to_many :things
end
class Thing
has_and_belongs_to_many :items
end
i = Item.new
i.things << Thing.new( :value => "Something").save
i.things << Thing.new( :value => "Something Else" ).save
i.save
Fine, now I have two records in the
2006 Jul 17
14
REST Relationship Models
I''m trying to figure out an elegant way to do this:
I have the following three tables:
people, employer, employees
And consequently the following three models:
class Person < ActiveRecord::Base
end
class Employer < ActiveRecord::Base
has_many :employees
end
class Employee < ActiveRecord::Base
belongs_to :person
belongs_to :employer
end
I want to be able to say:
2006 Jun 28
1
European Rails Conf -- talk proposals now being accepted
Hello all --
And a special greeting to those of you who were at RailsConf 2006 in
Chicago. You know how great the event was, and how great the European
Rails Conference is going to be in London in September!
We''re now accepting proposals for talks at the European Rails
Conference, to be held September 14-15 in London. Accepted speakers
will get free admission to the conference.
2006 Jul 16
17
AWDWR question
In an early section on Action View, showing code being put directly
into the rhtml file:
<% require ''date''
DAY_NAMES = %w{ Sunday Monday Tuesday Wednesday Thursday Friday Saturday }
today = Date.today %>
<h1>Hello, Dave</h1>
<p>
It''s <%= DAY_NAMES[today.wday] %>.
Tomorrow is <%= DAY_NAMES[(today + 1).wday %>.
</p>
I get this
2006 Feb 10
12
Accessing ''many'' variables
Hi,
I have a class called Outlet which has_many Jacks. Apart from internal
id, each jack is unique by the attribute ''color''.
I''d like to iterate through each Outlet, and be able to output data
for a Jack of a certain color.
Say, I want to access the orange jack for the current outlet:
<td><%=h outlet.jack.color[''O''].ip_address
2006 Mar 16
3
Passing function names from string variables
This may be a more generic Ruby question, so I''m going to ask on the Ruby
forum, but I''m trying to figure out if there is a way to pass in the string
value of a variable as the name of a method.
For example, I would like to do something like:
def sort_obj_by_uid(objects,@attr)
@tmparray = Array.new
@tmphash = Hash.new
for object in @objects
if !
2006 May 16
2
Ruby Central presents the European Rails Conference
Hello everyone --
Ruby Central, Inc. is pleased to announce the first official....
EUROPEAN RAILS CONFERENCE
September 14-15, 2006
TUC Congress Centre
London, UK
Sponsored by Skills Matter Ltd. (UK)
Speakers scheduled to appear at this exciting event include:
* David Heienemeier Hansson
* Dave Thomas
* Kathy Sierra
* Scott Baron
2006 Apr 20
4
Question about Associations
Hi all. Got a stupid-simple question about associations. I have two
models - school and course. There are a fixed number of schools (set
up in the migration). Each course is assigned a school and a school
will be associated with multiple courses...
How do I set up the associations? Do (can) I have School :has_one
:course and Course :has_many :schools?
Does the schools table then get a course_id
2006 May 23
10
Ruby on Rails: Up and Running
hello,
On page 49 of the beta version of Ruby on Rails: Up and Running, the
book suggests to download a zip file containing everything that has been
done up to that point, and a create_tables_with_data.sql file. The book
doesn''t have the link, and I couldn''t find it in the book site. Does
anyone know where to get the files?
This is a very good book.
Thanks.
--
Posted via
2006 Jun 02
6
Set instance variable for all actions in the Controller
Can I set an application wide instance variable that is available for all
actions...and their views?
eg.
class ApplicationController < ActionController::Base
@current_user = User.find(session[:user_id])
end
and everywhere I can call @current_user.id and I can get that object? Even
down in the views?
I could not get this to work...
Thanks in advance,
Jeff
-------------- next part
2006 Mar 03
6
has_one :next - invalid name?
I have this in a model:
has_one :next,
:class_name=>''WorkPart'',
:foreign_key=>''next_id''
And it causes this error:
compile error
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.1/lib/active_record/deprecated_associations.rb:83:
void value expression
2006 Jul 31
2
[UPDATE] More info on RubyConf 2006 registration
Hi --
Registration for RubyConf 2006 is still scheduled to open on August 2,
in the early evening Pacific (US West Coast) time.
Also, there''s more info at http://www.rubycentral.org/conference
(e.g., the fact that this year we''re only taking credit cards, etc.).
David
P.S. Any LA area Rubyists around? I''ll be there this week doing Rails
training.
--