[Rails] Re: MySQL update BLOB

2010-12-23 Thread Roman Mandeleil
Yep I got it. So much trouble with the script so I missed the obvious.
But, I still don't understand why the place holder for the update
statement doesn't work: I mean that syntax:

update_sql = "update SHARE set COMPANY_LOGO = ? WHERE ID =
8982167534873685924";

stmt = myconnect.prepare(update_sql)
stmt.execute(data)

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Spree drag and drop: not recognizing JS

2010-12-23 Thread Dan Sadaka
Greetings,

I asked this over at the Spree google group but got no response.  I'm
hoping someone here might have experience with this.

I am implementing a drag and drop cart with Rails 3 and jQuery.  This
cart works outside of Spree.

The URL I call from the drop action is hardcoded as
/products/add_to_cart.js.

I also added an Add To Cart button that uses the new :remote => true

<%= form_tag url_for(:action => 'add_to_cart', :id => domid), :id =>
"add-to-cart-form", :remote => true do %>
<%= submit_tag "Add to Order" %>
<% end %>

This works!  the add_to_cart method fires and understands I want a JS
response.  However, the problem still occurs when I try to drag and
drop.  Of course, I can't (don't know how) to use the rails remote
helper inside of the javascript so I am "hardcoding" the call to /
products/add_to_cart.js.

So, rails is recognizing JS when done from a remote form but not by
passing the .js extension.  What do I need to do to get it to
recognize this?  Or, is there a better way?

TIA,
Dan

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: MySQL update BLOB

2010-12-23 Thread Marnen Laibow-Koser
Please quote when replying.

Roman Mandeleil wrote in post #970391:
> tinyblob

Well, there's your problem -- a MySQL TINYBLOB only holds 255 bytes of 
data!

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Weird issue with converting floats to integer

2010-12-23 Thread Marnen Laibow-Koser
Robert Walker wrote in post #970390:
> Marnen Laibow-Koser wrote in post #970377:
>> Then use fixed-point math.  IEEE floats are 100% inappropriate for any
>> sort of mathematical calculation.  And who cares how fast they are if
>> they're inaccurate?  Inaccurate engineering calculations are worse than
>> none at all -- do *you* want to drive over that bridge? :)
>
> Let's break this down to a comparison of accuracy vs. precision.
>
> Take for example the value 1/3.
>
> First using floating point math:
>
> x = 1.0
> => 1.0
> y = 3.0
> => 3.0
> z = x / y
> => 0.
>
> Now with Ruby's BigDecimal math:
> x = BigDecimal.new('1')
> => #
> y = BigDecimal.new('3')
> => #
> z = x / y
> => #
>
> In the case of float we have 16 decimal digits of precision, but in the
> case of BigDecimal we have only eight digits of precision.

Are you sure?  Or are only eight digits displayed?

>
> Yes, in the case of BigDecimal we have a value representing "precisely"
> the value 0., but that result is obviously less accurate than
> the result of the floating point calculation.

Not obvious at all, since I don't know how many 3s the BigDecimal is 
*actually* storing.

>
> Over large aggregations this can make a difference.

Yes, it certainly can.

> It is certainly the
> case that IEEE floats introduce error due to the inherent storage
> limitations, but doing precise mathematics as fixed point has it's own
> complications as well.

Sure.  BigDecimal is the best of both worlds.

>
> Ruby's BigDecimal class does not provide the needed accuracy for complex
> mathematics.

Of course it does.  Why do you think it does not?

Anyway, if you need more than BigDecimal, then start climbing into the 
realms of symbolic math with Rational.

> The difference is that BigDecimal always stores precise
> values within the limits of it storage space. Where floats store
> imprecise representations, but representations with a fixed precision.
>
> I don't think either of these classes are appropriate for the sort of
> math mentioned above.

Why is BigDecimal inappropriate?  What would you use instead?

> But, they both have their uses.

I'm not sure Float has a proper use case at all. :)

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: Re: Re: Where put require

2010-12-23 Thread Paul Bergstrom
David Kahn wrote in post #970173:

Well said. :-)

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Re: Re: Where put require

2010-12-23 Thread Paul Bergstrom
Paul Bergstrom wrote in post #970168:

> And so have I. But as I said. I'm not a natural programmer. But I try to
> be a software developer and I think Rails is much easier to use than e g
> php. Hopefully it will stay that way.

Actually that should be web developer. A bit tired when I wrote that and 
missed it. I'm not into rails because of software development. Not sure 
why anyone would.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: MySQL update BLOB

2010-12-23 Thread Roman Mandeleil
tinyblob

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Weird issue with converting floats to integer

2010-12-23 Thread Robert Walker
Marnen Laibow-Koser wrote in post #970377:
> Then use fixed-point math.  IEEE floats are 100% inappropriate for any
> sort of mathematical calculation.  And who cares how fast they are if
> they're inaccurate?  Inaccurate engineering calculations are worse than
> none at all -- do *you* want to drive over that bridge? :)

Let's break this down to a comparison of accuracy vs. precision.

Take for example the value 1/3.

First using floating point math:

x = 1.0
=> 1.0
y = 3.0
=> 3.0
z = x / y
=> 0.

Now with Ruby's BigDecimal math:
x = BigDecimal.new('1')
=> #
y = BigDecimal.new('3')
=> #
z = x / y
=> #

In the case of float we have 16 decimal digits of precision, but in the 
case of BigDecimal we have only eight digits of precision.

Yes, in the case of BigDecimal we have a value representing "precisely" 
the value 0., but that result is obviously less accurate than 
the result of the floating point calculation.

Over large aggregations this can make a difference. It is certainly the 
case that IEEE floats introduce error due to the inherent storage 
limitations, but doing precise mathematics as fixed point has it's own 
complications as well.

Ruby's BigDecimal class does not provide the needed accuracy for complex 
mathematics. The difference is that BigDecimal always stores precise 
values within the limits of it storage space. Where floats store 
imprecise representations, but representations with a fixed precision.

I don't think either of these classes are appropriate for the sort of 
math mentioned above. But, they both have their uses.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Running Rails 2 and Rails 3 side by side on Obuntu

2010-12-23 Thread Peter Vandenabeele
Marnen Laibow-Koser wrote in post #970178:
> Peter Vandenabeele wrote in post #970143:
> [...]
>> Thanks for that hint. It lead me to this page:
>>
>>   http://rvm.beginrescueend.com/gemsets/basics/
>
> You hadn't read that before?

No. I am fairly new to rvm. Figured out

 $ rvm gemset help

as a useful command for exploration :-)

>> Now that we have bundler (with it's Gemfile) and rvm,
>> what would be the best way to run e.g. a Rails 2.3.8
>> and a 3.0.3 on the same Ruby 1.8.7 version in rvm ?
>>
>> Would it be useful to use rvm gemsets,
>
> Of course.  That way each project is completely independent.

OK, that's good. I'll try it out.

Thanks again,

Peter

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: MySQL update BLOB

2010-12-23 Thread Frederick Cheung


On Dec 23, 8:51 pm, Roman Mandeleil  wrote:
> Hi I am trying to update a blob column from Ruby script into MySQL DB.
> The script is running on PC and DB on Linux host.
> The problem I see is that only 255 bytes of data being stored ,
> is there any way to deal with that problem ?

What's the type of the column?

Fred
>
> myconnect = Mysql::new(host, user,  "", db)
> f = File.new(file_name,'rb')
>
> data = Mysql.escape_string(f.sysread(f.size))
>
> update_sql = "update SHARE set COMPANY_LOGO = '"+ data + "' WHERE ID =
> 8982167534873685924";
>
> stmt = myconnect.prepare(update_sql)
> stmt.execute()
>
> stmt.close
> myconnect.commit
> myconnect.close
>
> I also tried to leave a - '?' mark and than fill it with data, that one
> is not storing anything.
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] update a foreign key in an association table

2010-12-23 Thread Fabrice
Hello,

I'd like to know how to update a foreign key in an association table
(many_to_many association) ?

Here is my model, Split is the association table between Account and
Transaction:

class Account < ActiveRecord::Base
set_primary_key :guid

has_many :splits, :foreign_key => 'account_guid', :primary_key =>
'guid'
has_many :transactions, :through => :splits
end

class Transaction < ActiveRecord::Base
set_primary_key :guid

has_many :splits, :foreign_key => 'tx_guid', :primary_key =>
'guid'
has_many :accounts, :through => :splits
end

class Split < ActiveRecord::Base
belongs_to :transaction, :foreign_key => 'tx_guid', :primary_key
=> 'guid'
# here is the association that I'd like to change:
belongs_to :account, :foreign_key => 'account_guid', :primary_key
=> 'guid'
end

I'm trying this but it does not work (the value is not updated):

account = Account.new
transaction.splits.first.account = account
# error: prints the old value of account
puts transaction.splits.first.account

Do you have any idea ? Do I need to create a new Split and delete the
old one or is it possible to update the existing one ?

Thank you for your help,

Fabrice

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] logserver with log4r

2010-12-23 Thread Eshark
Hey guys,

I am trying to set up a logging server using log4r !

When I try to run the server I get the following error message
 "LogServer not supported. ROMP is required (RuntimeError)"

I installed romp the way its mentioned in some blog with similar
issue. Any ideas about it ?

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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails 3 - polymorphic associations problem with ActiveRecord::Relation

2010-12-23 Thread Gerardo
Hi,
My application is running over ubuntu 10, ruby 1.9.2, rails 3.0.3 and
passenger 3.0.2 + nginx.

This application has several polymorphic associations and the problem
is that when the associations are called it  randomly returns either
the related object or an ActiveRecord::Relation object.

Has anybody had a similar problem or is this a known issue?

Basically the Model looks like this:
class Blahblah < ActiveRecord::Base
  belongs_to :data_object, :polymorphic => true
end

When I call data_object.id, sometimes I'll get the following error:
"undefined method 'id' for ActiveRecord::Relation"
other times, the association works fine

If I try this in a rails console it seems to always work (could be
because of the inspect the console does).
Basically the issue always occurs when the app is running on nginx or
apache.

Any help will be appreciated.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] One form, multiple models, custom validation

2010-12-23 Thread Fidel Viegas

On 23/12/10 10:32, Serafino Picozzi wrote:

Hi everyone,

I hope someone can help me solve this problem.
I have a model called Project with :has_many =>  :tasks. In the new
Project form i allow the creation of 1 to n tasks on the fly thanks to
accepts_nested_attributes_for, where the task model has some validations
that block the creation of the new project if the required fields are
not correct.

This works just fine as it is supposed to work, but here's the problem:

At least one task needs to have some fields not empty, otherwise the
project should not be created. It can be any of the tasks but it's
imperative that at least one of them has those attributes, for the other
tasks these attributes are not required.
Is there a way of doing that without strange hacks?

Thanks in advance for your help


Hi Serafino,

I am assuming that you are using Javascript. If that is the case, then 
you can find the solution here 
http://stackoverflow.com/questions/1704142/unobtrusive-dynamic-form-fields-in-rails-with-jquery


All the best,

Fidel.

--
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: One form, multiple models, custom validation

2010-12-23 Thread Peter Vandenabeele
Would this not be the proper solution ?

User has many payments. I want the user to have at
least one payment with an amount, before a user is
valid.

class User < ActiveRecord::Base
  default_scope :order => :id
  has_many :payments
  validate :has_one_complete_payment

private

  def has_one_complete_payment
errors.add(:base, :missing_complete_payment) unless payments.detect 
{|p| p.amount}
  end
end

$ cat config/locales/en.yml
en:
  hello: "Hello world"
  activerecord:
errors:
  models:
user:
  attributes:
base:
  missing_complete_payment: You need at least one payment 
with amount filled out

That results in this behaviour:

$ rails c
Loading development environment (Rails 3.0.3)
001:0> user = User.new(:first_name => "Jon")
=> #
002:0> user.valid?
=> false
003:0> user.errors
=> #["You need at least one payment with amount 
filled out"]}>
004:0> p1 = user.payments.build()
=> #
005:0> user.valid?
=> false
006:0> user.errors
=> #["You need at least one payment with amount 
filled out"]}>
007:0> p2 = user.payments.build()
=> #
010:0> user.valid?
=> false
011:0> user.errors
=> #["You need at least one payment with amount 
filled out"]}>
012:0> p2.amount = "123.45"
=> "123.45"
013:0> user.valid?
=> true
014:0> user.save
=> true
015:0> user.payments.inspect
=> "[#, #>]"
015:0>

HTH,

Peter

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Re: Weird issue with converting floats to integer

2010-12-23 Thread Colin Law
On 23 December 2010 21:34, Marnen Laibow-Koser  wrote:
> Colin Law wrote in post #970376:
>> On 23 December 2010 03:41, Marnen Laibow-Koser 
>> wrote:
>>> 29114.9996362021192908287048
>>>
>>> It bears repeating: never, ever use Floats for arithmetic. If you can't
>>> use fixed-point math, then use BigDecimal.
>>
>> I have to disagree here.
>
> I knew someone would. :)

You probably guessed it might be me :)

>
>>  I would rephrase it as _almost_ never use
>> Floats  The one time when they would be appropriate is if you have a
>> large amount of arithmetic to perform.  The sort of thing that might
>> occur in complex statistical analysis for example or engineering
>> calculations of some sort.  On most (possibly all) computers floating
>> point consumes vastly less processor time to perform than BigDecimal.
>
> Then use fixed-point math.  IEEE floats are 100% inappropriate for any
> sort of mathematical calculation.  And who cares how fast they are if
> they're inaccurate?  Inaccurate engineering calculations are worse than
> none at all -- do *you* want to drive over that bridge? :)

We are getting off topic for Rails apps but I think if you looked into
most engineering and scientific software you would find they use
floating point arithmetic.  Fixed point is not appropriate as
intermediate calculations need guaranteed _relative_ error, not
absolute error.  That is what floats provide.

> If you want to use IEEE floats for arithmetic, then the onus is on you
> to do the requisite numerical analysis to figure out how much error you
> are introducing, and to inform your users of that fact.

Yes of course.  As you said, the bridge designer needs to know the
possible errors in his calculations.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Re: Weird issue with converting floats to integer

2010-12-23 Thread Marnen Laibow-Koser
Colin Law wrote in post #970376:
> On 23 December 2010 03:41, Marnen Laibow-Koser 
> wrote:
>> 29114.9996362021192908287048
>>
>> It bears repeating: never, ever use Floats for arithmetic. If you can't
>> use fixed-point math, then use BigDecimal.
>
> I have to disagree here.

I knew someone would. :)

>  I would rephrase it as _almost_ never use
> Floats  The one time when they would be appropriate is if you have a
> large amount of arithmetic to perform.  The sort of thing that might
> occur in complex statistical analysis for example or engineering
> calculations of some sort.  On most (possibly all) computers floating
> point consumes vastly less processor time to perform than BigDecimal.

Then use fixed-point math.  IEEE floats are 100% inappropriate for any 
sort of mathematical calculation.  And who cares how fast they are if 
they're inaccurate?  Inaccurate engineering calculations are worse than 
none at all -- do *you* want to drive over that bridge? :)

If you want to use IEEE floats for arithmetic, then the onus is on you 
to do the requisite numerical analysis to figure out how much error you 
are introducing, and to inform your users of that fact.

> This is a rare occurence in Rails apps

Yes indeed!

> I expect so I agree that for
> most people Marnen's advice would be appropriate.
>
> Colin

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Colin Law
On 23 December 2010 03:41, Marnen Laibow-Koser  wrote:
> TomRossi7 wrote in post #970207:
>> Any idea why this calculates the integer the way it does?
>>
>> irb> ("291.15".to_f * 100.0).to_i
>> => 29114
>
> Because of the vagaries of floating-point arithmetic:
> irb> ("291.15".to_f * 100.0) < 29115
> => true
> irb> printf "%.30f", ("291.15".to_f * 100.0)
> 29114.9996362021192908287048
>
> It bears repeating: never, ever use Floats for arithmetic.  If you can't
> use fixed-point math, then use BigDecimal.

I have to disagree here.  I would rephrase it as _almost_ never use
Floats  The one time when they would be appropriate is if you have a
large amount of arithmetic to perform.  The sort of thing that might
occur in complex statistical analysis for example or engineering
calculations of some sort.  On most (possibly all) computers floating
point consumes vastly less processor time to perform than BigDecimal.
This is a rare occurence in Rails apps I expect so I agree that for
most people Marnen's advice would be appropriate.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Saving records from multiple tables

2010-12-23 Thread pepe
> You say to use a transaction... I already am using a transaction!

Sorry about that. I obviously didn't read carefully your post.

> The issue is that if the person save succeeds and the client save
> fails then the transaction is rolled back fine. However the person
> record now has a person.id and subsequent code assumes that the record
> is saved and tries to refind the record which of course does not
> exist.
>
> I have got around this by saving the original value of the person.id
> and then resetting it in the rescue clause but it is a bit messy.
>
> One other issue is that the only validation errors that get set are
> the errors from the first record (person) that is saved so the user
> may fix these up only to find new validation errors from the second
> record...

I have not tried before what you are trying to do but I will as soon
as I have some time to spare. I don't understand why Rails would not
clear the ID value of the record and reset the record in order for
new_record? to return true.

> I'm sure there must be a tidy way!

If you use acceptes_nested_attributes_for and field_for the
validations will work just like you want them to work, however you
will need to change your form to be based on your person model, which
based on what you have explained would be pretty much impossible since
the person is selected in the form and you don't have a person object
to base the form on.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Peter Vandenabeele
TomRossi7 wrote in post #970346:
> I have currency information that I plan to store as an integer --
> ironically to avoid issues like this.  The user input will always be
> in a decimal form.  I'm thinking I will just do this ('291.15'.to_f *
> 100).round instead.  That should round out any of the weird float
> issues.

As was said before by others in this thread, using the BigDecimal type
really is the most reliable, and simple, solution. Don't reinvent
the wheel with calculating in pennies and rounding etc. ...

In the migration, do this:

class AddAmountToPayment < ActiveRecord::Migration
  def self.up
add_column :payments, :amount, :decimal, :precision => 12, :scale => 
2
  end
...

This which will work automatically correct when reading
user input in your forms and when doing internal calculations:

$ rails c
Loading development environment (Rails 3.0.3)
001:0> Payment.columns.select{|c| c.sql_type =~ /decimal/}
=> [#]

002:0> payment = Payment.new(:amount => "291.15")
=> #>

003:0> payment.amount
=> #

004:0> payment.amount.to_s
=> "291.15"

...

019:0> (payment.amount - BigDecimal("291") - BigDecimal("0.15")).to_s
=> "0.0"
020:0> ((291.15 - 291) - 0.15).to_s
=> "-2.27318164292001e-14" # Rounding errors with float !!!

HTH,

Peter

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] rails/ruby test - error report without line numbers

