Many thanks, Fred. Your comments were extremely helpful in that they make sense, but I don't understand them well enough to actually turn them into action steps - which suggests I am trying to do things I should not be (yet), hence my 'fishy' code.
I'll go back and start from scratch on a tutorial, then attack this project fresh later. Thanks again - SR On Dec 20, 10:48 am, Frederick Cheung <[email protected]> wrote: > On Dec 18, 3:18 pm, SMR <[email protected]> wrote: > > > > > Good morning All - > > > I am working on a time tracking application as a learning excercise > > and have run into an error neither I nor Google can remedy. > > > When loading my view, I get an error: 'undefined method > > 'true_class_path' for #<ActionView::Base:......... > > > Context: > > > I have controllers for Project, Worktrack and 'Workbench', among > > others. Workbench is where users would actually assign Worktracks to > > projects. There is no 'Workbench' table - I created just a controller > > for it, based on the 'Cart' controller in Agile Web Development. > > Project and Worktrack have complete scaffolds. > > > Workbench View code: > > > <%= button_to "Add Worktrack", assign_worktrack(project) %> > > > Workbench Controller code: > > > def assign_worktrack(project_identifier) > > project_identifier.worktracks << Worktrack.new(:status => "Not > > Started") > > project_identifier.save > > end > > > I am struggling with the following: > > > 1. Google-ing true_class_path in almost any context provides no useful > > information - I'm not sure what the error even means, aside from the > > name, and I can't figure out an action based on having an apparently > > bad path. Diagnosis hints would be much appreciated. > > > 2. In the 'proper MVC / Rails' realm - should my method be in the > > controller, or somewhere else? I tried moving it to the > > projects_helper and application_helper files assuming that this would > > help Rails connect the dots to the appropriate path, but that did not > > work and 'felt wrong'. > > > 3. My code is probably suboptimal - like I said, I'm just learning RoR > > and Ruby. Suggestions in that realm, especially if I have anything WTF- > > worthy are welcome. > > > To me, this whole issue smells like "I put my code in the wrong place > > and confused Rails", but I can't get any further. > > Rails tries to be helpful to you - if you say something like > redirect_to @book (or link_to 'Show', @book, form_for @book etc...) > and @book is an instance of Book, then rails assumes that you have set > up routes for books and that it should use the book_path helper to > generate the relevant url. > > It sounds like somewhere in your code (follow the stack trace from > your error), you are giving Rails the value true where it expected you > to supply an active record object ( Rails sees the value true, which > is the singleton instance of the class TrueClass and so, by its logic > the url should be generated by true_class_path). > > In particular button_to is a method like this - what value are you > passing it ? (Ie what is the return value of assign_worktrack ?( > > Beyond the actual error, that code looks really fishy - > assign_worktrack will be called at the point that the view is rendered > (not when the button is clicked). If you're doing things in the true > rails/restful spirit then worktracks would probably be a nested > resource of projects and so project_worktracks_path(project) would > return the path for listing/creating worktracks for that project (This > may or may not be true - it don't know your data or how it all fits > together). > > Fred > > Fred > > > > > Any help or insight would be much appreciated. > > > Thanks in advance for your time - > > > SR- Hide quoted text - > > - Show quoted text -- Hide quoted text - > > - Show quoted text - -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

