[Rails] accessing from both ends of has many through relationship

2012-08-03 Thread Martyn W.
I have a 'has many through' relationship in my models. I am trying to access objects from either side of this relationship, with mixed results.Here are my models: class Material ActiveRecord::Base attr_accessible :description, :number has_many :parts has_many :work_tickets,

[Rails] Re: accessing from both ends of has many through relationship

2012-08-03 Thread Martyn W.
For %= work_ticket.material.number % I get undefined method `number' for nil:NilClass -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to

[Rails] Routing error: no route matches contoller works. Route exists though

2012-06-05 Thread Martyn W.
I have a fairly straight forward rails app, version 3.2. When I try to create a Work instance, with deliberately invalid fields from a form, I get a routing error: No route matches {:controller=works} This does not happen when I try the same test with an update on a Work instance. After an

[Rails] Re: Routing error: no route matches contoller works. Route exists though

2012-06-05 Thread Martyn W.
Hassan Schroeder wrote in post #1063180: On Tue, Jun 5, 2012 at 9:56 AM, Martyn W. li...@ruby-forum.com wrote: I dont understand why after failing the save in the controller and trying to render new it would give me a route matching error. Any ideas? Yes - look at the log for that request

[Rails] Re: Routing error: no route matches contoller works. Route exists though

2012-06-05 Thread Martyn W.
Martyn W. wrote in post #1063175: I have a fairly straight forward rails app, version 3.2. When I try to create a Work instance, with deliberately invalid fields from a form, I get a routing error: No route matches {:controller=works} This does not happen when I try the same test

[Rails] Re: Re: validation not called on create, only update

2012-06-04 Thread Martyn W.
Michael Pavling wrote in post #1062778: On 1 June 2012 04:31, flaps flaps2...@gmail.com wrote: THanks for your response. The validation methods are not called on a create, allowing the save method to be called, unprotected. I dont want the save to be called let alone fail. Is there any

[Rails] Re: Re: validation not called on create, only update

2012-06-04 Thread Martyn W.
Martyn W. wrote in post #1063043: Michael Pavling wrote in post #1062778: On 1 June 2012 04:31, flaps flaps2...@gmail.com wrote: THanks for your response. The validation methods are not called on a create, allowing the save method to be called, unprotected. I dont want the save to be called