Hi. In the episode 74 <http://railscasts.com/episodes/74>, Ryan has a model "project" that can have many "tasks", and he uses link_to_function to dynamically add a field in the form for a new Task. In order to do that he created a helper called add_task_link. The code of the method is: # projects_helper.rb def add_task_link(name) link_to_function name do |page| page.insert_html :bottom, :tasks, :partial => ''task'', :object => Task.new end end The problem i have here is that i can''t figure out where does this Task object, which he instantiate with Task.new in the line i highlighted, come from. Thanks, -- Guerra --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Task is a model that he have created before 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hi. > > In the episode 74 <http://railscasts.com/episodes/74>, Ryan has a model > "project" that can have many "tasks", and he uses link_to_function to > dynamically add a field in the form for a new Task. > > In order to do that he created a helper called add_task_link. The code of > the method is: > > # projects_helper.rb > def add_task_link(name) > link_to_function name do |page| > page.insert_html :bottom, :tasks, :partial => ''task'', :object => Task.new > > end > end > > The problem i have here is that i can''t figure out where does this Task object, > which he instantiate with Task.new in the line i highlighted, come from. > > > Thanks, > > -- > Guerra > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Oscar, thanks for answering. I understand that. I''m reproducing something very similar to what ryan does at the cast and i also have the corresponding model. In my app it''s called Client_phones. When i call Client_phone.new in the same place ryan does, i get an error that says that client_phones should have a method Client_phone. What would be that method? What am i missing here? My Client_phones model has only a belongs_to client up to now. Thanks, On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Task is a model that he have created before > > 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > >> Hi. >> >> In the episode 74 <http://railscasts.com/episodes/74>, Ryan has a model >> "project" that can have many "tasks", and he uses link_to_function to >> dynamically add a field in the form for a new Task. >> >> In order to do that he created a helper called add_task_link. The code of >> the method is: >> >> # projects_helper.rb >> def add_task_link(name) >> link_to_function name do |page| >> page.insert_html :bottom, :tasks, :partial => ''task'', :object => Task.new >> >> >> end >> end >> >> The problem i have here is that i can''t figure out where does this Task object, >> which he instantiate with Task.new in the line i highlighted, come from. >> >> >> >> Thanks, >> >> -- >> Guerra >> >> > > > >-- Guerra --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I can''t get in my mind the complete code, I can only suggest to copy (and understand) Ryan''s code, and then replace his models with yours 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>:> > Hi Oscar, > > thanks for answering. > > I understand that. I''m reproducing something very similar to what ryan does > at the cast and i also have the corresponding model. In my app it''s called > Client_phones. > > When i call Client_phone.new in the same place ryan does, i get an error > that says that client_phones should have a method Client_phone. > > What would be that method? What am i missing here? > > My Client_phones model has only a belongs_to client up to now. > > Thanks, > > On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> Task is a model that he have created before >> >> 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> >>> Hi. >>> >>> In the episode 74 <http://railscasts.com/episodes/74>, Ryan has a model >>> "project" that can have many "tasks", and he uses link_to_function to >>> dynamically add a field in the form for a new Task. >>> >>> In order to do that he created a helper called add_task_link. The code of >>> the method is: >>> >>> # projects_helper.rb >>> def add_task_link(name) >>> link_to_function name do |page| >>> page.insert_html :bottom, :tasks, :partial => ''task'', :object => Task.new >>> >>> >>> >>> end >>> end >>> >>> The problem i have here is that i can''t figure out where does this Task object, >>> which he instantiate with Task.new in the line i highlighted, come from. >>> >>> >>> >>> >>> Thanks, >>> >>> -- >>> Guerra >>> >>> >> >> >> > > > -- > Guerra > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 18 Jun 2008, at 13:17, Israel Guerra wrote:> Hi Oscar, > > thanks for answering. > > I understand that. I''m reproducing something very similar to what > ryan does at the cast and i also have the corresponding model. In my > app it''s called Client_phones. >That''s pretty much guarenteed to cause trouble. classes should be camelcased & singlular ie your class should be ClientPhone and be in client_phone.rb Fred> When i call Client_phone.new in the same place ryan does, i get an > error that says that client_phones should have a method Client_phone. > > What would be that method? What am i missing here? > > My Client_phones model has only a belongs_to client up to now. > > Thanks, > > On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben > <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Task is a model that he have created before > > 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > Hi. > > In the episode 74, Ryan has a model "project" that can have many > "tasks", and he uses link_to_function to dynamically add a field in > the form for a new Task. > > In order to do that he created a helper called add_task_link. The > code of the method is: > > # projects_helper.rb > def add_task_link(name) > link_to_function name do |page| > page.insert_html :bottom, :tasks, :partial => ''task'', :object => > Task.new > > > > > end > end > > The problem i have here is that i can''t figure out where does this > Task object, > which he instantiate with Task.new in the line i highlighted, come > from. > > > > > > Thanks, > -- > Guerra > > > > > > > > -- > Guerra > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Fred. The name of my model is Client_phone and the name of the class in it is "ClientPhone". I think its correct, since it was generated automatically. My code is exactly like Ryan''s, but for my models. I wrote every code as he shows in the episode 73 and 74. He never shows the code for The Task model, that would be my Client_phone. The call for Task.new i have doubts about, would return, in my opinion, an object representing what is the Task model, but i don''t know if i should implement the function in the model or not. And if i should, i don''t have any clues of what code would go in there. I''m at work now, later i can post my files here. Thanks for helping. On Wed, Jun 18, 2008 at 9:33 AM, Frederick Cheung < frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 18 Jun 2008, at 13:17, Israel Guerra wrote: > > > Hi Oscar, > > > > thanks for answering. > > > > I understand that. I''m reproducing something very similar to what > > ryan does at the cast and i also have the corresponding model. In my > > app it''s called Client_phones. > > > That''s pretty much guarenteed to cause trouble. classes should be > camelcased & singlular ie your class should be ClientPhone and be in > client_phone.rb > > Fred > > > When i call Client_phone.new in the same place ryan does, i get an > > error that says that client_phones should have a method Client_phone. > > > > What would be that method? What am i missing here? > > > > My Client_phones model has only a belongs_to client up to now. > > > > Thanks, > > > > On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben > > <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Task is a model that he have created before > > > > 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > > Hi. > > > > In the episode 74, Ryan has a model "project" that can have many > > "tasks", and he uses link_to_function to dynamically add a field in > > the form for a new Task. > > > > In order to do that he created a helper called add_task_link. The > > code of the method is: > > > > # projects_helper.rb > > def add_task_link(name) > > link_to_function name do |page| > > page.insert_html :bottom, :tasks, :partial => ''task'', :object => > > Task.new > > > > > > > > > > end > > end > > > > The problem i have here is that i can''t figure out where does this > > Task object, > > which he instantiate with Task.new in the line i highlighted, come > > from. > > > > > > > > > > > > Thanks, > > -- > > Guerra > > > > > > > > > > > > > > > > -- > > Guerra > > > > > > > >-- Guerra --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Someone who watched the cast, maybe can tell me what they think there is in the Task model that allows him to call the new procedure the way he does. Thanks. On Wed, Jun 18, 2008 at 11:48 AM, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Fred. > > The name of my model is Client_phone and the name of the class in it is > "ClientPhone". > > I think its correct, since it was generated automatically. > > My code is exactly like Ryan''s, but for my models. > > I wrote every code as he shows in the episode 73 and 74. He never shows the > code for The Task model, that would be my Client_phone. > > The call for Task.new i have doubts about, would return, in my opinion, an > object representing what is the Task model, but i don''t know if i should > implement the function in the model or not. And if i should, i don''t have > any clues of what code would go in there. > > I''m at work now, later i can post my files here. > > > Thanks for helping. > > > On Wed, Jun 18, 2008 at 9:33 AM, Frederick Cheung < > frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> >> >> On 18 Jun 2008, at 13:17, Israel Guerra wrote: >> >> > Hi Oscar, >> > >> > thanks for answering. >> > >> > I understand that. I''m reproducing something very similar to what >> > ryan does at the cast and i also have the corresponding model. In my >> > app it''s called Client_phones. >> > >> That''s pretty much guarenteed to cause trouble. classes should be >> camelcased & singlular ie your class should be ClientPhone and be in >> client_phone.rb >> >> Fred >> >> > When i call Client_phone.new in the same place ryan does, i get an >> > error that says that client_phones should have a method Client_phone. >> > >> > What would be that method? What am i missing here? >> > >> > My Client_phones model has only a belongs_to client up to now. >> > >> > Thanks, >> > >> > On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben >> > <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > Task is a model that he have created before >> > >> > 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: >> > Hi. >> > >> > In the episode 74, Ryan has a model "project" that can have many >> > "tasks", and he uses link_to_function to dynamically add a field in >> > the form for a new Task. >> > >> > In order to do that he created a helper called add_task_link. The >> > code of the method is: >> > >> > # projects_helper.rb >> > def add_task_link(name) >> > link_to_function name do |page| >> > page.insert_html :bottom, :tasks, :partial => ''task'', :object => >> > Task.new >> > >> > >> > >> > >> > end >> > end >> > >> > The problem i have here is that i can''t figure out where does this >> > Task object, >> > which he instantiate with Task.new in the line i highlighted, come >> > from. >> > >> > >> > >> > >> > >> > Thanks, >> > -- >> > Guerra >> > >> > >> > >> > >> > >> > >> > >> > -- >> > Guerra >> > > >> >> >> >> >> > > > -- > Guerra-- Guerra --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Probably I don''t understand, but .new() is a standard ruby method that''s available on every class. It''s how you create an instance of the class. So this is valid ruby: class MyClass end x = MyClass.new So... you don''t need to have anything in your class definition to be able to call .new() on it. ________________________________ From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Israel Guerra Sent: Wednesday, June 18, 2008 12:44 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: Object Task at episode 74 of railscasts Someone who watched the cast, maybe can tell me what they think there is in the Task model that allows him to call the new procedure the way he does. Thanks. On Wed, Jun 18, 2008 at 11:48 AM, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: Hi Fred. The name of my model is Client_phone and the name of the class in it is "ClientPhone". I think its correct, since it was generated automatically. My code is exactly like Ryan''s, but for my models. I wrote every code as he shows in the episode 73 and 74. He never shows the code for The Task model, that would be my Client_phone. The call for Task.new i have doubts about, would return, in my opinion, an object representing what is the Task model, but i don''t know if i should implement the function in the model or not. And if i should, i don''t have any clues of what code would go in there. I''m at work now, later i can post my files here. Thanks for helping. On Wed, Jun 18, 2008 at 9:33 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: On 18 Jun 2008, at 13:17, Israel Guerra wrote: > Hi Oscar, > > thanks for answering. > > I understand that. I''m reproducing something very similar to what > ryan does at the cast and i also have the corresponding model. In my > app it''s called Client_phones. > That''s pretty much guarenteed to cause trouble. classes should be camelcased & singlular ie your class should be ClientPhone and be in client_phone.rb Fred > When i call Client_phone.new in the same place ryan does, i get an > error that says that client_phones should have a method Client_phone. > > What would be that method? What am i missing here? > > My Client_phones model has only a belongs_to client up to now. > > Thanks, > > On Wed, Jun 18, 2008 at 9:09 AM, Oscar Del Ben > <thehcdreamer-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > Task is a model that he have created before > > 2008/6/18, Israel Guerra <israel.guerra-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>: > Hi. > > In the episode 74, Ryan has a model "project" that can have many > "tasks", and he uses link_to_function to dynamically add a field in > the form for a new Task. > > In order to do that he created a helper called add_task_link. The > code of the method is: > > # projects_helper.rb > def add_task_link(name) > link_to_function name do |page| > page.insert_html :bottom, :tasks, :partial => ''task'', :object => > Task.new > > > > > end > end > > The problem i have here is that i can''t figure out where does this > Task object, > which he instantiate with Task.new in the line i highlighted, come > from. > > > > > > Thanks, > -- > Guerra > > > > > > > > -- > Guerra > > -- Guerra -- Guerra --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Seemingly Similar Threads
- episode 73 resulting in error: undefined method `stringify_keys!' for "33":String
- add dynamic nested attributes without nested form gem
- link_to_function or button_to_function memory usage
- Sourcetrunk : OpenSSH episode
- Half Life 2 Episode 1 Audio and Fullscreen issues wine1.2rc7