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.

class - Calling another ruby file that is not a gem -


i want create static ruby class library of function. on vista ruby 1.9.2

my class 1 :

class testclass    def say_hello     puts "say hello"   end end 

in testclass.rb file (i assume correct ruby tutorials on classes complete mess putting in single magic (file?) if irb begining , end of thing).

my ruby main() (yes come java) or program entry or wathever called in ruby :

require 'testclass.rb'  puts "start" say_hello 

but fails :

c:\ruby_path_with_all_my_classes>ruby classuser.rb <internal:lib/rubygems/custom_require>:29:in `require': no such file load --  testclass.rb (loaderror)     <internal:lib/rubygems/custom_require>:29:in `require'     classuser.rb:1:in `<main>' 

how work? possible call other files in ruby or trapped in 1 file containing classes?

in 99% of cases when computer tells couldn't find thing, because thing isn't there. so, first thing need check whether there is file named testclass.rb somewhere on filesystem.

in 99% of rest of cases, computer looking in wrong place. (well, actually, computer looking in right place, thing looking in wrong place). require loads file $load_path, have make sure directory file testclass.rb in is on $load_path.

alternatively, if not want require file $load_path rather relative position of file doing requireing, need use require_relative.

note, however, code won't work anyway, since say_hello in instance method of instances of testclass class, calling on main object, instance of object, not testclass.

note standard naming conventions of ruby files snake_case, in particular, snake_case version of primary class/module of file. so, in case, file should named test_class.rb. also, require , require_relative figure out correct file extension themselves, should leave off .rb. , thirdly, standard ruby coding style 2 spaces indentation, not four.

none of these lead code not working, of course, since purely stylistic, may lead people being unwilling answer questions, since shows don't respect community enough learn basic rules.


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 -