class AssigneesController < ApplicationController def assignees Assignee.class_eval %Q{ def assignee_name self["#{params[:assignee_by]}"] end } end def do_assignee_cleaning Assignee.assignee_name redirect_to assignee_cleaning_project_assignees_path(params[:project_id]) end end I want to use assignee_name method in do_assignee_cleaning action but i am getting error undefined method `assignee_name'' for class `Assignee'' in do_assignee_cleaning -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> class AssigneesController < ApplicationController > def assignees > Assignee.class_eval %Q{ > def assignee_name > self["#{params[:assignee_by]}"] > end > } > end > def do_assignee_cleaning > Assignee.assignee_name > redirect_to > assignee_cleaning_project_assignees_path(params[:project_id]) > end > > end > I want to use assignee_name method in do_assignee_cleaning action but i am > getting error undefined > method `assignee_name'' for class `Assignee'' in do_assignee_cleaningIn an effort to understand the question (not having used class_eval) I found the following link that suggests, rather non-intuitively, that you should be using instance_eval rather than class_eval. http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
sorry for mistake not Assignee.assignee_name Assignee.find(1).assignee_name On Tue, Jun 21, 2011 at 4:08 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > class AssigneesController < ApplicationController > > def assignees > > Assignee.class_eval %Q{ > > def assignee_name > > self["#{params[:assignee_by]}"] > > end > > } > > end > > def do_assignee_cleaning > > Assignee.assignee_name > > redirect_to > > assignee_cleaning_project_assignees_path(params[:project_id]) > > end > > > > end > > I want to use assignee_name method in do_assignee_cleaning action but i > am > > getting error undefined > > method `assignee_name'' for class `Assignee'' in do_assignee_cleaning > > In an effort to understand the question (not having used class_eval) I > found the following link that suggests, rather non-intuitively, that > you should be using instance_eval rather than class_eval. > > > http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ > > Colin > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Regards Mukesh Paras Singh -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2011 11:45, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> sorry for mistake not Assignee.assignee_name > Assignee.find(1).assignee_nameDo you mean that you have fixed the problem by that change, or that you had a mistake in the question you asked and with Assignee.find(1).assignee_name it still fails? Colin> > On Tue, Jun 21, 2011 at 4:08 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > class AssigneesController < ApplicationController >> > def assignees >> > Assignee.class_eval %Q{ >> > def assignee_name >> > self["#{params[:assignee_by]}"] >> > end >> > } >> > end >> > def do_assignee_cleaning >> > Assignee.assignee_name >> > redirect_to >> > assignee_cleaning_project_assignees_path(params[:project_id]) >> > end >> > >> > end >> > I want to use assignee_name method in do_assignee_cleaning action but i >> > am >> > getting error undefined >> > method `assignee_name'' for class `Assignee'' in do_assignee_cleaning >> >> In an effort to understand the question (not having used class_eval) I >> found the following link that suggests, rather non-intuitively, that >> you should be using instance_eval rather than class_eval. >> >> >> http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ >> >> Colin >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Regards > Mukesh Paras Singh > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
yes still fails Assignee.find(1).assignee_name On Tue, Jun 21, 2011 at 4:20 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> On 21 June 2011 11:45, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > sorry for mistake not Assignee.assignee_name > > Assignee.find(1).assignee_name > > Do you mean that you have fixed the problem by that change, or that > you had a mistake in the question you asked and with > Assignee.find(1).assignee_name it still fails? > > Colin > > > > > On Tue, Jun 21, 2011 at 4:08 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > >> > >> On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > class AssigneesController < ApplicationController > >> > def assignees > >> > Assignee.class_eval %Q{ > >> > def assignee_name > >> > self["#{params[:assignee_by]}"] > >> > end > >> > } > >> > end > >> > def do_assignee_cleaning > >> > Assignee.assignee_name > >> > redirect_to > >> > assignee_cleaning_project_assignees_path(params[:project_id]) > >> > end > >> > > >> > end > >> > I want to use assignee_name method in do_assignee_cleaning action but > i > >> > am > >> > getting error undefined > >> > method `assignee_name'' for class `Assignee'' in do_assignee_cleaning > >> > >> In an effort to understand the question (not having used class_eval) I > >> found the following link that suggests, rather non-intuitively, that > >> you should be using instance_eval rather than class_eval. > >> > >> > >> > http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ > >> > >> Colin > >> > >> -- > >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> To unsubscribe from this group, send email to > >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > >> For more options, visit this group at > >> http://groups.google.com/group/rubyonrails-talk?hl=en. > >> > > > > > > > > -- > > Regards > > Mukesh Paras Singh > > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > For more options, visit this group at > > http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- Regards Mukesh Paras Singh -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2011 11:56, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes still fails Assignee.find(1).assignee_namePlease don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message. Thanks. Can you post the full error message and the stack trace please along with the exact code (copy/paste rather than re-type). Colin> > On Tue, Jun 21, 2011 at 4:20 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 21 June 2011 11:45, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > sorry for mistake not Assignee.assignee_name >> > Assignee.find(1).assignee_name >> >> Do you mean that you have fixed the problem by that change, or that >> you had a mistake in the question you asked and with >> Assignee.find(1).assignee_name it still fails? >> >> Colin >> >> > >> > On Tue, Jun 21, 2011 at 4:08 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> > wrote: >> >> >> >> On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > class AssigneesController < ApplicationController >> >> > def assignees >> >> > Assignee.class_eval %Q{ >> >> > def assignee_name >> >> > self["#{params[:assignee_by]}"] >> >> > end >> >> > } >> >> > end >> >> > def do_assignee_cleaning >> >> > Assignee.assignee_name >> >> > redirect_to >> >> > assignee_cleaning_project_assignees_path(params[:project_id]) >> >> > end >> >> > >> >> > end >> >> > I want to use assignee_name method in do_assignee_cleaning action but >> >> > i >> >> > am >> >> > getting error undefined >> >> > method `assignee_name'' for class `Assignee'' in do_assignee_cleaning >> >> >> >> In an effort to understand the question (not having used class_eval) I >> >> found the following link that suggests, rather non-intuitively, that >> >> you should be using instance_eval rather than class_eval. >> >> >> >> >> >> >> >> http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ >> >> >> >> Colin >> >> >> >> -- >> >> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. >> >> To unsubscribe from this group, send email to >> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> For more options, visit this group at >> >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> > >> > >> > >> > -- >> > Regards >> > Mukesh Paras Singh >> > >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group at >> > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Regards > Mukesh Paras Singh > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
On 21 June 2011 11:56, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> yes still fails Assignee.find(1).assignee_nameI presume that you *have* called assignees before calling do_assignee_cleaning. Colin> > On Tue, Jun 21, 2011 at 4:20 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote: >> >> On 21 June 2011 11:45, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> > sorry for mistake not Assignee.assignee_name >> > Assignee.find(1).assignee_name >> >> Do you mean that you have fixed the problem by that change, or that >> you had a mistake in the question you asked and with >> Assignee.find(1).assignee_name it still fails? >> >> Colin >> >> > >> > On Tue, Jun 21, 2011 at 4:08 PM, Colin Law <clanlaw-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> >> > wrote: >> >> >> >> On 21 June 2011 11:11, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> > class AssigneesController < ApplicationController >> >> > def assignees >> >> > Assignee.class_eval %Q{ >> >> > def assignee_name >> >> > self["#{params[:assignee_by]}"] >> >> > end >> >> > } >> >> > end >> >> > def do_assignee_cleaning >> >> > Assignee.assignee_name >> >> > redirect_to >> >> > assignee_cleaning_project_assignees_path(params[:project_id]) >> >> > end >> >> > >> >> > end >> >> > I want to use assignee_name method in do_assignee_cleaning action but >> >> > i >> >> > am >> >> > getting error undefined >> >> > method `assignee_name'' for class `Assignee'' in do_assignee_cleaning >> >> >> >> In an effort to understand the question (not having used class_eval) I >> >> found the following link that suggests, rather non-intuitively, that >> >> you should be using instance_eval rather than class_eval. >> >> >> >> >> >> >> >> http://ilikestuffblog.com/2009/01/09/fun-with-rubys-instance_eval-and-class_eval/ >> >> >> >> Colin >> >> >> >> -- >> >> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. >> >> To unsubscribe from this group, send email to >> >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> >> For more options, visit this group at >> >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >> > >> > >> > >> > -- >> > Regards >> > Mukesh Paras Singh >> > >> > -- >> > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> > For more options, visit this group at >> > http://groups.google.com/group/rubyonrails-talk?hl=en. >> > >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> > > > > -- > Regards > Mukesh Paras Singh > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.
Curious why you would want to define the method that way, are you overriding the method assignee_name which is already defined in the Assignee class? If not, then why not define it directly in the model like this: def assignee_name(assigned_by) self["assigned_by"] end Controller method will be def do_assignee_cleaning Assignee.assignee_name(params[:assignee_by]) redirect_to assignee_cleaning_project_assignees_path(params[:project_id]) end -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/aVbAUtgf5QQJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks for your reply I thought class_eval method would permanently add assignee_name method to Assignee instance object and i can access from other action too. On Tue, Jun 21, 2011 at 5:20 PM, Chirag Singhal <chirag.singhal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>wrote:> Curious why you would want to define the method that way, are you > overriding the method assignee_name which is already defined in the Assignee > class? > If not, then why not define it directly in the model like this: > > def assignee_name(assigned_by) > self["assigned_by"**] > end > > Controller method will be > def do_assignee_cleaning > Assignee.assignee_name(params[:assignee_by]) > redirect_to assignee_cleaning_project_**assignees_path(params[:** > project_id]) > end > > -- >> You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/rubyonrails-talk/-/aVbAUtgf5QQJ. > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- Regards Mukesh Paras Singh -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2011 14:31, mukesh singh <mukesh23.singh-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thanks for your replyPlease don''t top post, it makes it difficult to follow the thread. Insert your reply at appropriate points in previous message. Thanks.> I thought class_eval method would permanently add assignee_name method to > Assignee instance object and i can access from other action too.I think it will, but only when you execute the class_eval code. Permanent means of course until you restart the server or reload the Assignee class. Since in development mode classes are reloaded at each action request it will not hold from one request to the next, if that is what you are trying to do. Even in production this is a bad thing to do as you never know when a server might get restarted and loose the data. Not to mention the fact that once in production successive actions are not necessarily even run by the same computer. If you want retain information from one action to the next then put it in the session or in the database, or in a hidden field in the intervening view. I think Chirag Singhal''s suggestion is better though unless there is some reason you cannot use it. Colin> > On Tue, Jun 21, 2011 at 5:20 PM, Chirag Singhal <chirag.singhal-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> >> Curious why you would want to define the method that way, are you >> overriding the method assignee_name which is already defined in the Assignee >> class? >> If not, then why not define it directly in the model like this: >> def assignee_name(assigned_by) >> self["assigned_by"] >> end >> Controller method will be >> def do_assignee_cleaning >> Assignee.assignee_name(params[:assignee_by]) >> redirect_to >> assignee_cleaning_project_assignees_path(params[:project_id]) >> end >> >> -- > > >> >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Talk" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/rubyonrails-talk/-/aVbAUtgf5QQJ. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. > > > > -- > Regards > Mukesh Paras Singh > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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.