I''m getting this error when I try to update a list using ajax after submitting some data: undefined method `time_ago_in_words'' for #<IdeaController:0x3a38ae8> the LOC is this: render_text "<li>" + @params[:idea][:title] + "<br />by " + @params[:idea][:author] + " | " & time_ago_in_words(Time.now) & " ago | " + "</li>" Is there something I''m missing? time_ago_in_words(Time.now) works in the view... thanks! k. -- Posted via ruby-forum.com.
On 8/17/06, kareem <blog@reemer.com> wrote:> I''m getting this error when I try to update a list using ajax after > submitting some data: > > undefined method `time_ago_in_words'' for #<IdeaController:0x3a38ae8> > > the LOC is this: > render_text "<li>" + @params[:idea][:title] + "<br />by " + > @params[:idea][:author] + " | " & time_ago_in_words(Time.now) & " ago | > " + "</li>" > > Is there something I''m missing? time_ago_in_words(Time.now) works in > the view... > > thanks! > > k. > > -- > Posted via ruby-forum.com. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails >Kareem, time_ago_in_words is a method from the helpers of active_view. Those methods are not directly exposed in your controller. You should resist the temptation to format a response in the controller. Pass objects to the view and let them take care of the format. This separation of model-view-controller will make testing easier and keep everything simple :) -- Zack Chandler depixelate.com
> You should resist the temptation to format a response in the > controller. Pass objects to the view and let them take care of the > format. This separation of model-view-controller will make testing > easier and keep everything simple :)Hi Zack, Thanks for the response. I''m formatting this data in response to an Ajax request, and want to update the page with the formatted data, but without a refresh. If this is possible, can you point me in the direction of how I would do this by passing an object to the view and formatting it there? Thanks much! -- Posted via ruby-forum.com.
If you use RJS templates to create your view in response to the request, you''ll be able to use the active_view helpers. Hammed RJS templates: codyfauser.com/articles/2005/11/20/rails-rjs-templates On 8/18/06, kareem <blog@reemer.com> wrote:> > > You should resist the temptation to format a response in the > > controller. Pass objects to the view and let them take care of the > > format. This separation of model-view-controller will make testing > > easier and keep everything simple :) > > Hi Zack, > > Thanks for the response. > > I''m formatting this data in response to an Ajax request, and want to > update the page with the formatted data, but without a refresh. > > If this is possible, can you point me in the direction of how I would do > this by passing an object to the view and formatting it there? > > Thanks much! > > -- > Posted via ruby-forum.com. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: wrath.rubyonrails.org/pipermail/rails/attachments/20060818/eda971d1/attachment.html
Hammed Malik wrote:> If you use RJS templates to create your view in response to the request, > you''ll be able to use the active_view helpers.This is perfect--thanks! -- Posted via 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 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 groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---