Ruby on Rails Wednesday, June 30, 2010

I've written a routine for encoding and decoding custom urls.

My route looks like:

map.browse 'items/browse/*query', :controller => 'items', :action =>
'browse'

Now the param query is suposed to look something like:

manufactured_by_Sombody/is_tagged_this_and_that/is_tagged_foo_or_bar/
is_not_tagged_baz_and_nitch

Now I've got the routines built to decode this and turn it into a
thinking sphinx search hash, and I have the code to turn the TS hash
into that url. My problem is, I need access to that code in both the
controller and the view, where is the best place to put this code so
it is accessible in those two locations without repeating the code.

Is there a better way to do this, becaue at the moment in order to
form links I am using code like

link_to "foo", browse_url(:query => parse_browse_url(hash))

I'd appreciate any input.

-Brian

--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment