Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Hop Pocket
Sep 23, 2003

Sort of rails related, but yesterday Time Machine (OS X) completely saved my bacon. I had been working all day on a plugin for Mephisto and near the end I wanted to test out the install.rb functionality of the plugin. I had been working on the plugin in #{RAILS_ROOT}/vendor/plugins/mephisto_plugin.

% script/plugin install vendor/plugins/mephisto_plugin

rails: This directory already exists.. Use --force to override

% script/plugin install vendor/plugins/mephisto_plugin --force

Directory mephisto_plugin could not be found.

(Yes I realize that this was a completely retarded way to go about testing it)

To my horror I realized that the entire directory had been deleted. I grabbed the hourly backup from Time Machine all the while mumbling "please work please work please work".

Hooray for hourly backups

Adbot
ADBOT LOVES YOU

Mrs. Wynand
Nov 23, 2002

DLT 4EVA
Any of you looking for work? ;)

If you are already getting paid for RoR work, can I steal you away? Seriously, if you have actual working experience on Rails - I am drat near certain I can get you a pretty substantial pay increase by joining our shop.

Pardot
Jul 25, 2001




Hop Pocket posted:

Hooray for hourly backups

Are you not using source control?

Hop Pocket
Sep 23, 2003

Pardot posted:

Are you not using source control?

I am, but I don't commit every hour. Usually at the end of the day or work period.

jonnii
Dec 29, 2002
god dances in the face of the jews

Hop Pocket posted:

I am, but I don't commit every hour. Usually at the end of the day or work period.

I tend to check in every feature or bug fix, which normally corresponds to items in jira. It makes it easier to do release notes, and link your scm to your issue tracker.

Doing a check in at the end of every day tends to lead to every dev doing that and build breakage.

Hop Pocket
Sep 23, 2003

jonnii posted:

I tend to check in every feature or bug fix, which normally corresponds to items in jira. It makes it easier to do release notes, and link your scm to your issue tracker.

Doing a check in at the end of every day tends to lead to every dev doing that and build breakage.

I agree, but sometimes a particular task will take you the better part of a day, as was the case here. In other words, there was no point in checking it in until the issue I was working on was resolved. Anyways, sorry for the derail, back to rails related things :)

skidooer
Aug 6, 2001
Is anyone an expert with Ferret/acts_as_ferret?

I'm confused why
code:
Model.find_by_contents('field:"Some Value"')
returns no results.

However,
code:
query = Ferret::Search::PhraseQuery.new(:field)
query << "Some Value"
Model.find_by_contents(query)
returns the expected results. Note that "field" is an untokenized field.

I've gone through the source and Ferret's query parser builds, as far as I can tell, the exact same PhraseQuery object before it goes searching so I'm not seeing why there is a discrepancy.

Edit: Found it. The query parser builds the phrase query like this:
code:
query = Ferret::Search::PhraseQuery.new(:field)
query << "Some" << "Value"

skidooer fucked around with this message at 05:50 on Mar 7, 2008

Pardot
Jul 25, 2001




In case some of you missed this, there's a new version of rubygems, 1.1.0, out. It's supposed to be much faster at indexing, but I haven't had a chance to test it out yet. Just run sudo gem update --system to get it.

http://blog.segment7.net/articles/2008/03/29/rubygems-1-1-0

Hop Pocket
Sep 23, 2003

Pardot posted:

In case some of you missed this, there's a new version of rubygems, 1.1.0, out. It's supposed to be much faster at indexing, but I haven't had a chance to test it out yet. Just run sudo gem update --system to get it.

http://blog.segment7.net/articles/2008/03/29/rubygems-1-1-0

I'm on leopard, and I had to run

code:
$ sudo gem install rubygems-update
$ sudo update_rubygems
To get it to run. Both finished the same way, with a weird error message at the end, but only after trying the above way of updating did `gem -v` == 1.1.0

Pardot
Jul 25, 2001




Hop Pocket posted:

I'm on leopard, and I had to run