2010-12-23 Thread Colin Law
On 23 December 2010 17:40, Joshua S.  wrote:
> Hi all,
>
> I'm new to Rails and new to Rails testing. I have a few questions:
>
> First, the most important question. How do I get line numbers to be
> reported with my errors when testing. Here is what I get back on a
> typical error:
>
>
> j...@josh-laptop:~/d/test$ ruby unit/line_test.rb -n test_update
> Loaded suite unit/line_test
> Started
> E
> Finished in 0.03 seconds.
>
>  1) Error:
> test_update(LineTest):
> NameError: undefined local variable or method `sdf' for
> #
>
>
> 1 tests, 0 assertions, 0 failures, 1 errors
>
> It is tough to debug without a line number and filename. From the code
> samples I've seen, people generally get back a more verbose error
> report. How do I enable this?

I suggest running from your app root.  What happens if you do
ruby -I test test/unit/line_test.rb

>
> The next question is a small one. What is the difference between:
> -ruby unit/line_test.rb

That will only work if you run from the test folder, in fact I am
surprised it works at all as I don't know how it finds the app
environment.

> -ruby test -I unit/line_test.rb

That should be '-I test' not 'test -I' .  It tells it to Include the
folder test in the search path, so that require 'test_helper' at the
top of the test file finds test/test_helper.rb

> -ruby test unit/line_test.rb

I don't think this would ever work.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Devise restrict concurrent login

2010-12-23 Thread Matt Jones


On Dec 22, 10:36 am, Hitesh Rawal  wrote:
> Hi,
>
> I am using devise 1.0.8, and I want to restrict concurrent login of user
> i.e. same user should not be login from different browser or different
> location if he already login from some where.
>
> and if he really wants to login forcefully then other side sessions for
> that user should be clear and he should be logout from other sides.
>
> Any help would be greatly appreciated.

Clearance does this:

https://github.com/thoughtbot/clearance/wiki/concurrent-sign-in

In principle you should be able to do the same thing in Devise (reset
the authentication token on each signin).

--Matt Jones

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] MySQL update BLOB

2010-12-23 Thread Roman Mandeleil
Hi I am trying to update a blob column from Ruby script into MySQL DB.
The script is running on PC and DB on Linux host.
The problem I see is that only 255 bytes of data being stored ,
is there any way to deal with that problem ?


myconnect = Mysql::new(host, user,  "", db)
f = File.new(file_name,'rb')


data = Mysql.escape_string(f.sysread(f.size))

update_sql = "update SHARE set COMPANY_LOGO = '"+ data + "' WHERE ID =
8982167534873685924";

stmt = myconnect.prepare(update_sql)
stmt.execute()


stmt.close
myconnect.commit
myconnect.close


I also tried to leave a - '?' mark and than fill it with data, that one
is not storing anything.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Saving records from multiple tables

2010-12-23 Thread giorgio
Thanks for reply pepe.
You say to use a transaction... I already am using a transaction!

The issue is that if the person save succeeds and the client save
fails then the transaction is rolled back fine. However the person
record now has a person.id and subsequent code assumes that the record
is saved and tries to refind the record which of course does not
exist.

I have got around this by saving the original value of the person.id
and then resetting it in the rescue clause but it is a bit messy.

One other issue is that the only validation errors that get set are
the errors from the first record (person) that is saved so the user
may fix these up only to find new validation errors from the second
record...

I'm sure there must be a tidy way!

My latest version which works but is not pretty is:

  def create
begin #try to find existing person
  @person=Person.find(params[:person][:id])
rescue #they dont exist so create new
  @person=Person.new(params[:person])
end
person_...@person.id

@client=Client.new(params[:client])
begin
  Person.transaction do
@person.save!
@client.pers...@person
@client.save!
flash[:notice] = 'Client was successfully created.'
redirect_to :action => 'edit', :id => @client.id
  end
rescue
  #reset client and person to param values
  @person.id=person_id
  render :action => 'new'
end
  end

Cheers
George

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Scheduling Plugin

2010-12-23 Thread Matt Jones


On Dec 23, 12:00 pm, "ppgeng...@prevailhs.com" 
wrote:
> On Dec 22, 11:12 am, Mike Porter  wrote:
>
> > Hi,
>
> > We are looking for a calendar scheduling solution that supports
> > recurring events.
>
> I haven't used it, but when I was filling idle time a little bit ago
> the one I found that I liked the best 
> was:https://github.com/seejohnrun/ice_cube.
> Its development seems a lot more active than the one you have, which
> is generally pretty important to me when searching out gems, since
> things in Rails move so fast.
>
> > Some specific requirements are that we need to be able to setup
> > recurring events, then modify one of those events on a certain day by
> > deleting it for example.
>
> > Basically, we want the back end for a Google Calender type
> > functionality.
>
> Again, haven't used it but from the perusing it claims to do this
> (from their github landing page):
>
>   With ice_cube, you can specify (in order of precendence)
>
>     Exception Dates - To specifically exclude from a schedule
>     Recurrence Dates - To specifically include in a schedule
>     Exception Rules - Rules on how to exclude recurring dates in a
> schedule
>     Recurrence Rules - Rules on how to include recurring dates in a
> schedule
>

I looked at IceCube a while back, and the biggest issue I had from an
implementation perspective was that the DSL for building recurrence
rules was awesome *but* there wasn't a clear path to build it from
user input. calendar_fu is not quite as syntactically nice, but it
seems more "user-ready", if you will.

BTW, if you haven't checked out FullCalendar (http://arshaw.com/
fullcalendar/) you should - it's a pretty slick jQuery plugin to
handle the *other* half of the calendar system.

--Matt Jones

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Matt Jones


On Dec 22, 10:34 pm, TomRossi7  wrote:
> Any idea why this calculates the integer the way it does?
>
> irb> ("291.15".to_f * 100.0).to_i
> => 29114

As Marnen's already pointed out, the issue is that the result is a
*tiny* bit smaller than 29115, so to_i truncates off the entire
fractional part and gives the wrong answer. In general, if you want to
convert a decimal to an integer the way most people would on paper,
use .round.to_i, which will correctly round the float to the nearest
integer.

On the currency issue, it's typically a good idea to avoid floating-
point throughout the process if you're trying to get a reliable fixed-
point result. Decimal columns are definitely a good idea for this sort
of thing.

--Matt Jones

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes

2010-12-23 Thread Marnen Laibow-Koser
Please quote when replying.

daze wrote in post #970358:
> Oh whoa okay thanks.  I better make some changes now... :/
>
> Can I use Shoulda w/ Rspec, or do I just use one over the other?

I understand Shoulda is usable with RSpec.  I've never actually used 
Shoulda on any of my projects, though.  (And you *should* be able to do 
what you're doing with Shoulda and Test::Unit.)

> And I should use this one https://github.com/rspec/rspec-rails, right?

rspec-rails works with RSpec to provide some Rails-specific features. 
Please see http://rspec.info for more information.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes

2010-12-23 Thread daze
Oh whoa okay thanks.  I better make some changes now... :/

Can I use Shoulda w/ Rspec, or do I just use one over the other?
And I should use this one https://github.com/rspec/rspec-rails, right?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Marnen Laibow-Koser
Please quote when replying.

TomRossi7 wrote in post #970346:
> I have currency information that I plan to store as an integer --
> ironically to avoid issues like this.  The user input will always be
> in a decimal form.  I'm thinking I will just do this ('291.15'.to_f *
> 100).round instead.  That should round out any of the weird float
> issues.

I think there are better ways of doing that -- such as using a DECIMAL 
field in the database.  Then no conversion is necessary and the data is 
stored as fixed-point.

Or, if you'd rather store the data as an integral number of pennies 
(though that may have i18n issues -- there are a few currencies, such as 
the Kuwaiti dinar, that are subdivided into 1000, not 100), then a quick 
way would be to normalize the string so that it contains 2 decimal 
places (so "123" would become "123.00"), then drop the decimal point.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rails/ruby test - error report without line numbers

2010-12-23 Thread Joshua S.
I posted an unpleasant solution on stackoverflow:

http://stackoverflow.com/questions/4521203/ruby-tests-error-messages-dont-include-line-numbers-or-file-name/4521275#4521275

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread TomRossi7
I have currency information that I plan to store as an integer --
ironically to avoid issues like this.  The user input will always be
in a decimal form.  I'm thinking I will just do this ('291.15'.to_f *
100).round instead.  That should round out any of the weird float
issues.

On Dec 23, 12:51 pm, Marnen Laibow-Koser  wrote:
> Please quote when replying.
>
> Jeff Burlysystems wrote in post #970344:
>
> > Or just change the way you calculate to get at the level of accuracy
> > that you want/need:
>
> > irb> ("291.15".to_f * 1000.0).to_i/10
> > => 29115
>
> That's incredibly silly IMHO.  Besides, it will not always be the same
> for all values, will it?  I think BigDecimal is the right answer here.
>
>
>
> > Jeff
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Marnen Laibow-Koser
Please quote when replying.

Jeff Burlysystems wrote in post #970344:
> Or just change the way you calculate to get at the level of accuracy
> that you want/need:
>
> irb> ("291.15".to_f * 1000.0).to_i/10
> => 29115

That's incredibly silly IMHO.  Besides, it will not always be the same 
for all values, will it?  I think BigDecimal is the right answer here.

>
> Jeff

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Weird issue with converting floats to integer

2010-12-23 Thread Jeff Lewis
Or just change the way you calculate to get at the level of accuracy
that you want/need:

irb> ("291.15".to_f * 1000.0).to_i/10
=> 29115

Jeff

On Dec 22, 7:41 pm, Marnen Laibow-Koser  wrote:
> TomRossi7 wrote in post #970207:
>
> > Any idea why this calculates the integer the way it does?
>
> > irb> ("291.15".to_f * 100.0).to_i
> > => 29114
>
> Because of the vagaries of floating-point arithmetic:
> irb> ("291.15".to_f * 100.0) < 29115
> => true
> irb> printf "%.30f", ("291.15".to_f * 100.0)
> 29114.9996362021192908287048
>
> It bears repeating: never, ever use Floats for arithmetic.  If you can't
> use fixed-point math, then use BigDecimal.
>
>
>
> > Thanks,
> > Tom
>
> Best,
> --
> Marnen Laibow-Koserhttp://www.marnen.org
> mar...@marnen.org
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rails/ruby test - error report without line numbers

2010-12-23 Thread Marnen Laibow-Koser
Joshua S. wrote in post #970342:
> Hi all,
>
> I'm new to Rails and new to Rails testing. I have a few questions:
>
> First, the most important question. How do I get line numbers to be
> reported with my errors when testing.


  Probably by not using Test::Unit. :)  It sucks.  Try RSpec instead. 
Better API and much more readable error reports.


Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] rails/ruby test - error report without line numbers

2010-12-23 Thread Joshua S.
Hi all,

I'm new to Rails and new to Rails testing. I have a few questions:

First, the most important question. How do I get line numbers to be
reported with my errors when testing. Here is what I get back on a
typical error:


j...@josh-laptop:~/d/test$ ruby unit/line_test.rb -n test_update
Loaded suite unit/line_test
Started
E
Finished in 0.03 seconds.

  1) Error:
test_update(LineTest):
NameError: undefined local variable or method `sdf' for
#


1 tests, 0 assertions, 0 failures, 1 errors

It is tough to debug without a line number and filename. From the code
samples I've seen, people generally get back a more verbose error
report. How do I enable this?

The next question is a small one. What is the difference between:
-ruby unit/line_test.rb
-ruby test -I unit/line_test.rb
-ruby test unit/line_test.rb

I'd like to know the difference since I'm unable to use the command in
the Rails Testing guide (third one).

Thanks!

Josh

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes

2010-12-23 Thread Marnen Laibow-Koser
daze wrote in post #970337:
> On Dec 22, 10:38pm, Marnen Laibow-Koser  wrote:
>
>> Let's see your error messages. But why the heck are you defining an
>> object like this anyway? What are you trying to achieve?
>
> I'm trying to get a test for acts_as_list working.  I've defined a
> method in test_helper that I use in my unit tests:
>
> # tests acts as list and default_scope :order => 'position'
> def self.should_act_as_list(options = {})
>  klass = self.name.gsub(/Test$/, "").constantize # converts string
> to class

Nonononono.   Don't do it that way.  With RSpec, you'd write a custom 
matcher class; I don't know if the same thing is done with Shoulda.  But 
you're getting too complex here and asking for trouble.

Please read about how custom should_* methods are supposed to be 
written.


>   context "acting as a list" do
> setup do # DON'T DO THIS???
>   #...@instance = klass.all[0]
> end

What on earth is that for?

>
> should "have a position column" do
>   instance = klass.first
>   assert_not_nil instance.position, :message => "If you see me,
> check
> out the POSITION."
> end

That won't actually do what you want -- it will just make sure that 
position is not nil.  You'd have to check the columns array or use 
respond_to? to do what you're trying for here.

>
> should "move objects correctly" do
>   instance = klass.first
>   instance.move_to_bottom
>   assert_equal klass.all[-1], instance
>   instance.move_higher
>   assert_equal klass.all[-2], instance
>   instance.move_to_top
>   assert_equal klass.first, instance
>   instance.move_lower
>   assert_equal klass.all[1], instance
> end

Probably not necessary -- you're testing acts_as_list here, which is 
presumably already well tested.

You are really doing things the hard way here.  Learn a bit more about 
Ruby's metaprogramming...

[...]
 ...and I'm sure that my test db is populated whenever I run my tests...
>
>> You shouldn't have to be sure of that beforehand; rather, you should be
>> using factories to create records for tests on the fly.
>
> I want my development and test dbs to be the same,

No you don't.  You want the *schemas* to be the same, but you want only 
specially crafted test data in your test DB.

> so I thought using
> the seeds.rb file - which in my case uses Factories

Your seeds file probably should not be using factories.

> - in conjunction
> with rake db:seed RAILS_ENV=test would be the best way.  There are
> some things I want to have set names for, like sections - they'll
> always be Sports, News, etc.  Other things like Articles, though, I
> generate in the seeds file en masse.
> Is my methodology totally wrong?

Yes.

> Should I be testing acts_as_list's
> functionality in a totally different way?

That's a separate question from seeds.

>
> I mean, are you saying I should create records in the "setup" method
> for each unit test rather than populate the db with that rake db:seed
> RAILS_ENV=test command?

Yes.  Seeding the test database is never a good idea (this is why 
fixtures are dangerous), because it becomes difficult to make sure your 
tests don't share state, and also because it becomes difficult to keep 
track of the assumptions you're making.  Use factories to create only 
the actual records you need for each test case (generally less than 10).

And do check out RSpec when you get a chance. :)

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Scheduling Plugin

2010-12-23 Thread ppgeng...@prevailhs.com
On Dec 22, 11:12 am, Mike Porter  wrote:
> Hi,
>
> We are looking for a calendar scheduling solution that supports
> recurring events.

I haven't used it, but when I was filling idle time a little bit ago
the one I found that I liked the best was: 
https://github.com/seejohnrun/ice_cube.
Its development seems a lot more active than the one you have, which
is generally pretty important to me when searching out gems, since
things in Rails move so fast.

> Some specific requirements are that we need to be able to setup
> recurring events, then modify one of those events on a certain day by
> deleting it for example.
>
> Basically, we want the back end for a Google Calender type
> functionality.

Again, haven't used it but from the perusing it claims to do this
(from their github landing page):

  With ice_cube, you can specify (in order of precendence)

Exception Dates - To specifically exclude from a schedule
Recurrence Dates - To specifically include in a schedule
Exception Rules - Rules on how to exclude recurring dates in a
schedule
Recurrence Rules - Rules on how to include recurring dates in a
schedule


HTH,
\Peter

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Difference between rake test:units and individually running ruby -I test test/unit/something_tes

2010-12-23 Thread daze
On Dec 22, 10:38 pm, Marnen Laibow-Koser  wrote:

> Let's see your error messages.  But why the heck are you defining an
> object like this anyway?  What are you trying to achieve?

I'm trying to get a test for acts_as_list working.  I've defined a
method in test_helper that I use in my unit tests:

# tests acts as list and default_scope :order => 'position'
def self.should_act_as_list(options = {})
 klass = self.name.gsub(/Test$/, "").constantize # converts string
to class
context "acting as a list" do
setup do # DON'T DO THIS???
#...@instance = klass.all[0]
end

should "have a position column" do
instance = klass.first
assert_not_nil instance.position, :message => "If you 
see me, check
out the POSITION."
end

should "move objects correctly" do
instance = klass.first
instance.move_to_bottom
assert_equal klass.all[-1], instance
instance.move_higher
assert_equal klass.all[-2], instance
instance.move_to_top
assert_equal klass.first, instance
instance.move_lower
assert_equal klass.all[1], instance
end

end
end

My error messages just show this:
---
Loaded suite C:/Ruby187/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake/
rake_test_loader
Started
EE...
Finished in 0.171875 seconds.

  1) Error:
test: An article acting as a list should have a position column.
(ArticleTest):
NoMethodError: undefined method `position' for nil:NilClass
/test/test_helper.rb:36:in `__bind_1293122683_953075'

  2) Error:
test: An article acting as a list should move objects correctly.
(ArticleTest):
NoMethodError: undefined method `move_to_bottom' for nil:NilClass
/test/test_helper.rb:41:in `__bind_1293122683_953075'

  3) Error:
test: acting as a list should have a position column. (PageTest):
NoMethodError: undefined method `position' for nil:NilClass
/test/test_helper.rb:36:in `__bind_1293122684_93700'

  4) Error:
test: acting as a list should move objects correctly. (PageTest):
NoMethodError: undefined method `move_to_bottom' for nil:NilClass
/test/test_helper.rb:41:in `__bind_1293122684_93700'

  5) Error:
test: A section acting as a list should have a position column.
(SectionTest):
NoMethodError: undefined method `position' for nil:NilClass
/test/test_helper.rb:36:in `__bind_1293122684_109325'

  6) Error:
test: A section acting as a list should move objects correctly.
(SectionTest):
NoMethodError: undefined method `move_to_bottom' for nil:NilClass
/test/test_helper.rb:41:in `__bind_1293122684_109325'

33 tests, 28 assertions, 0 failures, 6 errors
rake aborted!
Command failed with status (1): [C:/Ruby187/bin/ruby.exe -I"lib;test"
"C:/R...]
---
..which is really the same error over and over again.  My variable
"instance" becomes nil somehow.

>>> ...and I'm sure that my test db is populated whenever I run my tests...

> You shouldn't have to be sure of that beforehand; rather, you should be
> using factories to create records for tests on the fly.

I want my development and test dbs to be the same, so I thought using
the seeds.rb file - which in my case uses Factories - in conjunction
with rake db:seed RAILS_ENV=test would be the best way.  There are
some things I want to have set names for, like sections - they'll
always be Sports, News, etc.  Other things like Articles, though, I
generate in the seeds file en masse.
Is my methodology totally wrong?  Should I be testing acts_as_list's
functionality in a totally different way?

I mean, are you saying I should create records in the "setup" method
for each unit test rather than populate the db with that rake db:seed
RAILS_ENV=test command?

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] [JOB] Jr. OS Developer, Greenwich, CT | 65k

2010-12-23 Thread OSS
This is a full time, on-site, salaried Junior Open Source Developer
position located in Greenwich, CT paying $55,000 to $65,000 depending
on experience + benefits.  No telecommuting allowed.  US Citizens or
Green Card holders only please.  Local candidates only.  Thank you.

Our boutique hedge fund client is offering a high profile opportunity
for a junior open source professional. This position will function as
the point person for day-to-day operations of the firm as it relates
to Linux and MySQL engineering, coding in Ruby on Rails and/or PHP and
general infrastructure support.

Environment includes: Linux, MySQL, Ruby on Rails, PHP

What’s in it For You?
* Be part of the unique combination of open source and financial
services
* Autonomy to make critical IT decisions for this growing firm
* Learn an industry typically tied to conventional technologies
* Maintain a work/life balance while working in Greenwich, CT

Required Qualifications:
* Strong Computer Science competence in software and hardware
* Development experience within Linux, MySQL, PHP, Ruby on Rails
* Ability to multitask with new development, enhancement and
infrastructure projects
* Personal ambition to work in a startup environment
* Proven motivation for technical growth and leadership

If you are interested in this job, please submit your RESUME and
SALARY requirements to beau[AT]open-source-staffing.com

Thank you,
Beau J. Gould
--
Open Source Staffing
http://opensourcestaffing.wordpress.com
beau[AT]open-source-staffing.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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rvm, rails and sqlite

2010-12-23 Thread Rail Shafigulin
zoltan,

thanks for help. i solved the problem by doing the following:

rvm notes

returns a list of modules that needed to be installed on linux. after 
that i

gem install sqlite3-ruby

and everything worked fine.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] MongoMapper with ActiveModel - Rails 3

2010-12-23 Thread Milo Thurston
I'm trying out Rails 3 with MongoMapper for a new application, and have
run into a bug when both MongoMapper::Document and
ActiveModel::Validations are used in the same model, in this case
job.rb. I can create a new model with the various validations I require,
but when I attempt to save it I get:

NoMethodError: undefined method `_run_before_save_callbacks' for
#

Google doesn't come up with much for this other than suggestions to rely
only upon MongoMapper, which I would rather not do. So, if anyone can
suggest a workaround it would be very useful.
Thanks!

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Dynamic JavaScript -- was: Re: Re: Rails - escape_javascript without all the \n\n\n\n\n

2010-12-23 Thread Marnen Laibow-Koser
Matteo Latini wrote in post #970246:
> On Dec 22, 2010, at 6:05 PM, Marnen Laibow-Koser wrote:
>
>>
>>>
>> really doesn't belong.  You wouldn't do that in Ruby; don't do it in JS.
> Ruby is actually NOT like that... Actually everything we love about
> rails
> is thanks to dynamic code...

That's not true at all.  Most of it is due to metaprogramming, which is 
a very different thing than dynamically generating source code as text 
-- in fact, the point of Ruby's metaprogramming is that you *don't* have 
to dynamically generate source code to have dynamic behavior.  Please 
get your facts straight.

(There are a few spots deep in the Rails framework where source code is 
generated as strings, presumably for efficiency reasons.  I regard these 
as either errors or performance hacks, and I would never attempt to do 
likewise in my own application code.)

>
>>>
>>> Also, what do you mean by hidden div?
>>
>> A div with display: none in its style.
>>
>>> Do you mean you just jam
>>> the data in it or use it for html templating?
>>
>> I don't understand what you're asking.
>
> Do you use html/js templating, or the hidden div is filled with
> data?

That's not an "or" question, is it?  Or am I still not understanding 
what you mean?

Best,
-- 
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org

Sent from my iPhone

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Please help with installing mysql gem to linux machine w/ xampp

2010-12-23 Thread gezope
Hello,
check RVM because later you can have more problems
http://rvm.beginrescueend.com/gemsets/basics/

I had the same problem, and met with this many times in mailing list.
Better to avoid in early stage.
Cheers,
gezope

On dec. 22, 21:44, "Dan W."  wrote:
> Solved! via:http://www.dolicapax.org/?p=11
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Connection to database

2010-12-23 Thread gezope
Hi,

- first check MySQL console,
- then 'gem list m' - you can see here every gem listed starts with
letter 'm' (or simply 'gem list')
- then what other wrote here 'irb -r active_record'.

If your Euby, Gem, Rails installed well, you have the necessary gems
(see in gem list), then you can edit your Gemfile, then run bundle
install, then edit .yaml. I think just give a try, you cannot loose
much in early stage.
Good luck,
gezope

n dec. 22, 08:29, Anandh Kumar  wrote:
> Hi everyone,
>
> Can someone suggest me is there any way in RoR to check for the database
> connection without using database.yml.
>
> I need this because before editing database.yml file i want to check
> whether mysql is installed in the given host.
>
> Any help would be greatly appreciated.
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rvm, rails and sqlite

2010-12-23 Thread gezope
Hello Rail!

I would use this method:
- check RVM, set all thing you need, see also this part
http://rvm.beginrescueend.com/gemsets/basics/
- is sqlite installed? is it running?
- check if needed Ruby version installed and if you can switch,
- gem version you need,
- particular gem you need - this case sqlite3-ruby,
- rails version you need,
- finally .yaml

Important: If you're on Unix, do NOT use 'sudo' when istalling a gem!
(And always pay attention which gem and which Rails do you intall with
a Ruby version.)

If you have further problems, it is almost surely because of old gem.
Others wrote on mailing list before that if nothing else worked, they
uninstalled then reinstalled their gem, after that it worked fine.
Please check answers before in this mailing lists, I met with these
questions several times. (Or you can write me in private also, I had
so long struggle with this.)

If you have still problem can you list me here your:
OS, rvm -v, ruby -v, rvm list, gem -v, gem list, rvm gemset list,
please. Good luck,
Zoltan

n dec. 22, 20:40, Rail Shafigulin  wrote:
> peter thanks for the help. it turns out i needed to run
>
> rvm notes
>
> and there was a list of packages i need to install to successfully work
> with rvm
>
> after that i ran
>
> sudo apt-get  and everything started working
>
> your solution was similar to what i have done
>
> --
> Posted viahttp://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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] has_many :through full stack help

2010-12-23 Thread agilehack
I am trying to implement HMT for the first time and having a ton of
trouble.  I would like to be able to have the user check a checkbox
and fill some extra fields for data input.  I have tried so many
iterations borrowed from different places I found on the web, none
seem to work quite right.  Essentially I have two models: 'practice'
and 'system' where a practice can have one or many systems and I have
a join model called 'implementation' where I also store some
additional attributes such as who implemented the software and when.
I have now rolled all my code back to the basics following the HABTM
railscast.  So right now when I check a checkbox (choosing the system)
the join model (implementation) does get both system ID's but I cant
figure out how to correctly add the additional 3 fields and have them
stored when I save.  I have included below what I think is relevant, I
am beyond just hints at this point, I need help with the code itself -
just cant get it to work.  THANK YOU THANK YOU if you can help

---PRACTICE MODEL---
class Practice < ActiveRecord::Base
 
attr_accessible :name, :tax_id, :location_ids, :employee_ids, :system_ids

  has_and_belongs_to_many :employees
  has_and_belongs_to_many :locations

  has_many :implementations
  has_many :systems, :through => :implementations

  validates_presence_of :name, :tax_id


end

-SYSTEM MODEL---
class System < ActiveRecord::Base
 
attr_accessible :system_publisher, :system_name, :system_type, :system_version,
  :system_version_certified, :practice_ids

  has_many :implementations
  has_many :practices, :through => :implementations
end
-IMPLEMENTATION MODEL-
class Implementation < ActiveRecord::Base
 
attr_accessible :system_start_date, :system_stop_date, :system_implemented_by, 
:system_ids, :practice_ids

  belongs_to :system
  belongs_to :practice
end
PRACTICE CONTROLLER

class PracticesController < ApplicationController

  #added for auto complete text (HABTM)
  #auto_complete_for :location, :name
  #auto_complete_for :employee, :first_name

  def index
@practices =
Practice.name_like_all(params[:search].to_s.split).ascend_by_name
#...@practices = Practice.all
  end

  def show
@practice = Practice.find(params[:id])
  end

  def new
@practice = Practice.new
  end

  def create
@practice = Practice.new(params[:practice])

if @practice.save
  flash[:notice] = "Successfully created practice."
  redirect_to @practice
else
  render :action => 'new'
end
  end

  def edit
@practice = Practice.find(params[:id])
  end

  def update

params[:practice][:employee_ids] ||= []
params[:practice][:location_ids] ||= []
#?
#   params[:practice][:system_ids] ||= []
#?

@practice = Practice.find(params[:id])
if @practice.update_attributes(params[:practice])
  flash[:notice] = "Successfully updated practice."
  redirect_to @practice
else
  render :action => 'edit'
end
  end

  def destroy
@practice = Practice.find(params[:id])
@practice.destroy
flash[:notice] = "Successfully destroyed practice."
redirect_to practices_url
  end
end
PRACTICE _form
<% form_for @practice do |f| %>
  <%= f.error_messages %>
  
<%= f.label :name %>
<%= f.text_field :name %>
  
  
<%= f.label :tax_id %>
<%= f.text_field :tax_id %>
  


Employee(s):
<% for employee in Employee.find(:all) %>

<%= check_box_tag "practice[employee_ids][]", employee.id,
@practice.employees.include?(employee) %>
<%= employee.first_name %> <%= employee.last_name %>

<% end %>


Location(s):
<% for location in Location.find(:all) %>

<%= check_box_tag "practice[location_ids][]", location.id,
@practice.locations.include?(location) %>
<%= location.name %>

<% end %>




<% for system in System.find(:all) %>

  <%= check_box_tag "practice[system_ids][]", system.id,
@practice.systems.include?(system) %>
  <%= system.system_name %>

<% end %>


<%= f.submit %>
<% end %>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Saving records from multiple tables

2010-12-23 Thread pepe
I see 2 things that might help you. On one hand you could use
accepts_nested_attributes_for in your person model and fields_for in
your view, then you would only need to save the person and that would
take care of the client as well but based on what I see in your code
that might not be feasible. On the other hand you could wrap the code
for your save commands in a transaction and if there is any type of
error during any of the saves Rails will roll back the transaction and
you're golden.


On Dec 22, 8:30 pm, giorgio  wrote:
> I hav page where I am saving a "client" record and a "person" record.
> Sometimes the "person" is an existing record and sometimes it is a new
> record. The "client" is always new.
> Here is some code:
>
> class Person < ActiveRecord::Base
>   has_many :clients
> 
>
> class Client < ActiveRecord::Base
>   belongs_to :person
>   validates_presence_of :person_id
>
> 
>
>   def create
>     @client = Client.new(params[:client])
>     begin #check if the person already exists
>       @person=Person.find(params[:person][:id])
>     rescue #otherwise create new person
>       @person=Person.new(params[:person])
>     end
>     @client.pers...@person
>      begin
>       Client.transaction do
>         @person.save!
>         @client.pers...@person
>         @client.save!
>         flash[:notice] = 'Client was successfully created.'
>         redirect_to :action => 'edit', :id => @client.id
>       end
>     rescue
>       render :action => 'new'
>     end
>   end
>
> Im not really sure what the best way and order to do the saves is.
> If I try to save client first then it wont have a person_id yet and
> will fail validation.
> If I save the person first and then the client fails validation for
> some other reason the code sort of works in that it rolls back but the
> @person record has an id set even though the save failed. It also
> appears to return false for @person.new_record?
>
> Is there a tidier way to do this? I have tried @client.person.save and
> various other combinations but it is not really clear what actually
> gets saved.
>
> Any comments appreciated.
>
> George

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] saravanan

2010-12-23 Thread Jatin kumar
On Thu, Dec 23, 2010 at 12:02 PM, Saravanan Ravi wrote:

> Hi,
>
>  I am new to ruby on rails.. i have one dought in select tag
>  i created table name with products(id,title,price,date)
>
Your question is not clear.
What do you mean by


>  I loaded all title name from mysql databse.
>
 Where should the corresponding price be displayed??

> but if i select any title means the corresponding price should be display
>  what can i do for that..plz help me..
>
> --
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Does using :render => :partial breaks the MVC separation during an ajax call

2010-12-23 Thread deepak
I am using this function below which updates a div element with a
partial in an ajax call.

def publish
  render :update do |page|
page.replace_html 'my_div', :partial => 'my_partial'
  end
end

Does this approach breaks the MVC separation. If Yes, how can we avoid
it?

Thanks
Deepak Kumar
INDIA

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] saravanan

2010-12-23 Thread Saravanan Ravi
Hi,

 I am new to ruby on rails.. i have one dought in select tag
 i created table name with products(id,title,price,date)
 I loaded all title name from mysql databse.but if i select any
 title means the corresponding price should be display
 what can i do for that..plz help me..

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Authlogic Rails 3

2010-12-23 Thread Up 4.
I think you should add the following line in your gem file:

gem "rails3-generators"

It is required to add your required generators

UP4B LLC
http://up4b.com

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Active Record Relations and Nesting

2010-12-23 Thread Devin M
Hello,
  I am looking to create a rails app that will model and display
related nodes. I am just beginning to dive into active record and I
was wondering if the following pesudo code would work?

class NodeLink < ActiveRecord::Base
  belongs_to :node # foreign key - node_id (recorded as
primary_node_id)
  belongs_to :node # foreign key - node_id (recorded as
secondary_node_id)
end

class Node < ActiveRecord::Base
  has_many :nodes, :through => :node_links
end

In essence this would create something that looks like the following.
  [Node One]
  |   |
  |   |
[Node Two]  [Node Three]
|
|
[Node Four]

Where the node links are represented by the lines and the nodes
themselves are enclosed in brackets. And this pattern could be
continued indefinite through different variations of nodes and links.

Any help or advice you could give would be great.
Thanks,
Devin Morin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] No such file to load error

2010-12-23 Thread Juhi Choudhary
Hi
  I am using ruby with selenium to automate my test. But when I execute
my test case in eclipse IDE I am getting the following error

:29:in `require': no such file to
load -- test1 (LoadError)
  from :29:in `require'
  from
D:/Juhi_Project/.metadata/.plugins/org.rubypeople.rdt.testunit/ruby/RemoteTestRunner.rb:301:in
`'


My source code is

require "test/unit"
require "rubygems"
gem "selenium-client"
require "selenium/client"

class Test1 < Test::Unit::TestCase
  def setup
@verification_errors = []
@selenium = Selenium::Client::Driver.new \
  :host => "localhost",
  :port => ,
  :browser => "*chrome",
  :url => "http://www.tutorialspoint.com/";,
  :timeout_in_second => 60
