this feels ugly

Discussion in 'Ruby' started by travis laduke, Feb 28, 2006.

  1. i better explain a little to get started.
    in my form for creating a Person, there's a Company field. People
    belong to companies and companies have many people.

    in my person form i have:
    <%= text_field 'person', 'Company' %>

    in my controller i have
    def create
    params['person']['Company'] = Company.find_by_name(params['person']
    @person =[:person])

    this seems ugly to me and makes me feel like this is not the best way.
    I'm doing this because expects Company to be a Company
    object not a string. params['person']['Company'] comes in from the
    form as "cutco" or "edgeslice" or whatever.

    Anyway, i'm using a text field instead of a select box, because
    select boxes with more that like 3 items are annoying to use. I'm
    going to autocomplete the company text field.

    how do people usually create new objects (and specify who they
    belong_to) from the child's (in this case Person) view/controller?

    travis laduke, Feb 28, 2006
    1. Advertisements

  2. oops, wrong list. so sorry.
    travis laduke, Feb 28, 2006
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.