code:
$ sudo gem install rubygems-update
$ sudo update_rubygems
To get it to run. Both finished the same way, with a weird error message at the end, but only after trying the above way of updating did `gem -v` == 1.1.0

You know, I read some blog comment that someone else had to do this too, but I just did clean install of leopard on my macbook and the regular gem update --system worked fine. That was using the ruby that came with it, not macports or anything. I wonder what causes the difference.

brae
Feb 2, 2006

Pardot posted:

You know, I read some blog comment that someone else had to do this too, but I just did clean install of leopard on my macbook and the regular gem update --system worked fine. That was using the ruby that came with it, not macports or anything. I wonder what causes the difference.

I was also able to upgrade cleanly that way on my 2ish month old install of Leopard. I'm running ruby 1.8.6 from macports.

Pardot
Jul 25, 2001




The new timestamp migrations in edge rails is cool and solves the problem of two people checking migrations with the same number (though you should update your copy before checking in and notice this anyway :argh: ). It might solve my biggest issue with migrations, too but I'm not sure -- I'd have to try it out. It's when you branch for a release and continue working on trunk, and then have to fix something on your branch right away that involves a migration. What I've done before with that is to flatten the migrations down to a single migration before the branch, then skip several numbers for the next trunk migration. Ugly.

The other awesome edge rails thing is the gem dependancies. You specify what gems you need in environment.rb
rake gems:install - installs all the gems your app needs
rake gems:unpack - vendors all the gems

bmoyles
Feb 15, 2002

United Neckbeard Foundation of America
Fun Shoe
Pretty interesting stuff here:
http://www.modrails.com/
http://izumi.plan99.net/blog/

brae
Feb 2, 2006

bmoyles posted:

Pretty interesting stuff here:
http://www.modrails.com/

Just what we need: another apache module for connecting to external code that is not only language specific, but framework specific. I'm sure it will be as good as mod_python, mod_perl, mod_mono, and countless others.

I don't understand why people can't just come up with decent FastCGI bridges. Also, what is wrong with a mongrel cluster and mod_proxy?

skidooer
Aug 6, 2001

brae posted:

Also, what is wrong with a mongrel cluster and mod_proxy?
It requires administration. Passenger just works. Upload your application and you're done. At least that's what they claim.

jonnii
Dec 29, 2002
god dances in the face of the jews
And they've said that it won't be rails specific in the long run, but will work with all rack compatible frameworks.

Popcorn Sutton
Oct 25, 2007

by The Finn
A few basic ruby questions for you guys.

I'm writing a script that takes a list of names, puts them into an array, and then generates a .csv file for use with windows server 2003 to add users in. This is what I have so far:

code:
a = Array.new(500)
i = 0
File.open("Namelist", "r") do |f1|
  while line = f1.gets
    test = line.gsub(/[.0123456789]/, "")
    data = test.split('\n')
    a[i] = data
    i = i + 1
  end
  string = 'test' + a[2].to_s + 'omglolz'
  print string 
end
I basically only have the array part done, It's my first ruby code ever and it only took me like 2 hours to figure everything out.

Obviously the last part was just to test that it worked. I'm sure there's a better way to go about what I've done so far, but that's what I came up with.

The next part of the coding I have to do is to generate the csv file, it looks like this:
code:
"CN=Amie Baldwin,OU=Test OU,DC=test,DC=com",amieb,amieb@test.com,512,user
So I need it to take the name from the array and generate the following:
Full name - done
OU, DC, and DC remain static
First Initial + Last Name
Previous + test.com
The rest remain static.

The full name is stored in an array (a), the first and last name are separated by a space.

I know how to make a string from these things, but I don't know how to generate the rest, and how to have it loop for however many entries in the array there are. I also am somewhat confused about writing to a file.

---Huge Edit---

I got off work and was bored, so I tore into this with some help from #ruby on freenode, and the full solution/input file so you can see it work can be found here: http://pastie.org/185259

Popcorn Sutton fucked around with this message at 04:46 on Apr 23, 2008

Pardot
Jul 25, 2001




You don't need to use counter variables anymore, or define arrays, or use while loops or for loops anymore now that you've entered the magical world of ruby!

Here's a quick refactoring of your code. I don't really like how you were using regexes to generate the account name, but I didn't want to figure out a different way to do it.


http://pastie.org/185316

I put it in as a picture for the syntax highlighting, to see how I'd like it. I think it works well for short-to-medium length stuff like this.

skidooer
Aug 6, 2001
Another take:
code:
begin
  require 'fastercsv'
rescue LoadError
  require 'rubygems'
  require 'fastercsv'
end

class Person
  attr_accessor :id, :first_name, :last_name
  
  def initialize(id = nil, first_name = nil, last_name = nil)
    @id, @first_name, @last_name = id.to_i, first_name, last_name
  end
  
  def name
    "#{first_name} #{last_name}"
  end

  def username
    "#{first_name[0..0]}#{last_name}"
  end
  
  def email
    "#{username}@contoso.com"
  end
  
  def dn
    "CN=#{name},OU=Test OU,DC=contoso,DC=com"
  end
  
  def to_a
    [ dn, username, email, 512, 'user' ]
  end
  
  def map(&block)
    to_a.map(&block)
  end
end

FasterCSV.open('names.csv', 'w') do |csv|
  csv << %w(dn sAMAccountName userPrincipalName userAccountControl objectClass)
  File.open('names.txt').each do |record|
    csv << Person.new(*record.strip.split(/\s+/))
  end
end

Sewer Adventure
Aug 25, 2004
Is session data stored in the cookie by default? Is that why there is a 4kb limit?

Pardot
Jul 25, 2001




Sewer Adventure posted:

Is session data stored in the cookie by default? Is that why there is a 4kb limit?

Yes and yes. Cookie based sessions were made the default in revision 6184 back in February 2007.

r6184 posted:

Introduce a cookie-based session store as the Rails default. Sessions typically contain at most a user_id and flash message; both fit within the 4K cookie size limit. A secure hash is included with the cookie to ensure data integrity (a user cannot alter his user_id without knowing the secret key included in the hash). If you have more than 4K of session data or don't want your data to be visible to the user, pick another session store. Cookie-based sessions are dramatically faster than the alternatives.

What are you doing that needs more that 4k for the session? Typically you shouldn't store entire objects in the session. Rather, store the id, and then do Model.find session[:whatever].

Sewer Adventure
Aug 25, 2004

Pardot posted:

Yes and yes. Cookie based sessions were made the default in revision 6184 back in February 2007.


What are you doing that needs more that 4k for the session? Typically you shouldn't store entire objects in the session. Rather, store the id, and then do Model.find session[:whatever].

Thanks and yeah I was storing whole objects for a shopping cart and it was giving cookie overflows when people tried to buy lots of stuff, but storing the ids is definitely a better idea

Hop Pocket
Sep 23, 2003

I got bit by the 4k limit just a couple of days ago. We were using the cacheable flash strategy to store flash in the cookies (for an instance where we had to have page level caching) and we ended up putting form error validations, and then form values into the cookie was well. BOOM!

Popcorn Sutton
Oct 25, 2007

by The Finn
Hey guys, doing another ruby script, this time for the adding of an exchange server mailboxes using the same namelist as before. Here's the code:

(I'm using my code for this still as I didn't really understand the awesome fast code enough to modify it to my own needs)

code:
a = []
b = []
i = 0

File.open("NameList").each_line do |line| 
 line.strip!
  a[i] = line.gsub(/[.0123456789]/, "").strip!.split.join(' ')
  b[i] = a[i].gsub(/^([a-z0-9\-])([a-z0-9\- ]+) ([a-z0-9\- ]+)$/i, '\\1\\3')
  i = i + 1
  break if i == 500
end
now = 0
top = 500
fout = File.open("mailboxadd.bat", "w")

while now < top
  string2 = 'Enable-Mailbox -Identity NETADMIN.COM\'+a[now]+' -Database Mailbox Database'
  fout.puts string2
  now += 1
