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.

ruby - Rails helper method that works differently in different environments -


in ruby on rails application, have controller i'd functionality conditionally run, condition dependent on environment application running in. contrived example, in development mode i'd do:

if foo == 5:     ... end 

and in production mode, i'd like:

if foo > 6:     ... end 

the difference between 2 conditions more complicated single constant (5 or 6 in example above).

what idiomatic way in rails? write helper methods directly in environments/ files? or add method application controller checks current environment? or else?

i add check env['rails_env'] in logic statements.

http://guides.rubyonrails.org/configuring.html#rails-environment-settings

i change code to:

if foo == 5 && env['rails_env'] == "development"     ... elsif foo > 6 && env['rails_env'] == "production"     ... end 

it condition in flow-control, no need complicate it.

if need lot, few methods in application.rb help:

def isdev     env['rails_env'] == "development" end  def isprod     env['rails_env'] == "production" end 

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 -