ruby on rails - How to have a route accessed only from code and not from URL -
i see when name route in config file, like:
match 'controller/posts' => 'controller#posts', :as => 'posts'
it creates named route controller action.
but route needs accessed code. when click on posts button view, should execute user.
but when executes www.xyz.com/posts, should not try execute this. possible ?
i'm not sure why go way. sounds want able call specific bit of code controller. route won't work reasons mentioned (it available on browser).
instead, should extract bit of code , put in it's own library.
lib/foobar.rb:
module foobar def my_method # add code here end end
then can call whereever want in code.
Comments
Post a Comment