end

fout.close
It's giving me this error and I don't understand why:
code:
/Users/fivestar/Ruby/ExchangeMailbox/exchangemailbox.rb:17: syntax error, unexpected tCONSTANT, expecting kDO or '{' or '('
  string2 = 'Enable-Mailbox -Identity NETADMIN.COM\'+a[now]+' -Database Mailbox Database'
                                                                               ^
/Users/fivestar/Ruby/ExchangeMailbox/exchangemailbox.rb:17: unterminated string meets end of file
/Users/fivestar/Ruby/ExchangeMailbox/exchangemailbox.rb:17: warning: parenthesize argument(s) for future version
/Users/fivestar/Ruby/ExchangeMailbox/exchangemailbox.rb:17: syntax error, unexpected $end, expecting kEND
fout.close
          ^
Why is it breaking tables?

Thanks again for the help guys, no idea what i'd do without you. (Probably sit in #ruby on freenode and beg for help.

Also, for those of you who might play poxnora I'm coding a really awesome ruby app for our upcoming project GOONMALL.

Plastic Jesus
Aug 26, 2006

I'm cranky most of the time.

Popcorn Sutton posted:

Why is it breaking tables?

Thanks again for the help guys, no idea what i'd do without you. (Probably sit in #ruby on freenode and beg for help.

Also, for those of you who might play poxnora I'm coding a really awesome ruby app for our upcoming project GOONMALL.

You don't have a 'do' to go along with your 'while'. Also, while loops aren't very ruby idiomatic. You could try something like this instead:

code:
0.upto(500) { |idx|
   fout.puts "Enable-Mailbox -Identity NETADMIN.COM #{a[idx]}-Database Mailbox Database"
}

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I hope this thread hasn't slumped off since I found it on the second page. I'm trying to get into Rails now, but I keep getting spanked. My big problem is integrating with and IDE. I've found the Ruby Eclipse plugins just don't function. I'm lucky to get a source file up in there, and then luckier still to run something, but never enough to debug. NetBeans had promise, but it seems out of sync with the newer rails stuff I have on my box. Now mongrel shits itself with this when I hit the top page in a new, default project in NetBeans:

