You can load rails project in irb. for instance in your rail's project directory you start irb. Then you only need to require environment.rb file. Such as require 'config/environment.rb' in irb and thats it now you can access your project's model, etc.
Showing posts with label ruby. Show all posts
Showing posts with label ruby. Show all posts
Friday, April 10, 2009
Sunday, November 16, 2008
Use join method to merge Array into string
If you are a Ruby/Ruby on Rails developer.
Some times you need to concatenate/ merge Array elements into String, so its good to use join (Array method).
E.g;
users_id = Array.new
#Add some ids into array, so it becomes,
users_id = [1001,1002,1003,1004,1005]
#Now use need all users ids in to lets say in query so just do,
#users_id.join(",") this will return String type object having users ids
users_id.join(",")
# "1001,1002,1003,1004,1005"
Some times you need to concatenate/ merge Array elements into String, so its good to use join (Array method).
E.g;
users_id = Array.new
#Add some ids into array, so it becomes,
users_id = [1001,1002,1003,1004,1005]
#Now use need all users ids in to lets say in query so just do,
#users_id.join(",") this will return String type object having users ids
users_id.join(",")
# "1001,1002,1003,1004,1005"
Subscribe to:
Posts (Atom)