@selenium.start_new_browser_session
  end
def teardown
@selenium.close_current_browser_session
assert_equal [], @verification_errors
  end
def test_test1
@selenium.open "/ruby/ruby_hashes.htm"
@selenium.click "link=Ruby Date & Time"
@selenium.wait_for_page_to_load "3"
@selenium.type "q", "module"
@selenium.click "//inp...@name='sitesearch' and
@value='www.tutorialspoint.com']"
@selenium.click "sa"
@selenium.click "link=Ruby Ranges"
@selenium.wait_for_page_to_load "3"
@selenium.click "link=Ruby Iterators"
@selenium.wait_for_page_to_load "3"
  end
end


When I run this from command line it,s working fine. I have ruby1.9,
ruby-gems1.3.7,RSpec2.3.0,rails3.0.3.

Thanks in advance

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Problem with Selenium RC with Rails

2010-12-23 Thread Juhi Choudhary
Hi
  Your code is missing something. Try this one

 require "test/unit"
require "rubygems"
require "selenium"


class MyTestClass < Test::Unit::TestCase
  def setup
@verification_errors = []
@selenium = Selenium::Client::Driver.new(
  "localhost",
  ,
  "*firefox",
  "http://tutorialspoint.com/";,
  30 )
  @selenium.start
end
  def teardown
@selenium.stop unless $selenium
assert_equal [], @verification_errors
  end

  def test_task

@selenium.open "/ruby/ruby_hashes.htm"
@selenium.click "link=Ruby Date & Time"
@selenium.wait_for_page_to_load "3"
@selenium.type "q", "module"
@selenium.click "//inp...@name='sitesearch' and 
@value='www.tutorialspoint.com']"
@selenium.click "sa"
@selenium.click "link=Ruby Ranges"
@selenium.wait_for_page_to_load "3"
@selenium.click "link=Ruby Iterators"
@selenium.wait_for_page_to_load "3"
end
end


It is working fine in my system.

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: "File not found: lib" when installing rails-3.0.0

2010-12-23 Thread Sebastian S.
Solution:

$ cd /usr/lib/ruby/gems/1.8/gems/rails-3.0.3/
$ ls .

bin

if you have only "bin" directory:

$ sudo mkdir lib

$ sudo gem install rails

Sebastian

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] [ANN] WiceGrid 0.6 for Rails 2 and 3.0.0.pre1 for Rails 3 are released

2010-12-23 Thread Yuri Leikind
Hello all,

WiceGrid  version 0.6 for Rails 2 and 3.0.0.pre1 for Rails 3 are
released.

WiceGrid is a Rails grid plugin.

A more detailed blog post: http://leikind.org/2010/12/23/better-late-than-never
Examples online: http://grid.leikind.org/
Source code Rails 2: http://github.com/leikind/wice_grid
Source code Rails 3: https://github.com/leikind/wice_grid/tree/rails3

Best regards,
Yuri Leikind

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] One form, multiple models, custom validation

2010-12-23 Thread Serafino Picozzi
Hi everyone,

I hope someone can help me solve this problem.
I have a model called Project with :has_many => :tasks. In the new
Project form i allow the creation of 1 to n tasks on the fly thanks to
accepts_nested_attributes_for, where the task model has some validations
that block the creation of the new project if the required fields are
not correct.

This works just fine as it is supposed to work, but here's the problem:

At least one task needs to have some fields not empty, otherwise the
project should not be created. It can be any of the tasks but it's
imperative that at least one of them has those attributes, for the other
tasks these attributes are not required.
Is there a way of doing that without strange hacks?

Thanks in advance for your help

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Difference between rake test:units and individually running ruby -I test test/unit/something_test.rb ?

2010-12-23 Thread Colin Law
On 23 December 2010 03:17, daze  wrote:
> Here's my issue: running ruby -I test test/unit/something_test.rb for
> each of my unit tests works perfectly.
> However, running rake test:units brings errors in all of them - some
> object becomes nil for some reason.
>
> Why might this be happening?
>
> Specifics: the object that is successfully not nil when I run the unit
> tests one-by-one but becomes nil when I do rake test:units is defined
> like this...
>
> klass = self.name.gsub(/Test$/, "").constantize
> instance = klass.first

You could use ruby-debug to break into the test at the point of
failure and inspect the data and see what is going on.  If you have
not used ruby-debug have a look at the Rails Guide on debugging to see
how.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Dynamic JavaScript -- was: Re: Re: Rails - escape_javascript without all the \n\n\n\n\n

2010-12-23 Thread Matteo Latini

On Dec 22, 2010, at 6:05 PM, Marnen Laibow-Koser wrote:

> Please quote when replying.
> 
> Matteo Latini wrote in post #969994:
>> On Dec 21, 2010, at 10:03 PM, Marnen Laibow-Koser wrote:
>> 
>>> 
>> What do you exactly mean by dynamic...
> 
> By "dynamic JavaScript", I mean JavaScript generated on the fly with RJS 
> or ERb rather than an unchanging static .js file.
> 
>> Can you provide some examples
>> in which having dynamic JS can lead to design/development issues?
> 
> I think the use of dynamic JS complicates things needlessly.  It also 
> prevents the client from caching the JS file.  In general, source code 
> (behavior) should be static and data should be dynamic.  This is true on 
> the server side and I believe it's also true on the client side.
> 
> Dynamic code is also harder to test and debug.
> 
>> 
>> Would you classify JSON as dynamic? In some way, json is just
>> like javascript variables.
> 
> I would classify JSON as data.  Since data can be dynamic, I think it is 
> entirely appropriate for an Ajax request (or whatever) to return dynamic 
> JSON, HTML, XML, CSV, or whatever.  Usually this would then be processed 
> by a static JavaScript file.
> 
> Again, my principle is: dynamic data, static source code/behavior. 
> Rails' dynamic JS crams the data in with the source code, where it 
> really doesn't belong.  You wouldn't do that in Ruby; don't do it in JS.

Ruby is actually NOT like that... Actually everything we love about rails
is thanks to dynamic code...

>> 
>> Also, what do you mean by hidden div?
> 
> A div with display: none in its style.
> 
>> Do you mean you just jam
>> the data in it or use it for html templating?
> 
> I don't understand what you're asking.

Do you use html/js templating, or the hidden div is filled with
data?

> 
> Best,
> -- 
> Marnen Laibow-Koser
> http://www.marnen.org
> mar...@marnen.org
> 
> Sent from my iPhone
> 
> -- 
> 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-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
> 

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Dreamhost Rails upgrade troubles

2010-12-23 Thread Colin Law
On 22 December 2010 22:18, Brian Wolk  wrote:
> Thanks for the replies, everyone.
>
> I tried what Water suggested:
>
> $ rake rails:freeze:edge RELEASE=2.3.5

I don't think you want the edge.

If you want to freeze to the version of rails that the app is
currently using then just
rake rails:freeze:gems
should do it I think.

Colin

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Barry Flower is out of the office

2010-12-23 Thread Barry Flower

I will be out of the office starting  23/12/2010 and will not return until
04/01/2011.

Please contact  Adam Brand as my delegate or if urgent a  message can be
left on 0439 467 971


Unless otherwise stated, this email is confidential. If received in error, 
please delete and inform the sender by return email. Unauthorised use, copying 
or distribution is prohibited. Westpac Banking Corporation (ABN 33 007 457 141) 
is not responsible for viruses, or for delays, errors or interception in 
transmission. Unless stated or apparent from its terms, any opinion is not the 
opinion of Westpac Banking Corporation. This message also includes information 
on Westpac Institutional Bank available at westpac.com.au/wibinfo

-- 
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-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.