code:
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  TERM => stop.  USR2 => restart.  INT => stop (no restart).
** Rails signals registered.  HUP => reload (without restart).  It might not work well.
** Mongrel 1.1.4 available at 0.0.0.0:3000
** Use CTRL-C to stop.
Wed Apr 30 12:34:11 -0500 2008: Read error: #<ArgumentError: wrong number of arguments (1 for 0)>
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/http_request.rb:41:in `write'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/http_request.rb:41:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:149:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:149:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.4/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Should I not bother with the IDEs? I'm trying to update to 6.1 but I doubt it's going to help. Ultimately I want a visual debugger.

Ruby as a language has been interesting, but I keep getting burnt with gems and gluing together the complex stuff I need.

Trabisnikof
Dec 24, 2005

Rocko Bonaparte posted:

IDE Stuff

Most of the coders I know who do Rails don't use an IDE. Rails has some decent error messages, and with unit testing (if you are so inclined) that should provide strong tools to debug. I know I've never really looked at using an IDE because it never seemed necessary for a scripting language like ruby.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I have to give up thrashing on this as much as I do in a day since it's not moving anywhere. I got off NetBeans and managed to get the Hello World tutorial working off of https://www.rubyonrails.org. But as soon as I try to do something with the database, I get an error from rake db:create "uninitialized constant ActiveRecord." I have no idea what to do to fix it for my system. The gem is installed--that's about all I know. Nobody on IRC could help. I'm new enough that I don't know where to look to start figuring this stuff out. If nobody can help I have to give up on it for now.

It's just amazing to me to think that other people could have the tutorials kick off fine and dandy when they poo poo on me almost immediately. Do most people develop on Windows or something? I wonder if it's the fact that I'm on Ubuntu that makes everything unstable.

dustgun
Jun 20, 2004

And then the doorbell would ring and the next santa would come
What's the migration that you're using?

dustgun fucked around with this message at 05:07 on May 1, 2008

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I am unsure. I reference ActiveRecord in the tutorial's first migrate script:

code:
class AddTable < ActiveRecord::Migration
    def self.up
create_table :people do |t|
      # id is created for us.
      t.column :name,    :string, :limit => 50, :null => false
      t.column :street1, :string, :limit => 70, :null => false
      t.column :street2, :string, :limit => 70, :null => false
      t.column :city,    :string, :limit => 70, :null => false
      t.column :state,   :string, :limit => 2,  :null => false
      t.column :zip,     :string, :limit => 10, :null => false 
    end
  end

  def self.down
    drop_table :people
  end
end
And these are the gems I have installed:
code:
actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
mkrf (0.2.3)
mongrel (1.1.4)
mysql (2.7)
rails (2.0.2)
rake (0.8.1)
ruby-opengl (0.60.0)
rubysdl (2.0.1)
sqlite3-ruby (1.2.1)

canned from the band
Sep 13, 2007

I'm a man of intensity. Of cool, and youth, and passionately

Rocko Bonaparte posted:

I am unsure. I reference ActiveRecord in the tutorial's first migrate script:

code:
class AddTable < ActiveRecord::Migration
    def self.up
create_table :people do |t|
      # id is created for us.
      t.column :name,    :string, :limit => 50, :null => false
      t.column :street1, :string, :limit => 70, :null => false
      t.column :street2, :string, :limit => 70, :null => false
      t.column :city,    :string, :limit => 70, :null => false
      t.column :state,   :string, :limit => 2,  :null => false
      t.column :zip,     :string, :limit => 10, :null => false 
    end
  end

  def self.down
    drop_table :people
  end
end
And these are the gems I have installed:
code:
actionmailer (2.0.2)
actionpack (2.0.2)
activerecord (2.0.2)
activeresource (2.0.2)
activesupport (2.0.2)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
mkrf (0.2.3)
mongrel (1.1.4)
mysql (2.7)
rails (2.0.2)
rake (0.8.1)
ruby-opengl (0.60.0)
rubysdl (2.0.1)
sqlite3-ruby (1.2.1)

You're using Rails 2.0 but using the old migration style. I'm not 100% sure if that still works, but check out 'sexy migrations' which is now in use. There's a good Railscasts episode on it: Migrations in Rails 2.0

EDIT: It can sometimes be a struggle to keep up with the constant changes in Rails. It's useful to keep an eye on the main Rails page and other Rails related blogs, its usually enough for me.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!

B1axident posted:

EDIT: It can sometimes be a struggle to keep up with the constant changes in Rails. It's useful to keep an eye on the main Rails page and other Rails related blogs, its usually enough for me.
I'm certain it is especially when I'm trying to learn off tutorials and don't know anything about these concepts yet. Should I be looking for rails 2.0 tutorials or something?

The tutorial I was using was even off the rubyonrails.org site.

jonnii
Dec 29, 2002
god dances in the face of the jews
in rails 2.0 it creates the migrations for you when you use script/generate model, maybe re-try that step?

canned from the band
Sep 13, 2007

I'm a man of intensity. Of cool, and youth, and passionately

Rocko Bonaparte posted:

I'm certain it is especially when I'm trying to learn off tutorials and don't know anything about these concepts yet. Should I be looking for rails 2.0 tutorials or something?

The tutorial I was using was even off the rubyonrails.org site.

All of their screencasts are from old versions and haven't been updated. Yeah, have a google for some Rails 2.0 tutorials, to get yourself upto date, there's quite a few around.

Also if you're thinking of buying a textbook, wait until the new version of 'Agile Web Development with Rails' comes out, as that's all updated for Rails 2.0. Think you can buy a beta pdf already!

bag of a bee
Jun 17, 2007

Ok I'm writing a database app with a database of Quotes. Each quote can be on multiple People. So i have two tables, Quotes, and People. Quotes has_many People and People Belongs to Quotes etc.

I've gotten that far and no problem manually adding in quotes and people associated with said quotes. I also have coded a successful viewer app that correctly associates quotes with people.

My database looks like this

code:

[Quotes]

ID 1
   Quote = "These are cool guys"


[People]

ID 1
   Name = "Mark"
   quote_id = 1

ID 2

   Name = "John"
   quote_id = 1

so people 1 & 2 both reference quote 1.

Anyway I can't quite figure out how to submit a new quote using this scheme setup. The form builder seems to only like dealing with a single object (just quotes, or just people, but not both). Can anyone point me in the right direction? I'm still pretty new to rails.

Thanks for any help :)

Edit: just to be clear I'll make a blog system analogy: I'm basically trying to make a Submit New Blog Post form that would let you submit a new blog post ALONG with a few user discussion comments for the blog post in the same form/action. So after all the standard blog fields (title, body, etc) you would have a couple rows of these fields: User - Comment, User - Comment, etc.

bag of a bee fucked around with this message at 05:39 on May 2, 2008

skidooer
Aug 6, 2001

bag of a bee posted:

The form builder seems to only like dealing with a single object (just quotes, or just people, but not both).
You can use fields_for to specify an additional object.
code:
<% form_for @quote do |f| %>
	<%= f.text_field :quote %>
	
	<% f.fields_for :people do |n| %>
		<%= n.text_field :name, :index => 0 %>
		<%= n.text_field :name, :index => 1 %>
	<% end %>
	
	<%= submit_tag 'Add quote' %>
<% end %>
code:
class QuotesController < ApplicationController
  def new
    @quote = Quote.new
  end

  def create
    @quote = Quote.create(params[:quote])
  end
end
code:
class Quote < ActiveRecord::Base
  has_many :people
  
  def people_with_form_initialization=(people)
    people = people.values.map { |attributes| Person.new(attributes) } if people.is_a?(Hash)
    self.people_without_form_initialization = people
  end
  alias_method :people_without_form_initialization=, :people=
  alias_method :people=, :people_with_form_initialization=
end

Pardot
Jul 25, 2001




You may also want to take a look at the Complex Rails Forms series at railscasts.

http://railscasts.com/episodes/73
http://railscasts.com/episodes/74
http://railscasts.com/episodes/75

asveepay
Jul 7, 2005
internobody

Pardot posted:

You may also want to take a look at the Complex Rails Forms series at railscasts.

http://railscasts.com/episodes/73
http://railscasts.com/episodes/74
http://railscasts.com/episodes/75

This helped me immensely when I was trying to do the same thing a few weeks ago. You may have a little trouble getting it to work if you're only creating one additional child object however.

Rocko Bonaparte
Mar 12, 2002

Every day is Friday!
I finally found a rails 2.0 tutorial that seemed to work. I've concluded that I will ultimately need to get a book in order to explain how everything fits together. I don't think I can get enough from the tutorials to figure out how it all goes. It also looks like the kind of thing you can't figure out entirely from looking at other people's sources; a big part of the process is generating everything as you plod along. I'll see if I can scoop up a rails 2.0 book at the library here, but it sounds like I might have to wait.

Adbot
ADBOT LOVES YOU

canned from the band
Sep 13, 2007

I'm a man of intensity. Of cool, and youth, and passionately

Rocko Bonaparte posted:

I finally found a rails 2.0 tutorial that seemed to work. I've concluded that I will ultimately need to get a book in order to explain how everything fits together. I don't think I can get enough from the tutorials to figure out how it all goes. It also looks like the kind of thing you can't figure out entirely from looking at other people's sources; a big part of the process is generating everything as you plod along. I'll see if I can scoop up a rails 2.0 book at the library here, but it sounds like I might have to wait.

I'm personally the type of guy that needs the book, so always gets one! There aren't many Rails 2.0 books out yet I can only think of the The Rails Way and the updated Agile Web Development With Rails. Keep in mind that the Rails Way is for more experienced users. Here's some info on recommended Ruby books: http://antoniocangiano.com/rails-books/

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply