Re: I need help with routes.rb

Re: I need help with routes.rb

I recently switched to instant rails and it appears i dont have svn.

C:\InstantRails\rails_apps\track02>rake rails:freeze:edge(in C:/InstantRails/rails_apps/track02)C:/INSTAN~1/ruby/bin/rake.bat: No such file or directory - svn --versionERROR: Must have subversion (svn) available in the PATH to lock this application to Edge Railsrake aborted!exit How do you install svn so that it's 'in the path'.

Re: I need help with routes.rb

I dont know RyanB. Everything i am reading on edge rails is a bit over my head at the moment.I am learning how to program with ruby, most posts i have seen are people learning ruby who are already programmers. All I am trying to acheive at the moment with my project is;

I have the relashionships right (i think). They work in the console. such as i can create an object and then run say order.invoices << invoice and the invoice then gets the order_id and order.invoices gives me the order, the customer, the invoice ect(brilliant-I love it!)But,

How do i do this in the application, I want the user to be able to open an invoice and create lines for that particular invoice. The only way i know how to do this is with the select option in the view.

From my little experience i have found that the solution is usually simple but i havnt found it yet. I thought the url should be something like invoice/1/invoice_lines/something and that is why i was on the routes.rb track but maybe i was on the wrong track.

Re: I need help with routes.rb

What you were attempting to do in the first post is called RESTful design. It is for creating special URLs and mapping certain actions to them. In other words, it only changes how the URLs are presented, not much more than that.

You don't need to use map.resources (which is only available in edge rails currently) to get the order.invoices << invoice ability. In fact, this doesn't have anything to do with the URL, it is all handled by ActiveRecord which is at a lower layer that doesn't even know what the URL of the page is.

If you have the has_many/belongs_to association set up for Invoice and InvoiceLine models then you are partly there. The next step is probably adding a controller action or two which adds the invoice line to an invoice. If you provide more details on how you want it to behave I may be able to provide some code.

So for a_customer I would like to create an_order for a_customer and an_invoice. I think an_invoice would need to be saved regardless as invoice is the join model holding the id's of customer and order. Is this right?But first things first I would like to know more simply how to create a new whatever @whatever.So that for example when the user is at a_invoice and creates invoice_items they know they are for the invoice the user is at and the invoice_items inherit the id of the invoice.

Re: I need help with routes.rb

Thankyou Ryan,Im doing something wrong. The create_order action gives errors. If i create the invoice with the create customer action, that works but the the create_order link returns an error , undefined method "invoice". If i tell it to find the invoices it does but cant find the customer.If i create a customer alone and then create_order i get the error, you have nil object when i didnt expect it well by now i usually do expect it! anyway 'nil.create' it told me.The invoice table holds the id for customer and the order (the join model).I tried various things but all with errors. So close yet so far!Sorry for being such a spass!

Re: I need help with routes.rb

yes i sort of new that but everything i tried didnt work. OMG im really hopeless at this.The code you gave me i tried for the edit view as that is where i was sorry, should have said so.I still got the same error of nil.invoices.In the show veiw i got error couldnt find customer with id=88