Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
You have to redefine all of your database tables in the Ruby code.

Erm, what? Presuming your tables conform to the Rails conventions (granted that is a substantial caveat when dealing with existing schemas and is an acknowledged weakness of Rails) you need one two line file for each stand alone table. Any relationships between tables are then specified within this class declaration.

class User < ActiveRecord::Base has_many :projects end

With Class::DBI you'd have to have MyDB::User->has_many( projects => "MyDB::Project" ) declarations somewhere to do the same thing, so I don't really see how this is really a substantial deficiency.

Update: Just to clarify, the above declaration would suffice to get a User class which has accessors for all columns of the users table in the default database; it would also setup relationship so that a_user.projects would return an array of Project instances associated with the User instance in question (presuming of course there were an appropriate Project class with a belongs_to :user declaration). If the DB doesn't adhere to Rails' expectations as far as table and primary key names it's pretty simple to correct it (set_table_name "web_user_names"); similar options are available for foreign key names (Class::DBI has similar expectations and mechanisms for allowing variation from them). Additionally, there are code generators which will write the stubs for you so you just run script/generate model User once when creating your app and the grunt work is done; you just go in and add the relationship information.


In reply to Re^2: OT: Ruby On Rails - your thoughts? by Fletch
in thread OT: Ruby On Rails - your thoughts? by Cody Pendant

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others cooling their heels in the Monastery: (4)
    As of 2020-12-03 01:44 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      How often do you use taint mode?





      Results (49 votes). Check out past polls.

      Notices?