RE: [Rails] wrong number of arguments (Wrox Beginning Ruby On Rails)

2010-02-19 Thread Pardee, Roy
The scaffold generator takes a model name, followed by an optional space-delimited list of field name:type specs. So you might say: script/generate scaffold Book name:string description:text price:decimal Or you can leave off the list of field names (in which case you don't get much in your

RE: [Rails] Re: Why do so many Ruby/Rails developers use Macs?

2009-12-08 Thread Pardee, Roy
> On Dec 4, 6:33 pm, Jim Knowlton wrote: > > I am a QA engineer who works in Ruby quite a bit, and I've never been > > able to figure out...why is there a disproportionately large > > contingent of Mac users among Ruby developers? Macs are probably 10 > > percent of the computer market, but every

[Rails] Re: Set a select box with default value selected

2009-09-14 Thread Pardee, Roy
Something like... # views/subject/show <%= link_to 'Would you like to add one?', new_book_path, {:subj => @subject} %> # controllers/books_controller def new @book = Book.new @book.subject = params[:subj] # etc... end HTH, -Roy -Original Message- From: rubyonrails-t

[Rails] Re: accesing post array

2009-09-14 Thread Pardee, Roy
I think you want to use the fields_for helper so rails will give you an array of form params to hold the various items. You should also probably include a hidden text field in there to hold the id of each item so you know which quantity should go w/which item. HTH, -Roy -Original Messag

[Rails] markdown call prompts "uninitialized constant ActionView::Helpers::TextHelper::Markdown" in upgraded application

2009-09-14 Thread Pardee, Roy
Hey All, I'm attempting to upgrade my app from rails 2.0.2 to 2.3.3. One bit that's failing is this call here (in /views/projects/show.html.erb) <%= markdown(@project.description) %> That earns me a: uninitialized constant ActionView::Helpers::TextHelper::Markdown On that line. I'm on

[Rails] Re: How to dynamically change stylesheets globally?

2009-07-16 Thread Pardee, Roy
If you give the cookie a long lifespan, you won't need the extra formatting preference stuff on the end of the URL. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Michael Schuerig Sent: Thursday, July 16, 2009 1:04 AM T

[Rails] Re: Single Sign-on for two rails app

2009-07-15 Thread Pardee, Roy
AD (at least) can be used on other platforms to automatically authenticate a connection w/out prompting the user for credentials. If RoR could use it that way it would amount to single-sign-on I think. Can RoR & its typical deployment stack not use AD like that? (I'm seriously asking, in case

[Rails] Re: How to dynamically change stylesheets globally?

2009-07-15 Thread Pardee, Roy
Right--you typically bring a stylesheet file into your app w/goo like this in the layout: My Cool App: <%= controller.action_name %> <%= stylesheet_link_tag 'my_stylesheet' %> You can bring as many stylesheets as you want into your layout. So e.g., this will work: <%= stylesheet_l

[Rails] Re: [JOBS]

2009-07-15 Thread Pardee, Roy
The OP's e-mail address is @aol.com. So obviously it's someplace in Albania. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Marnen Laibow-Koser Sent: Wednesday, July 15, 2009 10:21 AM To: rubyonrails-talk@googlegroups.c

[Rails] Re: Database table restore.

2009-07-15 Thread Pardee, Roy
> Hi guys, > >We have a table named layoff_comments in our database, >but accidentally we have deleted(lost) all the data from >this table, we have backup, and we want to restore that >table, without dropping the current database. Please help >us. > > Thanx in advance. You'll

[Rails] Re: Complete Beginner...

2009-07-14 Thread Pardee, Roy
I say, scratch an itch of your own. Track something you need to track in your personal or professional life. That way you don't have to beat requirements out of anybody (or guess at them). -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups

[Rails] RE: select or select_tag

2009-07-14 Thread Pardee, Roy
I believe they're fairly equivalent WRT populating them w/values. I think the main distinction is whether you're feeding the selected value into a form that builds a model object or not. If you're in a form_for block, then select is easier (e.g., it uses the context of the form builder to save

[Rails] Re: fresh MSI installation prlblems

2009-07-14 Thread Pardee, Roy
I think the root cause of both issues is the same--the ruby & rails installs for windows don't include sqlite binaries and/or the associated ruby bindings. There are excellent instructions for making a functional ruby and rails install on windows here: http://blog.mmediasys.com/2009/07/06/gett

[Rails] Re: Use of self in a class

2009-07-13 Thread Pardee, Roy
> So when you do this: > >class Something > def self.greet >puts "Hello from #{self}!" > end >end > > you're defining a method on the object self -- which happens > to be, at that point in execution, the class object > Something. And just to beat the horse a little more,

[Rails] RE: Problems installing mongrel in Ruby 1.9.1 on Mac OS

2009-07-09 Thread Pardee, Roy
There may be something of use to you on this page: http://isitruby19.com/mongrel HTH, -Roy From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Guillermo Acilu Sent: Thursday, July 09, 2009 5:55 AM To: Ruby on Rails Li

[Rails] Re: Rails apps. with Microsoft Access as a back end?

2009-07-08 Thread Pardee, Roy
Never tried it. I think the lack of an adapter is what kills this. I'd be curious to hear whether the sqlserver adapter in ODBC mode could be fooled into hitting msaccess w/the right connect string... -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...

[Rails] Re: shorten a link

2009-06-01 Thread Pardee, Roy
Can you post a sample @article.url that results in blank .host output from URI.parse? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Sean Six Sent: Thursday, May 28, 2009 8:53 PM To: rubyonrails-talk@googlegroups.com Su

[Rails] Re: Ruby and RoR Setup Frustrations

2009-06-01 Thread Pardee, Roy
It's not an IDE, but I really like the 'e' text editor for ruby/rails development on windows. Google for 'e text editor' & you'll find it. It's a textmate clone (or started out that way anyway). HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrail

[Rails] Re: sql -> migrations ?

2009-05-29 Thread Pardee, Roy
Try pointing your config/database.yml at your legacy db & run 'rake db:schema:dump'. That should dump the current schema out to db/schema.rb. HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of JannaB Sent: Frid

[Rails] Re: ID not primary key with not unique values

2009-05-26 Thread Pardee, Roy
I believe the primary_key directive will tell AR what field to use as the actual PK. Something like: class MyClass < AR::Base primary_key :actual_pk_field_name end Hopefully AR would then then ignore the id field. -Original Message- From: rubyonrails-talk@googlegroups.com [ma

[Rails] Re: nested habtm in views

2009-05-22 Thread Pardee, Roy
Maybe: <%= link_to lecture.title, lecture.lecture_id %> ? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Patrick Heneise Sent: Friday, May 22, 2009 1:45 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] nest

[Rails] Re: How to keep persistent socket connections?

2009-05-22 Thread Pardee, Roy
Heh--you're welcome. But please don't let me bully you into dropping rails--I don't understand your goals as well as you do. ;-) I'm just trying to explain options. I frankly don't understand rails well enough to know when/how objects live beyond individual http requesst/response cycles. My

[Rails] Re: How to keep persistent socket connections?

2009-05-21 Thread Pardee, Roy
FWIW--you can use AR in a straight ruby program. Frx--something like this should work I think: require "rubygems" require "activerecord" require "sqlite3" ActiveRecord::Base.establish_connection(:adapter => 'sqlite', :database => '~/my_db.db') c = ::ActiveRecord::Base.connection

[Rails] Re: How to keep persistent socket connections?

2009-05-21 Thread Pardee, Roy
If I was you I'd ask how to do this over on comp.lang.ruby. My guess is you'll have a better time doing this entirely outside of rails. BTW--the first appendix of the pickaxe book covers ruby's socket library. If you haven't already looked at that, there could be some useful stuff in there...

[Rails] Re: Referencing 'constant' record in db

2009-05-21 Thread Pardee, Roy
At the risk of being nitpicky, @@variables are not globals--they are class variables. Globals vars start with a $. From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Colin Law Sent: Thursday, May 21, 2009 9:30 AM To:

[Rails] Re: DB field documentation suggestions wanted

2009-05-21 Thread Pardee, Roy
I think this is the tool you mean: http://agilewebdevelopment.com/plugins/annotate_models -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Perry Smith Sent: Wednesday, May 20, 2009 1:24 PM To: rubyonrails-talk@googlegrou

[Rails] Re: Referencing 'constant' record in db

2009-05-21 Thread Pardee, Roy
First, consider whether it's worth worrying about this--it may be that rails' and/or the db's caching mechanisms make this not such a perf issue. That said, would it be feasible to not store this record in the db at all? Just make the constant a free-standing AR object? Something like: class

[Rails] Re: Overwhelmed with choices concerning Rails "best practices"

2009-05-20 Thread Pardee, Roy
Sazima's exactly right. When you're getting your "sea legs", ignore what the cool kids are doing and just learn the basics of the platform. Get yourself a book, install the version of rails it covers, dig in & write an application or two. Once you've got some experience under your belt you'l

[Rails] Re: Association through 2 intermediate Models

2009-02-27 Thread Pardee, Roy
I don't know if you can get there just w/HM=>T, but you can fake out the last link w/a custom method. This is working for me: class Article < ActiveRecord::Base belongs_to :feed_entry end class FeedEntry < ActiveRecord::Base belongs_to :feed has_many :articles end class Feed < ActiveRec

[Rails] rest-ish method for subsetting an index view?

2009-02-27 Thread Pardee, Roy
Hey All, My app keeps track of /people. A Person has a .typical_role property, which (right now) takes one of the following values: ["Programmer", "Investigator", "Project Manager", "Other"]. What's the best/easiest/neato-cool way to allow users to specify which subset of people they want to

[Rails] Re: One model active at a time

2009-02-19 Thread Pardee, Roy
How about a class method that takes the to-become-featured project as an argument? Something like: class Project < AR:Base validates_uniqueness_of :featured def self.make_featured(this_project) self.update_all("featured = false") this_project.featured = true this_project.save!

[Rails] Re: sparse tables seems to be an impossible term to search on google

2009-02-10 Thread Pardee, Roy
I suspect something like this could work--may be worth a shot. # Models class Table < AR:Base has_many :column_groups, :order => 'cg_num' has_many :rows, :order => 'rownum' def columns self.column_groups.map {|cg| cg.columns} end end class ColumnGroup < AR:Base belongs_to :table

[Rails] Re: ajax search feature works in FF but not IE

2009-01-28 Thread Pardee, Roy
feature works in FF but not IE Pardee, Roy wrote: > <%= observe_field('project_search', > :url => { :controller => "projects", :action => "index_search"}, > :update => "project-list", > ... > That partial renders a ta

[Rails] ajax search feature works in FF but not IE

2009-01-27 Thread Pardee, Roy
Hey All, I put a simple search box on my projects/index view, via the following observe_field call: <%= observe_field('project_search', :url => { :controller => "projects", :action => "index_search"}, :update => "project-list", :loading => "Element.show('search_spinner')", :com

[Rails] Re: cycle() not cycling in a partial

2009-01-26 Thread Pardee, Roy
Saturday, January 24, 2009 7:41 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: cycle() not cycling in a partial Pardee, Roy wrote: > I've got the below partial rendering each item of a collection to a table > row, with some nice ajax magic for hiding the row if the use

[Rails] cycle() not cycling in a partial

2009-01-23 Thread Pardee, Roy
Hey All, I've got the below partial rendering each item of a collection to a table row, with some nice ajax magic for hiding the row if the user clicks a link. It works very nicely, except for the bit that assigns the class= attribute to the tr tag. For some reason I can't figure out, every

[Rails] Re: helper for model?

2009-01-18 Thread Pardee, Roy
Ah, of course--thanks! I do want an instance method I think--want to call the generics from instance methods in the class. I will experiment. Thanks! -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Joshua Abbot

[Rails] Re: helper for model?

2009-01-16 Thread Pardee, Roy
clude MyModule end That seems to be a very neat and clean way to juggle these methods and DRY up your model code somewhat. -- Josh http://iammrjoshua.com Brandon Keepers wrote: > On Wed, Jan 14, 2009 at 8:26 PM, Pardee, Roy wrote: >> kid.attributes = atts >> I'd l

[Rails] helper for model?

2009-01-14 Thread Pardee, Roy
Hey All, I find I'm writing a ton of nearly identical model methods to support mass creation/update of child objects (a la the 'complex forms' series of railscasts). Stuff like: def existing_child_attributes=(updated_kids) children.each do |kid| unless kid.new_record? atts

[Rails] Re: Number of entries

2009-01-13 Thread Pardee, Roy
x = @results.empty? ? 1 : 0 -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of James Bond Sent: Tuesday, January 13, 2009 11:42 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: Number of entries How can I wri

[Rails] Re: radio buttons and whatnot

2009-01-13 Thread Pardee, Roy
Can't resist adding this gratuitous and unsolicited advice: If an application can only have one status at a time, resist any urge you might feel to store status in a series of boolean fields in applications. Instead, have your controller just store the id of the selected status in application

[Rails] Re: Passing data from action of cntrlr 1 to action of cntrlr 2

2009-01-08 Thread Pardee, Roy
Try something like: def create_visit(for_patient) # This populates patient_visit.patient_id w/the proper id value patient_visit = for_patient.visits.new # Note that I've changed the action from index to new--that's # the convention for actions that create new objects. redi

[Rails] Re: Styling rails elements

2009-01-07 Thread Pardee, Roy
I think the first doublequote around "red" is terminating the string in the first part of your ? : expresion. If it were me, I'd verbose that out some: <% if @tour_request.booked_datetime then %> Confirmed For: <%= @tour_request.booked_datetime %> <% else %> Date and time r

[Rails] Re: anyone know a good way to do a caption popup on mouseover?

2008-12-19 Thread Pardee, Roy
title= tag attributes maybe? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:rubyonrails-t...@googlegroups.com] On Behalf Of Scott Kulik Sent: Wednesday, December 17, 2008 9:18 PM To: rubyonrails-talk@googlegroups.com Subject: [Rails] anyone know a good way to do a cap

[Rails] Re: Saving a "final" version of a record.

2008-12-16 Thread Pardee, Roy
In the olden days we would do this sort of thing with db triggers and a 'journal' table--every UPDATE would result in a record_version field being incremented, and the pre-update version of the rec written out to a separate table. You can also keep all record versions in one table & put up a vi

[Rails] Re: Rails and Ruby behind proxy

2008-12-09 Thread Pardee, Roy
Try setting an environment variable like so: http_proxy=http://my.proxy.server.mycompany.com:port_number With the appropriate URI to your proxy server of course. HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Nicolas Alpi

[Rails] Re: error w/dynamic fixtures

2008-12-01 Thread Pardee, Roy
Sweetness--thanks! -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Frederick Cheung Sent: Thursday, November 27, 2008 4:59 AM To: Ruby on Rails: Talk Subject: [Rails] Re: error w/dynamic fixtures On Nov 26, 10:49 pm, "P

[Rails] Re: The verdict on Rails scaffolding

2008-12-01 Thread Pardee, Roy
Ah, that scratched an itch for me--thanks for posting that. Cheers, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of David A. Black Sent: Sunday, November 30, 2008 12:39 PM To: Ruby on Rails: Talk Subject: [Rails] Re: The verdict on

[Rails] error w/dynamic fixtures

2008-11-26 Thread Pardee, Roy
Hey All, I'm trying to do the basic test/unit stuff & having trouble w/a dynamic fixture error. I'm running rails 2.0.2 on windows. I have statuses & projects. Projects belong_to status and so forth. # statuses.yml === active: name: Active description: MyString # project

[Rails] making arrays of valid values user-editable--best practice?

2008-11-25 Thread Pardee, Roy
Hey All, I've got a couple of valid-value lists that I would keep as arrays in the appropriate model. So for instance: class Person < ActiveRecord::Base ROLE_NAMES = ['Admin Assistant', 'Programmer', 'Investigator', 'Project Manager', 'Other'] # blah blah blah end Now I need to c

[Rails] Re: Getting the number of years between two dates

2008-11-21 Thread Pardee, Roy
You can also do Time.now.year - other_date.year Cheers, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of gsterndale Sent: Thursday, November 20, 2008 11:26 PM To: Ruby on Rails: Talk Subject: [Rails] Re: Getting the number of yea

[Rails] Re: scaffold not working like i hoped......

2008-11-10 Thread Pardee, Roy
Scaffolding is still built-in, but it won't look for existing tables when it builds the views. You've got to list out all your column_name:column_type pairs on the call to script/generate. It's a bummer, but there it is... From: rubyonrails-talk@googlegroups.co

[Rails] Re: Beyond frusterating date_select issue

2008-11-06 Thread Pardee, Roy
This may just be superstition talking, but I wonder if the problem is the names "from" and "to". Any difference if you make those, e.g., "from_date" and "to_date"? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Shandy Nantz Sent: Thur

[Rails] Re: select in form - best practice?

2008-11-06 Thread Pardee, Roy
I think Fred's given the preferred idiom. It's simple & it works. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of James Byrne Sent: Wednesday, November 05, 2008 12:03 PM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: select i

[Rails] Re: Using Inner/Outer join to eager fetch belongs_to associations

2008-11-05 Thread Pardee, Roy
for the responses. - Justin On Nov 4, 11:55 am, "Pardee, Roy" <[EMAIL PROTECTED]> wrote: > But is a plugin really required? Can't you feed something to find_by_sql > that will get you both types of objects? > > -Original Message- > From: rubyonrails-

[Rails] Re: Using Inner/Outer join to eager fetch belongs_to associations

2008-11-04 Thread Pardee, Roy
But is a plugin really required? Can't you feed something to find_by_sql that will get you both types of objects? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Frederick Cheung Sent: Tuesday, November 04, 2008 1:32 AM To: Ruby on Rail

[Rails] Re: integration with plone site--insane?

2008-11-04 Thread Pardee, Roy
Thanks! I wondered about that. Does OpenID do actual single-sign on, or is it more that you can use the same credentials from site to site? I think if I put my app out in the wild I'll try to do openid. The trick will be getting the contractor to make that an option for the plone site. They

[Rails] Re: Reverse keys and values in a hash

2008-11-03 Thread Pardee, Roy
http://www.noobkit.com/show/ruby/ruby/ruby-core/hash/invert.html -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Neal L Sent: Monday, November 03, 2008 2:35 PM To: Ruby on Rails: Talk Subject: [Rails] Reverse keys and values in a hash H

[Rails] integration with plone site--insane?

2008-11-03 Thread Pardee, Roy
Hey All, My group has a plone-based public web portal thingy that a contractor provides for us, w/all the usual CMS goodies (contacts; news items, hierarchical folder structure, etc.). Quite independently of that, they asked me to create a project/collaboration tracking application (who's inv

[Rails] Re: X is not missing constant Y

2008-10-30 Thread Pardee, Roy
Well don't leave us hanging--how'd you fix it? ;-) -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jamal Soueidan Sent: Thursday, October 30, 2008 7:35 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: X is not missing constan

[Rails] Re: Foreign key question

2008-10-29 Thread Pardee, Roy
I think ActiveRecord will expect this join condition to work: on members.id = invitation.member_id Would that work on your data? I think that in both of those association declarations, the :foreign_key argument names the field in the child table that should be linked to the pk of the parent

[Rails] Re: Passing a function with arguments to another function with arguments that is a loop

2008-10-29 Thread Pardee, Roy
You can create a pointer to your display_price method with a Proc object, e.g.: this_func = Proc.new {|groc, bat| display_price(groc, bat)} loop(this_func, batch) Your loop method invokes the actual function with the .call method, e.g.: def loop(func, matrix) # Note that .each will a

[Rails] Re: 'each' loop 2 times trough all records

2008-10-24 Thread Pardee, Roy
Huh--interesting, those two has_many :games calls in your Team class there. Does that result in a single @my_team.games collection property that gives the complete list of games, whether they were team_a or team_b? My intuition is that the second call would sort of overwrite the first & you w

[Rails] Re: 'each' loop 2 times trough all records

2008-10-24 Thread Pardee, Roy
Could the inclusion of the games records be multiplying the number of teams that get returned maybe? Any difference if you take :games out of that :include array there? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Thierry Delbart Se

[Rails] Re: Looking for doc on Find method

2008-10-24 Thread Pardee, Roy
http://www.noobkit.com/show/ruby/rails/rails-edge/activerecord-edge/activerecord/base/find.html -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Thierry Delbart Sent: Friday, October 24, 2008 12:49 PM To: rubyonrails-talk@googlegroups.com

[Rails] Re: Problem running back-to-back migrations

2008-10-24 Thread Pardee, Roy
Agree that scaffolding in 2.x is unnecessarily hobbled. FWIW--here's what I wound up doing: http://helloimbloggingatyounow.blogspot.com/2008/03/i-am-leet-rails-haxor.html or if that breaks: http://is.gd/4IRI It's worked reasonably well for me. -Original Message- From: rubyonrails-ta

[Rails] Re: Subtemplating with ERB

2008-10-23 Thread Pardee, Roy
Yikes. Good luck with that. ;) The only thing that comes to my mind is the :locals hash you can pass in a call to render :partial. But it'd probably be as much of a pain to figure out how to have your transliterator make those calls as it would be to have it put variable creation code in the

[Rails] Re: sorting in different ways (with the same index action)

2008-10-23 Thread Pardee, Roy
Ah, so you've got a grandchild object (sector). I just had a parent & one child. I bet you are close. Try this: @news_items = NewsItem.find(:all, :order => order_by, :include => ['stock', 'sector']) and in the view: <%= sort_link('Sector Name', 'sectors.name') %> (So--singular forms i

[Rails] Re: Subtemplating with ERB

2008-10-23 Thread Pardee, Roy
I would think partials would serve you (laying out vars populated in the appropriate controller). Have you looked at those at all? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Christo Karlson Sent: Wednesday, October 22, 2008 3:10 PM

[Rails] Re: Returning a record's ID before the record is made?!??

2008-10-23 Thread Pardee, Roy
You shouldn't have to worry about that. In this code: Product.transaction do @product.save! #<-- this saves the product, retrieving the db-assigned ID @details.product = @product #<-- this writes @product.id to @details.product_id @details.save! #<-- this sav

[Rails] Re: Reading Recommendation on Database Design?

2008-10-22 Thread Pardee, Roy
You want general db design, or design of a system that does access control via roles? (For the former, I like _Database Design For Mere Mortals_ by Hernandez.) -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Chris-Aix Sent: Wednesday, O

[Rails] Re: 3 different areas, 1 yield?!

2008-10-22 Thread Pardee, Roy
That should go into your layout (apps/views/layouts). -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Heinz Strunk Sent: Wednesday, October 22, 2008 10:01 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Re: 3 different areas, 1

[Rails] Re: sorting in different ways (with the same index action)

2008-10-22 Thread Pardee, Roy
Yeah, that's a problem I haven't actually tackled myself yet. :P If you notice, I did this: <%= sort_link('Status', 'status_id') %> Which does the sort by the numeric value of the id for the status, rather than the text the user sees. Very bush-league. So I fixed it just now ;-) like so:

[Rails] Re: Non-Ruby REST client for Ruby REST server

2008-10-22 Thread Pardee, Roy
> -Original Message- > From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf > Of James Salter > Sent: Tuesday, October 21, 2008 4:42 PM > To: rubyonrails-talk@googlegroups.com > Subject: [Rails] Re: Non-Ruby REST client for Ruby REST server > > > fervic wrote: > > I

[Rails] Re: Cleaner way to build a "one or the other" validation?

2008-10-22 Thread Pardee, Roy
How about: def validate_dealer_id if number.blank? then errors.add_to_base("You must specify either a Dealer Number OR a Sub Dealer Number.") if subnumber.blank? else erros.add_to_base("A dealer can't have both a dealer number AND a sub dealer number") unless subnumber.blank? end

[Rails] Re: Boolean database + Site Design/Architecture Question

2008-10-21 Thread Pardee, Roy
Well, you can still have those is_whatever? methods--just write them on the model your own self: class Child def is_lost? self.status == 'lost' end def is_found? self.status == 'found' end def is_safe? self.status = 'safe' end end You could even write your own setters (d

[Rails] Re: Boolean database + Site Design/Architecture Question

2008-10-21 Thread Pardee, Roy
I would go with a single 'status' field. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tony Tony Sent: Tuesday, October 21, 2008 12:59 PM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Boolean database + Site Design/Architecture

[Rails] Re: sorting in different ways (with the same index action)

2008-10-21 Thread Pardee, Roy
In my view I've got: <%= sort_link('Name', 'name') %> <%= sort_link('Grant number', 'grant_number') %> <%= sort_link('Status', 'status_id') %> The controller starts out with: def index order_by = params[:order_by] || 'name' @projects = Project.find(:all, :order => or

[Rails] Re: SQL OR in Rails

2008-10-21 Thread Pardee, Roy
I believe you can also do: @states = States.find_by_country([LOCALE, 'International']) Worth a try... Cheers, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Schalk Neethling Sent: Tuesday, October 21, 2008 5:12 AM To: rubyonra

[Rails] Re: sorting in different ways (with the same index action)

2008-10-21 Thread Pardee, Roy
I use this helper: def sort_link(show_text, sort_by) link_to show_text, {:action => 'index', :order_by => sort_by}, :class => 'big-link', :title => "Sort by #{show_text}" end One thing I haven't done & would like to is to have the app 'remember' what the previous sort order was, so tha

[Rails] Re: Can we create FTP users within Rails?

2008-10-20 Thread Pardee, Roy
Does anybody else get the heebie-jeebies at the thought of running a web app under a user account w/perms enough to create FTP users? ;-) Have you considered other methods for empowering your users to move files back & forth to your server (e.g., attachment_fu)? If that would suit, you'll pro

[Rails] Re: Documentation for building an XML-RPC service with Rails 2

2008-10-17 Thread Pardee, Roy
Looks to me like there's about a half a page on XML-RPC, at the beginning of the chapter on ActiveResource--it's discussed as an alternative to ActiveResource. Not a ton there... -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of helzer S

[Rails] Re: 3 / 2 is 1?

2008-10-17 Thread Pardee, Roy
That's a common ruby gotcha. Division of integers results in an integer. To fix, convert one or both numbers to floats with .to_f or include a decimal place on the literal (e.g., 3.0/2) HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On

[Rails] Re: Removing values from a select (drop-down) box

2008-10-17 Thread Pardee, Roy
y to do this in one query? > > > That depends entirely on what's in your can_edit function. If your controller is doing an Account.find() to populate your @account var, you may be able to avoid the extra queries by throwing a :include => 'clients' on there... > Fre

[Rails] Re: Removing values from a select (drop-down) box

2008-10-16 Thread Pardee, Roy
Do clients have a .selected property or some such that you can use to figure out which clients are already selected? If so you could do, e.g., @account.clients.map{|c| !c.selected} I would think. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On

[Rails] Re: Raw SQL from a Rake Task

2008-10-16 Thread Pardee, Roy
Can you just shell out to whatever command-line tool your database supports for executing large sql files? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Joe Peck Sent: Thursday, October 16, 2008 12:36 PM To: rubyonrails-talk@googlegrou

[Rails] Re: Importing / Parsing Large Excel Files ?

2008-10-16 Thread Pardee, Roy
Other options include ruby's WIN32OLE and DBI libraries. For the former, you'll have to be running on a machine w/excel installed. You'd use the latter on a windows machine to read the spreadsheets in via ODBC. Your connect string would be *something* like: connection_string = "dbi:ADO:" +

[Rails] Re: Keep getting "Undefined local variable or method" when creating a new rails application

2008-10-16 Thread Pardee, Roy
I think your problem is that you used the plural "courses" on your call to script/generate scaffold. That generator wants a *singular* noun. So do a: rake db:rollback and script/destroy scaffold courses followed by a: script/generate scaffold course title:string description:text cou

[Rails] Re: login from token

2008-10-15 Thread Pardee, Roy
If you want navigation to a URL to actually log a specific person in, the tokens will have to be person-specific, won't they? What do you imagine the mechanics would be for getting a sending user to generate one of those URLs? Are you trading recipient-convenience for sender-inconvenience? Wo

[Rails] Re: Small regular expression question

2008-10-15 Thread Pardee, Roy
Google's your friend here. "validate url with regular expression". -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Joe Peck Sent: Wednesday, October 15, 2008 7:45 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Small regular ex

[Rails] Re: avoiding "ruby script/server" and eliminating ":3000"

2008-10-15 Thread Pardee, Roy
Create an alias like so in your .bash_profile or wherever: alias rss='ruby script/server --port:80' HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alejandro Mansilla Sent: Wednesday, October 15, 2008 8:19 AM To: rubyonrail

[Rails] Re: best-practice for programmatically using rxml generated from controller/view? (or 'how can I view a view from a model')

2008-10-14 Thread Pardee, Roy
ActiveResource is supposed to be good for this sort of thing, isn't it? Can you use that? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Nate Murray Sent: Tuesday, October 14, 2008 1:16 PM To: Ruby on Rails: Talk Subject: [Rails] best-

[Rails] Re: Searching - weird behavior with certain letters

2008-10-14 Thread Pardee, Roy
What does the resulting SQL look like in your log? -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of infinteVerve Sent: Tuesday, October 14, 2008 10:44 AM To: Ruby on Rails: Talk Subject: [Rails] Searching - weird behavior with certain lett

[Rails] Re: Trying to replace some .find calls with better code

2008-10-14 Thread Pardee, Roy
Try: @lost_children = @user.children.select {|c| c.is_lost} -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Tony Tony Sent: Tuesday, October 14, 2008 6:17 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Trying to replac

[Rails] Re: Searching on two table fields

2008-10-13 Thread Pardee, Roy
link_to "click me" :controller => 'some_controller', :action => 'my_action', :this_recipe_id => @recipe, :this_meal_id => @meal But depending on where you put that link there are probably shorthands you can use. HTH, -Roy -Original Message- From: rubyonrails-talk@googlegroups.com [ma

[Rails] Re: Searching on two table fields

2008-10-13 Thread Pardee, Roy
I believe e.g., Recipe.find_by_diet_id_and_meal_id(12, 34) should work. -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Martin Evans Sent: Monday, October 13, 2008 8:01 AM To: rubyonrails-talk@googlegroups.com Subject: [Rails] Searching o

[Rails] Re: has_many / belongs_to associations

2008-10-13 Thread Pardee, Roy
Nah, you can set a parent from a child. Dig it: >> hh = Album.new(:title => "Houses of the Holy", :artist => "Led Zepplin") => # >> hhr = Review.new(:title => "Led Zep's new album rocks", :review_body => "Best. Album. Ever.") => # >> hh.save => true >> hhr.save => true >> hh

[Rails] Re: ajax complex forms: checkbox weirdness

2008-10-10 Thread Pardee, Roy
I don't suppose it's as simple as not calling the check_box helper from the form object you're getting out of fields_for is it? I would guess that's what would happen if you did... -Original Message- From: rubyonrails-talk@googlegroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Danima

[Rails] Re: has_many validation the Rails way

2008-10-09 Thread Pardee, Roy
Is this the multiple-models-one-form problem? If so, see this & the prior 2 railscasts: http://railscasts.com/episodes/75-complex-forms-part-3 The problem that's not treated in those (IIRC) is how to give informative error messages when child item validation fails. IIRC, you get *something*

[Rails] Re: validates_presence_of and a blank form...

2008-10-09 Thread Pardee, Roy
One way to make this happen is to do a redirect in the controller after Model.save or Model.update_attributes rather than a render back to the new or edit action. Could that be your problem? (If that's not clear, post the update method of the appropriate controller.) HTH, -Roy -Original

  1   2   >