[Rails] Re: Agloco online jobs and work at home and work from home india

2012-10-01 Thread Bahar P.
Hi,I heard about your website and I only searched by google to see what 
is it.I was asked to logged in, so as I have Yahoo Email address,I 
logged in.Well I know nothing about your website, I only read this page, 
then I'm asked to reply! I really don't know what should I write and 
what is this reply for!? I will appreciate it if you let me know what is 
this?and what you want me to do?

Regards
Bahar Hamzehpour
Pune,Maharashtra,India

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Run ruby web app from command line

2012-10-01 Thread Sta Canovist
Hello

I made a quite simple ruby web app. It uses scrubyt and mysql to store
results as cached results. The program is quite simple. It shows a
form, you enter a value and the controller makes an external http
call, parse the data and show the result for the user.

But I have a problem. I have the requirement to let a ruby program
from command line more or less run the same function that on web is
been handled by the form controller.

How can I re-use the web app when doing a standalone program callable
from command line? I dont want to recode as all the app is already
functioning. I am requested to do a ruby program that is called like
this:

ruby ./client.rb some_param

Where should I put this client.rb? How do I use the code from the
application that runs on the web?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] How to properly setup multiple databases?

2012-10-01 Thread Bradford Smith
I've setup my application to connect to multiple databases, but am running 
into a few issues in production.  I also have a few questions.

First, I'm using rails 3-2-stable, because I was running in to a prepared 
statement bug, which is only fixed in this branch [1].  I'm not up for 
using master at this time, unless I absolutely need to.

Second, the pool size for the default and non-default database is 1, this 
is because I'm using unicorn.  Also, because establish_connection on 
multiple databases does not use the pool size [2].

The issue:

I have 4 unicorn workers.  After I start the app and rapidly refresh on a 
few pages, the default database sees 4 connections.  The non-default 
database sees only 1.  And for the lifetime of the app, the non-default 
database only sees one connection. I also think this is slowing down the 
website.

1) What would cause the application to create only one connection for the 
non-default database, provided I have 4 workers?  When I create a sample 
app on my local machine that uses the same configs with different code, I 
actually get 4 connections for both.  See my unicorn file here:  
https://gist.github.com/3807073.  All my non-default database models 
inherit from something that looks like:

class OtherDb  ActiveRecord::Base
  self.abstract_class = true
  establish_connection other_#{Rails.env}
end

2) What's the proper way to setup a unicorn.rb file for multiple databases 
with `preload_app true`, since I have establish_connection in the OtherDb 
model and need to establish_connection to the default in the after_fork?

3) Should I be looking into a different rack web server?  My queries are 
sub 500ms.

[1] https://github.com/rails/rails/pull/5872
[2] https://github.com/rails/rails/issues/7019

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/xbXCsD-xXJ0J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Protecting certain model attributes from being exposed in an API

2012-10-01 Thread Jeremy Baker
In my current project, there are business and security requirements that 
prevent certain values from being exposed. I was looking for a way to 
specify which attributes in a model should be protected. This is what I've 
come up with and I would love feedback as to whether or not it's a valid 
solution and how I could improve it.

Basically, I'm following the attr_accessible style and defining an 
attr_private method for setting specific attributes (or methods) as private.

http://codereview.stackexchange.com/questions/16064/protecting-certain-model-attributes-from-being-exposed-in-an-api

Your thoughts are much appreciated. Thanks in advance.

Jeremy

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/SgLzY2BcotAJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: Best Practices for Multiple site One login

2012-10-01 Thread thansika malar
 

Loginbuilder.com offers Single Sign On (SSO) service for multiple website 
owners. Make use of this service to give your users share one login to use 
all your websites. User details maintenance is made easier here.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/bL3uSeefM9UJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Rails 3: create input field for each element of a collection (MongoID)

2012-10-01 Thread Michael Imstepf
Hi all,

I have two models, Item and Bid

class Item
   include Mongoid::Document
   field :name, type: String
   has_many :bids 
 end
 class Bid
   include Mongoid::Document
   include Mongoid::Timestamps::Created
   field :bid, type: Float
   belongs_to :item  
 end


In views/prices/index I would like to list all items in a table and for 
each item put a field next it in which people can enter a number. At the 
bottom of the form should be a submit button for all records.

How is this best achieved?
There's plenty of code out there explaining how to add, for instance, several 
questions to one 
surveyhttp://railscasts.com/episodes/196-nested-model-form-part-1but I 
couldn't find an example that shows how to add one new record for 
each of of an existing element of a collection. 

Thanks...

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/adUQnc0M9R8J.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] RVM settings lost after every logout

2012-10-01 Thread gsw
Something else to consider is whether you are running the config that you 
assume that you are.

Trying putting an echo into the startup script that contains the RVM setup, 
like getting ready to load RVM..., then look into what shell you are 
using, which script is being used depending on whether you have a local 
session or connecting remotely, etc.; if you connect remotely like 
connecting to a VM/sever from your laptop that would matter.

And if you are typing rvm use in the terminal instead of using an .rvmrc 
in each root-level project directory that contains something like:

rvm use ruby-1.9.3-p194@name_of_the_project --create

or

rvm use @$(basename `pwd`) --create

then consider using the .rvmrc. Just be sure not to check it into open 
source projects, because then you might use someone else's gemset name that 
is using your project and make it easier for them to pollute their other 
gemset.

On Friday, September 28, 2012 10:32:45 AM UTC-4, chichibek bros wrote:

 thanks victor i will try both suggestions

 2012/9/28 Victor Goff keepero...@gmail.com javascript:

 For sure check the answer again where they said to source that line in 
 your bashrc or bash_profile dot file.

 Read the RVM installation notes carefully.  You will get there.

 -- 
 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 
 rubyonra...@googlegroups.comjavascript:
 .
 To unsubscribe from this group, send email to 
 rubyonrails-ta...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/groups/opt_out.
  
  




-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/bTudxYBwy_MJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] can I have more then 1 dynamic area

2012-10-01 Thread roelof
Hello, 
 
As a first project I will try to convert this site : 
http://www.tamarawobben.nl as a ruby on rails site.
But now I wonder how I can make more then 1 dynamic area.
So 1 area for the text, one for the recent posts and 1 for the menu.
I know I can do that with one erea with yield but if I only use it how 
does Ruby on Rails know which area I mean.
 
Roelof
 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/HfdCilDTPRkJ.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Run ruby web app from command line

2012-10-01 Thread Fernando Almeida
http://guides.rubyonrails.org/command_line.html#rails-runner

2012/9/30 Sta Canovist stacanov...@gmail.com

 Hello

 I made a quite simple ruby web app. It uses scrubyt and mysql to store
 results as cached results. The program is quite simple. It shows a
 form, you enter a value and the controller makes an external http
 call, parse the data and show the result for the user.

 But I have a problem. I have the requirement to let a ruby program
 from command line more or less run the same function that on web is
 been handled by the form controller.

 How can I re-use the web app when doing a standalone program callable
 from command line? I dont want to recode as all the app is already
 functioning. I am requested to do a ruby program that is called like
 this:

 ruby ./client.rb some_param

 Where should I put this client.rb? How do I use the code from the
 application that runs on the web?

 --
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.





-- 
Fernando Almeida
www.fernandoalmeida.net

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Run ruby web app from command line

2012-10-01 Thread Walter Lee Davis

On Sep 30, 2012, at 2:12 AM, Sta Canovist wrote:

 Hello
 
 I made a quite simple ruby web app. It uses scrubyt and mysql to store
 results as cached results. The program is quite simple. It shows a
 form, you enter a value and the controller makes an external http
 call, parse the data and show the result for the user.
 
 But I have a problem. I have the requirement to let a ruby program
 from command line more or less run the same function that on web is
 been handled by the form controller.
 
 How can I re-use the web app when doing a standalone program callable
 from command line? I dont want to recode as all the app is already
 functioning. I am requested to do a ruby program that is called like
 this:
 
 ruby ./client.rb some_param
 
 Where should I put this client.rb? How do I use the code from the
 application that runs on the web?

Have a google for 'command-line ruby' and read up on the gets() method. As far 
as where to put client.rb, that could be anywhere given the command-line you 
quoted. Starting the ruby method's first argument with a dot-slash means 
starting in the current directory… and the rest just points the ruby 
executable to the file client.rb in that directory. Are you meaning to call a 
Rails application using this command-line interface? Have a read on the Rails 
Runner. I don't remember anything about it except I saw it mentioned in passing 
in AWDWROR when I read it years ago, never used it.

Walter

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails with Phusion Passenger and Apache

2012-10-01 Thread Mandeep Kaur
On Sun, Sep 30, 2012 at 4:13 AM, Norbert Melzer timmel...@gmail.com wrote:
 2012/9/29 Mandeep Kaur meghasi...@gmail.com:

snip
 Hint 7: Last but not least: Learn to use a deploy-tool like Capistrano
 or Vlad, it will make many things easier and do things automatically
 that I personally would forget with every deploy (see Hint 5 and 6 :)
 )

