Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

url - Normalizing params a named route in rails -


i'm again, wrestling rails 3 , routes.

here problem:

i created named route 1 example:

match '/download/artist/:artist/album/:albumname', :to => "albums#show", :as => :search, :via => :get gives me route: search_path

i have classic 1 this: get "albums/show" gives me route: albums_show_path .

however, when i'm using search_path parameters this:

<%= link_to "#{result.name[0..50]}(...)", search_path(:artist =>result, :albumname => result.name), :class => "albumname" %>

, fails, not albums_show_path. here error:

no route matches {:controller=>"albums", :action=>"show", :artist=>"eddie vedder & ben harper", :albumname=>"my city of ruins / father's house (live) [benefiting artists peace , justice haiti relief] {digital 45}"}

i know because albumname parameter not escaped. after trying escape cgi.escape, doesn't work. suppose have in route.rb, have no clue how.

do have idea on how it?

edit

the error says: no route match etc. when don't have parameter illegal characters, find route.

** edit rake routes **

welcome_index /welcome/index(.:format) {:controller=>"welcome", :action=>"index"} albums_index /albums/index(.:format) {:controller=>"albums", :action=>"index"} albums_show /albums/show(.:format) {:controller=>"albums", :action=>"show"} search /download/artist/:artist/album/:albumname(.:format) {:controller=>"albums", :action=>"show"} albums_show_album_info /albums/show_album_info(.:format) {:controller=>"albums", :action=>"show_album_info"} albums_show_itunes /albums/show_itunes(.:format) {:controller=>"albums", :action=>"show_itunes"} albums_show_spotify /albums/show_spotify(.:format) {:controller=>"albums", :action=>"show_spotify"} albums_show_carrefour /albums/show_carrefour(.:format) {:controller=>"albums", :action=>"show_carrefour"} root /(.:format) {:controller=>"welcome", :action=>"index"}

you swap out illegal characters (whichever ones like) gsub:

<%= link_to "#{result.name[0..50]}(...)", search_path(:artist =>result, :albumname => result.name.gsub("/","\/").gsub("whateverelse", "newvalue"), :class => "albumname" %> 

i think because / interpreted denoting path separation (i forget true name of it) in urls. can "daisy-chain" gsub if want; see above.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -