From the command line, Is it possible to run a particular method in a
view from a specified controller.
e.g.
class MyController < ActionController
  def test
  end
end
view.rhtml
<%= link_to :action => :test %>
rendered_html
<a href="/my/test">
I''d like to be able to get that from the command line:
StudentProfilesController.new.send(''link_to'', :action =>
test)
There are also a large number of other view commands i''d like to able
to
call, so just grabbing out link_to doesn''t solve the issue
Cheers!
-- 
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
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
-~----------~----~----~----~------~----~------~--~---
Sorry:
StudentProfilesController.new.send(''link_to'', :action =>
test)
was supposed to be:
MyController.new.send(''link_to'', :action => test)
-- 
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
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''ve tried:
a = MyController.new.view_class.new
a.send(''initialize_current_url'')
vx = MyController.view_class.new(StudentProfilesController.view_root, 
{}, a)
vx.link_to(:controller => ''test'', :action =>
''test'')
but because half the internals are not initialized it doesn''t work.
Would trying to simulate the request and response parameters?
ActionController::Base
def process(request, response, method = :perform_action, *arguments) 
#:nodoc:
-- 
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
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 12 Nov 2007, at 00:34, Alex Moore wrote:> > i''ve tried: > > a = MyController.new.view_class.new > a.send(''initialize_current_url'') > vx = MyController.view_class.new(StudentProfilesController.view_root, > {}, a) > vx.link_to(:controller => ''test'', :action => ''test'') > > but because half the internals are not initialized it doesn''t work.Have you seen this: http://snippets.dzone.com/posts/show/1799 Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote: [quote] Have you seen this: http://snippets.dzone.com/posts/show/1799 [/quote] That allows you to run view helper methods... specifically I''d like to be able to access view helper methods + route helpers edit_projects and be able to use url_for and link_to. I still haven''t worked out a way to do this.. i''m wondering if i''ll need to reimplement the process function of actioncontroller.base -- 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 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 13 Nov 2007, at 02:03, Alex Moore wrote:> > Frederick Cheung wrote: > [quote] > Have you seen this: http://snippets.dzone.com/posts/show/1799 > [/quote] > > That allows you to run view helper methods... specifically I''d like to > be able to access view helper methods + route helpers edit_projects > and > be able to use url_for and link_to.link_to is a view helper as is one version of url_for. You just need to figure out which modules to include (hint: search through the rails code base for the functions you would like to be accessible) Fred> > > I still haven''t worked out a way to do this.. i''m wondering if i''ll > need > to reimplement the process function of actioncontroller.base > > -- > 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 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 -~----------~----~----~----~------~----~------~--~---