Can I deploy app using Capistrano without Passenger?
I have another question that using Passenger is correct option or not?

-- 
Mandeep Kaur
http://mandeepsimak.wordpress.com/

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails with Phusion Passenger and Apache

2012-10-01 Thread Hassan Schroeder
On Mon, Oct 1, 2012 at 7:00 AM, Mandeep Kaur meghasi...@gmail.com wrote:

 Can I deploy app using Capistrano without Passenger?

Yes.

 I have another question that using Passenger is correct option or not?

It's just one of many options; the decision is yours.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails with Phusion Passenger and Apache

2012-10-01 Thread Mandeep Kaur
On Mon, Oct 1, 2012 at 7:40 PM, Hassan Schroeder
hassan.schroe...@gmail.com wrote:
 On Mon, Oct 1, 2012 at 7:00 AM, Mandeep Kaur meghasi...@gmail.com wrote:

 Can I deploy app using Capistrano without Passenger?

 Yes.

Is there any drawback of using it?

 I have another question that using Passenger is correct option or not?

 It's just one of many options; the decision is yours.

OK But I want suggestion.


-- 
Mandeep Kaur
http://mandeepsimak.wordpress.com/

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails with Phusion Passenger and Apache

2012-10-01 Thread Hassan Schroeder
On Mon, Oct 1, 2012 at 7:16 AM, Mandeep Kaur meghasi...@gmail.com wrote:

 Can I deploy app using Capistrano without Passenger?

 Yes.

 Is there any drawback of using it?

Not that I'm aware of.

 I have another question that using Passenger is correct option or not?

 It's just one of many options; the decision is yours.

 OK But I want suggestion.

I suggest you try it and decide if it meets your requirements :-)

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] Rails with Phusion Passenger and Apache

2012-10-01 Thread Jordon Bedwell
On Mon, Oct 1, 2012 at 9:00 AM, Mandeep Kaur meghasi...@gmail.com wrote:
 On Sun, Sep 30, 2012 at 4:13 AM, Norbert Melzer timmel...@gmail.com wrote:
 Hint 7: Last but not least: Learn to use a deploy-tool like Capistrano
 or Vlad, it will make many things easier and do things automatically
 that I personally would forget with every deploy (see Hint 5 and 6 :)
 )

 Can I deploy app using Capistrano without Passenger?
 I have another question that using Passenger is correct option or not?

Yes, Capistrano can be setup to do whatever you want, including
provisioning servers, though personally I prefer to deploy to a
central server via Git then that server is designed to deploy, manage,
report, and test the code and then deploy it to all the other servers
and also provision extra servers if needed, via Juju.  Though that
solution is probably way out of the way of what most people would
want.  Way, out of the way of what most people want.

There is nothing wrong with using Passenger since it's the easiest
solution to work with, the only thing annoying about passenger is that
it takes over error pages and that is pretty annoying to somebody like
me who is happy to use passenger and even happy to mention that I use
it but do I want them controlling my errors? No, I don't know how to
turn it off and don't care to know.

That said, I use passenger on my dev machine because it's pure easy to
work with, I don't need to restart the server or manage anything more
than the apache server and issue a tmp/restart.txt if I need a hard
restart of the passenger server, on production I prefer to deploy with
Thin or Unicorn with Apache Event or Nginx.  Though lately I sway
towards Apache 2.4 w/ Event.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: LDAP gems: paged search with net-ldap

2012-10-01 Thread Jeff Lewis
Hi Adam,

I haven't used net-ldap gem (I've always just used ruby-net-ldap gem for 
past several yrs for various projects), but ... Here's a link to the 
specific note in the current src regarding that setting:

https://github.com/RoryO/ruby-net-ldap/blob/master/lib/net/ldap.rb#L1337

Jeff

On Friday, September 28, 2012 1:08:41 AM UTC-7, adam321 wrote:

 Hi, 
  
 client: Ruby Gem net-ldap 
 Server: eDirectory v8.8.6
  
 Net-ldap uses paged search and here are the eDirectory messages:
  iterCountEntries: ispositionable returned FALSE
  and
  after the 126th entry (MaxPageSize=126 harcoded in net-ldap) the
  search is aborted:
  invalid paged result control syntax.
  Net-ldap displays the error message: protocol error.
  
 If paged search is disable in net-ldap, it works just fine, all search 
 entries are delivered.

 I use net-ldap because it was downloaded on most.
 Any idea why this happen? Is net-ldap gem still maintained?
 If not, is there other better maintained ldap gems?
 Or maybe LDAP gems just don't need maintenance or people just don't use 
 ldap anymore? Thanks in advance for any clarification.

 -Adam- 


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/E8A6Gf0NO3EJ.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Re: OLE2 signature is invalid

2012-10-01 Thread Damjan Rems
fahim patel wrote in post #1077636:
 I am getting this error while using spreadsheet_on_rails

Are you opening xlsx files instead of xls?

by
TheR

-- 
Posted via http://www.ruby-forum.com/.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] Can I have Ruby on Rails without json

2012-10-01 Thread roelof
Hello, 

On my Chakra linux machine the json gem would not get compiled,
I already made a issue for that.
 
But for continuing my project can I have ruby on rails without the json gem 
?
And if so, how can I do this ?
 
Roelof
 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/hnuw2j3scR4J.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] struct square brackets method used to instantiate?

2012-10-01 Thread John Merlino
I know that Struct class defines the [] instance method:

1.9.3p0 :014  Struct.instance_methods(false)
 =
[:==, :eql?, :hash, :inspect, :to_s, :to_a, :values, :size, :length, :each, 
:each_pair, :
[], :
[]=, :select, :values_at, :members, :pretty_print, :pretty_print_cycle, 
:as_json]

This allows you to mimic hash behavior via Struct:

1.9.3p0 :016  HashLike = Struct.new(:x,:y)
 = HashLike
1.9.3p0 :017  h = HashLike.new(1,2)
 = #struct HashLike x=1, y=2
1.9.3p0 :018  h[:x]
 = 1
1.9.3p0 :019  h[:y] = 100
 = 100

But I come across a use case where the square brackets method was used
as instantiation:

1.9.3p0 :001  Point = Struct.new :x, :y do
1.9.3p0 :002  def distance(point)
1.9.3p0 :003? Math.sqrt((point.x - self.x) ** 2 +
1.9.3p0 :004  (point.y - self.y) ** 2)
1.9.3p0 :005? end
1.9.3p0 :006?   end
 = Point
1.9.3p0 :007  Point[3,4].distance Point[0,0]
 = 5.0

That confuses me. How can [] be used both as both hash key accessors
and also instantiation (e.g. new)?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Rails] struct square brackets method used to instantiate?

2012-10-01 Thread Ignacio Piantanida
2012/10/1 John Merlino stoici...@aol.com

 I know that Struct class defines the [] instance method:

 1.9.3p0 :014  Struct.instance_methods(false)
  =
 [:==, :eql?, :hash, :inspect, :to_s, :to_a, :values, :size, :length,
 :each, :each_pair, :
 [], :
 []=, :select, :values_at, :members, :pretty_print, :pretty_print_cycle,
 :as_json]

 This allows you to mimic hash behavior via Struct:

 1.9.3p0 :016  HashLike = Struct.new(:x,:y)
  = HashLike
 1.9.3p0 :017  h = HashLike.new(1,2)
  = #struct HashLike x=1, y=2
 1.9.3p0 :018  h[:x]
  = 1
 1.9.3p0 :019  h[:y] = 100
  = 100

 But I come across a use case where the square brackets method was used
 as instantiation:

 1.9.3p0 :001  Point = Struct.new :x, :y do
 1.9.3p0 :002  def distance(point)
 1.9.3p0 :003? Math.sqrt((point.x - self.x) ** 2 +
 1.9.3p0 :004  (point.y - self.y) ** 2)
 1.9.3p0 :005? end
 1.9.3p0 :006?   end
  = Point
 1.9.3p0 :007  Point[3,4].distance Point[0,0]
  = 5.0

 That confuses me. How can [] be used both as both hash key accessors
 and also instantiation (e.g. new)?

 --
 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+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.



That's because the :[] method is both defined as an instance method and as
a class method of the Point class.

Point.singleton_class.instance_methods false
= [:new, :[], :members]

-- 
Piantanida, Ignacio Julián

-- 
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+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




[Rails] How to edit each line of a file in ruby, without using a temp file

2012-10-01 Thread Nila
Hi,

Is there a way to edit each line in a file, without involving 2 files? Say, 
the original file has,

test01
test02
test03

I want to edit it like
test01,a
test02,a
test03,a

Tried something like this, but it replaces some of the characters. 
File.open('mytest.csv', 'r+') do |file|
  file.each_line do |line|
  file.seek(-line.length, IO::SEEK_CUR)
  file.puts 'a'
  end
end

Writing it to a temporary file and then replace the original file works, 
However, I need to edit the file quite often and therefore prefer to do it 
within the file itself .Any pointers are appreciated.

Thank you!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/aGb5C9X9JZUJ.
For more options, visit https://groups.google.com/groups/opt_out.