Thanks . I am experiment by putting common code in a helper . How Do i access it from my controller. I tried to do ApplicationHelper::base64_url_decode in the ApplicationController bu I am getting method not defined. Any ideas? :)
module ApplicationHelper def base64_url_decode str encoded_str = str.gsub('-','+').gsub('_','/') encoded_str += '=' while !(encoded_str.size % 4).zero? Base64.decode64(encoded_str) end def decode_data str encoded_sig, payload = str.split('.') data = ActiveSupport::JSON.decode base64_url_decode(payload) end end On Sunday, December 16, 2012 2:20:45 AM UTC-8, Frederick Cheung wrote: > > > > On Dec 16, 9:24 am, rubyrookie <asajn...@gmail.com> wrote: > > I am doing a partial render in the view from one controller. Here is the > > code -> <%= render :template => 'restaurants/new' %>. I want the > other > > controller new action code to do it. Is there a way to call an action > in > > another controller ? I don't want to duplicate the same code in two > > controllers. > > In a nutshell, no. If you need to do this you might want to look at: > > - putting the shared code into a module > - putting it into a common ancestor of the 2 classes > - moving the functionality into a helper that both controllers can > share > - look at cells gem, which is one way of having reusable units of view > + code > > 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/_9lmzrjMNsMJ. For more options, visit https://groups.google.com/groups/opt_out.