THis will be a very useful recipe to share...

On Tue, Jan 8, 2013 at 2:26 AM, Ignacio Huerta <[email protected]> wrote:

> Hi Drew,
>
> El 08/01/13 06:55, Drew Hamilton escribió:
>
>  Hello all,
>>
>> Thank you for all your suggestions.  I know it's been a while but I was
>> on a road/sea trip for several weeks without reliable access to the
>> Internet, so I would just work for a while, get stuck, and then wait
>> until I next had Internet to look up what the problem was so I could
>> keep going.
>>
>> Here is where I am at, and it's led to more questions:
>>
>> 1. I have a "data uploads" model that contains the uploaded file itself.
>>
>> 2. Each data_upload has_many "import rows"; the import rows table is
>> just a "square" table of text that the Excel file gets parsed into.
>>
>> 3. There is a lifecycle action on the data uploads table that takes
>> "uploaded" rows and turns them into "parsed" rows -- that essentially
>> makes several "import rows" based on the uploaded data.
>>
>> 4. My "real" model (not the Import stuff) has computer manufacturers and
>> model numbers.  Each table also has an "aliases" table ("HP", "Compaq",
>> "HP/Compaq" are all aliases for "Hewlett Packard", for example).  I made
>> methods on the models that would look up records "by name or alias".
>>
>> 5. Another lifecycle action on the data uploads table turns "parsed"
>> rows into "imported" ones, by checking for the existence of
>> manufacturers or models, and creating them if they do not exist yet.
>>
>> Now I have more questions:
>>
>> 1. Is there any way to programatically "back out of" changing states in
>> a lifecycle, if something goes wrong along the way?  Or having a single
>> action decide halfway which of two possible states that should be the
>> result.  During development I am just changing things back directly in
>> the database, but it seems like the state gets changed at the beginning
>> of the action.
>>
>
> I'm not sure how to do this in the model, but I guess you could use
> something like this in the controller:
>
>   def do_my_transition
>     invoice = Invoice.find(params[:id])
>     if (... some conditions ...)
>       do_transition_action :my_transition
>     else
>       flash[:error] = "There has been an error"
>       redirect_to(:action => 'show')
>     end
>   end
>
>
>
>
>> 2.  Each manufacturer has_many manufacturer_aliases and also has_many
>> models.  manufacturer_aliases and models both have create auto_action
>> for manufacturers, but only one of them works.  Which one works depends
>> on which one is the first "children" of manufacturer.  Is this expected
>> behaviour?
>>
>
> Yes, I think so. The automatic generator that creates
> app/views/taglibs/auto/pages.**dryml only prepares the form for the first
> one. But you should be able to add another form in show.dryml. Just take a
> look at the automatic page and see if you can reuse that. Ask if you get
> stuck :).
>
>
>
>> 3.  Is there any way to interact with the user in the middle of the
>> lifecycle action?  Rather than just blindly creating new entries for
>> things that it comes across and can't find, I'd like to ask whether it's
>> a new manufacturer or an alias of an existing one.
>>
>
> I'm not sure how your code looks like now, but I'm pretty sure you can do
> this in the model or controller levels. If you don't see how, please post
> the code that created the new records during the transition.
>
> Regards,
> Ignacio
>
>
>
>
>> Thanks,
>>
>>   - Drew
>>
>> On Wednesday, November 21, 2012 9:57:59 PM UTC+9, Drew Hamilton wrote:
>>
>>     Hi all,
>>
>>     First off, a very quick introduction of where I'm coming from,
>>     skill-level-wise:  I'm a complete neophyte with both Rails and Hobo,
>>     although I'm familiar with Ruby.  I do understand web development,
>>     MVC architecture, OOP, etc., and have used a variety of platforms
>>     and frameworks.
>>
>>     My company needs a small internal database to keep track of
>>     contracts, and I'm using that as an opportunity to learn Rails.  I
>>     was attracted to Hobo because it seems like it will eliminate a lot
>>     of the "busy work" involved in making an application.
>>
>>     I did the Agility tutorial, and also followed along with my own
>>     application.  Indeed, I was amazed at how I needed to do little more
>>     than declare my model to have a full application up and running.  I
>>     also did some work at changing some of the cards for my application,
>>     just to show that I can, although I prefer not to do a whole lot of
>>     that until the application is more complete than it is.
>>
>>     Where I'm stuck now is that after the tutorial, I have an app that
>>     allows users to enter and view data, but I don't have a really good
>>     understanding of how to make it do things programmatically.
>>
>>     In my specific case, the contract data in my application really only
>>     needs to be *viewed*; the data itself should be uploaded once per
>>     month from a CSV file and then cleaned up, have the uploader
>>     notified of problem rows, etc.  I used Paperclip and made a model
>>     that would take the raw CSV files, and I also made a model to hold
>>     the actual data from the files.
>>
>>     Parsing the CSV isn't the problem; I'm sure there are many Ruby
>>     libraries that can help.  What I don't know is
>>
>>     - If I wanted to make a link in the "uploaded csv file" page that,
>>     when clicked would run code, how do I make that link?  And where
>>     does the code itself go?
>>     - How do I access the data (not the CSV file; I mean how do I make
>>     new records; how do I search existing records, etc.) from that code?
>>
>>     I'm certainly not asking anyone to do my work for me; just hoping
>>     that someone could give me a link that I can read, or a link to a
>>     hobo-based project with public source code, etc. that would help
>>     point me in the right direction.
>>
>>     Thanks!
>>
>>       - Drew
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Hobo Users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/**msg/hobousers/-/8N0HtSC879wJ<https://groups.google.com/d/msg/hobousers/-/8N0HtSC879wJ>
>> .
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> hobousers+unsubscribe@**googlegroups.com<hobousers%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/**group/hobousers?hl=en<http://groups.google.com/group/hobousers?hl=en>
>> .
>>
>
> --
> Ignacio Huerta Arteche
> http://www.ihuerta.net
> Teléfono: 0034 645 70 77 35
> Email realizado con software libre
>
> --
> You received this message because you are subscribed to the Google Groups
> "Hobo Users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to hobousers+unsubscribe@**
> googlegroups.com <hobousers%[email protected]>.
> For more options, visit this group at http://groups.google.com/**
> group/hobousers?hl=en <http://groups.google.com/group/hobousers?hl=en>.
>
>


-- 
-Owen

*

Owen Dall

Vice President | Chief Technology Officer

Barquin International

www.barquin.com

Office: 202.296.7147 | Mobile: tel:410.991.0811

Fax: 202.296.8903 | email: [email protected]
*

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to