Re: [Rails] modeling questions

2010-11-19 Thread Bala Paranj
On Thu, Nov 18, 2010 at 9:50 PM, Me chabg...@gmail.com wrote:

 Howdy,  I have a couple questions on the best way to model things in
 rails.

 1.  How to model a table so an admin person can selectively turn on/


Use acts as paranoid plugin.


 off hard/soft deletes from a table at a table level?
 2.  Model a parent/child relationship that can go infinitely deep.
 specifically equipment,  parent = child = child = child 

 Use acts as tree plugin

 --
 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
Cheers,
Bala
RoR Developer Now Available for Hire

-- 
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: Using production DB data locally

2010-11-19 Thread Bala Paranj
Here is the syntax for export and import:
http://bparanj.blogspot.com/2007/06/how-to-export-data-from-one-database.html

On Thu, Nov 18, 2010 at 9:31 PM, Jeremy Woertink li...@ruby-forum.comwrote:

  Read up on mysqldump.
 
  -philip

 Awesome, that would be what I'm looking for. Thanks man!

 --
 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
Cheers,
Bala
RoR Developer Now Available for Hire

-- 
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] connect Model not to Controller named as pluarize of model but to another Controller

2010-11-19 Thread Bala Paranj
Controller is plural if you want all the RESTful actions including index. It
is singular when you don't need index. Because when a resource is singular
there is no need to list them.

On Thu, Nov 18, 2010 at 3:20 PM, sukury47 sukur...@gmail.com wrote:

 before ask you a my question,
 i'm not good at english,
 my description could be awakward;;

 i'am practicing rails3.0 these days.
 i've desinged RESTful app
 but there is some question.

 i'v e made USER model and Login controller.
 login controller has 'add_user' and 'login' actions

 and set route.rb up as below
 resources:users controller ='login'

 but it's not working as i want to do
 it doesn't match localhost:3000/login/user with login/login
 and match that with user/login

 what should I do?

 ps. As i've practiced rails, i thought that
 Controller not named as pluarize of model is bad structure of app
 is it real? do you think so two?

 --
 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
Cheers,
Bala
RoR Developer Now Available for Hire

-- 
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: Rails 3 skip_before_filter

2010-11-19 Thread Ant Peacocke
Thanks Daniel

I had tried skip_filter 
So I tried again and discovered the problem.

In rails 2.3.x 
skip_before_filter could take an array of symbols 
In rails 3 it can not

eg.
Rails 2.3.x the following works but does not work in rails 3
skip_before_filter [:domain_and_site, :multisite_scope, 
:redirect_to_main_domain]
skip_filter [:domain_and_site, :multisite_scope, :redirect_to_main_domain]

In rails 3 they need to be as follows
skip_before_filter :domain_and_site, :multisite_scope, :redirect_to_main_domain
skip_filter :domain_and_site, :multisite_scope, :redirect_to_main_domain

Cheers


On 18 Nov 2010, at 23:31, Daniel Guettler wrote:

 Try skip_filter(*names, blk) instead.
 
 On Nov 18, 11:32 am, Ant a...@levelsystems.net wrote:
 Hi
 
 I am having trouble with an app I am upgrading to Rails 3 where the
 skip_before_filter I have in a controller does not work.
 
 Looking at the rails 3 docshttp://api.rubyonrails.org/
 
 I can't find any mention of skip_before_filter anymore.
 
 Does anyone know if the behavior of skip_before_filter has been
 changed in Rails 3 and why it is not in the docs anymore?
 
 Thanks
 Ant
 
 -- 
 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.
 

-
Ant Peacocke 
Tel :   +33 (0) 9 70 46 63 37 
Port : +33 (0) 6 09 81 06 00 
Web : www.levelsystems.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-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: Rails 3 ActiveRecord queries - I'm missing something very BIG

2010-11-19 Thread Colin Law
On 18 November 2010 22:24, comopasta Gr li...@ruby-forum.com wrote:
 Thanks Philip!

 Yeah I wanted to include the tasks while getting the project.

 I think this does it Rails 3 way:
 @proj = Project.includes(:tasks).find_by_id(params[:id])

 @proj.tasks returns the array of tasks and looks much better.

Just a note to point out that the .includes(:tasks) is not required.
@proj.tasks will still work without it (unless this has changed in
rails 3).  Using includes will reduce the number of hits on the db
however.

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: Rails 3 ActiveRecord queries - I'm missing something very BIG

2010-11-19 Thread Frederick Cheung

On Nov 19, 8:57 am, Colin Law clan...@googlemail.com wrote:
 On 18 November 2010 22:24, comopasta Gr li...@ruby-forum.com wrote:

  Thanks Philip!

  Yeah I wanted to include the tasks while getting the project.

  I think this does it Rails 3 way:
  @proj = Project.includes(:tasks).find_by_id(params[:id])

  @proj.tasks returns the array of tasks and looks much better.

 Just a note to point out that the .includes(:tasks) is not required.
 @proj.tasks will still work without it (unless this has changed in
 rails 3).  Using includes will reduce the number of hits on the db
 however.

Except that when loading a single record it's pretty pointless: a
second query is used to load the tasks, so there isn't much point of
doing it ahead of time (of course if you were loading 20 projects it
would be a different matter)

Fred

-- 
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, Passenger, FreeBSD, Production weird goings on

2010-11-19 Thread John Butler
Hi,

Our production site is going very slow and i was just wondering if
anyone has ever seen stuff like this before in the  logs

One request returning four, notice the db times.

Processing ArticlesController#show (for 193.172.238.146 at 2010-11-18
16:26:03) [GET]
  Session ID: d3ab8cc7b8bfc3154e1f3cdd11a79ec0
  Parameters: {action=show, id=12,
controller=education/articles}
Completed in 201.30773 (0 reqs/sec) | Rendering: 0.84850 (0%) | DB:
200.23051 (99%) | 200 OK
[http://xx.xxx-xxx.com/education/articles/15]
Completed in 201.30773 (0 reqs/sec) | Rendering: 0.67231 (0%) | DB:
200.58331 (99%) | 200 OK
[http://xx.xxx-xxx.com/education/articles/64]
Completed in 198.24940 (0 reqs/sec) | Rendering: 0.76880 (0%) | DB:
197.43730 (99%) | 200 OK
[http://xx.xxx-xxx.com/education/articles/35]
Completed in 199.86349 (0 reqs/sec) | Rendering: 0.66750 (0%) | DB:
199.01294 (99%) | 200 OK
[http://xx.xxx-xxx.com/education/articles/54]

This looks unusual to me too, rendering the same views multiples of
times.

Processing ArticlesController#show (for 200.35.190.97 at 2010-11-18
16:25:14) [GET]
  Session ID: ffcb436fd7bc07baf925eb87ed069aa0
  Parameters: {action=show, id=101,
controller=education/articles}
Rendering  within layouts/application
Rendering education/articles/show
Rendering  within layouts/business/application
Rendering  within layouts/application
Rendering education/articles/show
Rendering  within layouts/application
Rendering education/articles/show
Rendering  within layouts/application
Rendering education/articles/show
Rendering  within layouts/application
Rendering education/articles/show
Rendering  within layouts/application
Rendering  within layouts/application
Rendering education/articles/show
Rendering education/articles/show
Rendering business/articles/show
Completed in 151.21412 (0 reqs/sec) | Rendering: 0.53775 (0%) | DB:
149.92393 (99%) | 200 OK
[http://xx.xxx-xxx.com/business/articles/116]
Completed in 200.98208 (0 reqs/sec) | Rendering: 0.25980 (0%) | DB:
200.69937 (99%) | 200 OK
[http://xx.xxx-.com/education/articles/299]

The production site runs:

rails 2.1.0
postgres
freebsd
passenger

One thing i noticed is Passenger is referencing Ruby Enterprise but the
app reports that it's runnign under FreeBSD's Ruby

This is a system we inherited, not our design or what we are used to.

Anyone shed any light?

JB

-- 
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] Help: delegated association 'App' returning ActionDispatch::Integration::Session instead

2010-11-19 Thread Stefan Alder
class Foo  ActiveRecord::Base
  has_one :bar
  delegate :app, :to = :bar
end

class Bar  ActiveRecord::Base
  belongs_to :app

  def self.attribute_column_names
return @@attr_columns if defined?(@@attr_columns)
readers = content_columns.map { |n| n.name.intern } -
[:created_at,:updated_at]
@@attr_columns ||= readers.map { |k| [k, #{k}=.to_sym] }.flatten
  end
end


This all worked fine until in the console in my staging and production
environments, I assigned bar.app to an undefined variable:

Bar.all.each do |p|
  p.update_attribute(app_id, my_undefined_variable)
end

After doing this, I get:
  NameError: undefined local variable or method
`my_undefined_variable' for main:Object

and
for whatever reason Foo.first.app is now returning an
ActionDispatch::Integration::Session object -- not only in the
console, but through the web, as well.

How can I correct this?

-- 
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 3 ActiveRecord queries - I'm missing something very BIG

2010-11-19 Thread Marnen Laibow-Koser
Frederick Cheung wrote in post #962548:
 On Nov 19, 8:57am, Colin Law clan...@googlemail.com wrote:

 Just a note to point out that the .includes(:tasks) is not required.
 @proj.tasks will still work without it (unless this has changed in
 rails 3). Using includes will reduce the number of hits on the db
 however.

 Except that when loading a single record it's pretty pointless: a
 second query is used to load the tasks, so there isn't much point of
 doing it ahead of time (of course if you were loading 20 projects it
 would be a different matter)

In other words, it sounds like (as in Rails 2) it's generally better to 
use joins than includes.

Not to hijack the thread, but: what's the point of includes?  Why make a 
separate query when the DB could do it in one query with a join?  I've 
never understood this.  What, if anything, am I missing?


 Fred

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: modeling questions

2010-11-19 Thread Marnen Laibow-Koser
Bala Paranj wrote in post #962528:
[...]
 2.  Model a parent/child relationship that can go infinitely deep.
 specifically equipment,  parent = child = child = child 

 Use acts as tree plugin

Hell no!  acts_as_tree should be avoided at all costs.  The adjacency 
list model that it uses is simple, naïve, and inefficient: each level of 
the tree requires a separate query (unless you're using Oracle, which 
has a proprietary extension to its SQL that fixes this).

What you want instead is a *nested set* or *nested interval* structure 
(do a Web search for articles on how these work).  These allow retrieval 
of an entire tree, to arbitrary depth, with a single query.  Rails 
plugins exist for both.  acts_as_nested_interval was buggy last time I 
used it, but has probably been fixed by now.  awesome_nested_set lives 
up to its name.


 --
 Cheers,
 Bala
 RoR Developer Now Available for Hire

The fact that you're recommending acts_as_tree means that people ought 
to think twice about hiring you...

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: select helper with boolean and null/nil values

2010-11-19 Thread pepe
I believe your problems are coming from the fact that you allow
something different than true/false in your DB column. If the column
is supposed to contain a boolean value, why are you allowing it to
contain the null value? A boolean value is either true or false, not
null. If I were you I would force the value to be one or the other and
make the column not null capable. You can enforce the rule with one of
the validation helpers. This is extracted from the
'validates_presence_of' documentation:

If you want to validate the presence of a boolean field (where the
real values are true and false), you will want to use
validates_inclusion_of :field_name, :in = [true, false]. 

If you don't want to display errors and just control the issue
silently you can always use before_save to change the value to false
if needed. Something like:

code
def before_save
  self.my_boolean_column = false unless self.my_boolean_column == true
end
/code

You should check against the value true (meaning that you shouldn't
leave the equality comparison out) because otherwise you could run
into problems if the value is ever something other than true/false/
null. A simple empty string would return true on the condition
otherwise as this example shows:

# This works in all cases
 a = true
= true
 puts 'true' if a == true
true
= nil
 puts 'true' if a
true
= nil

# This works only when comparing against 'true'
 a = ''
= 
 puts 'true' if a == true
= nil
 puts 'true' if a
true  # Notice how this would make the code above work incorrectly on
the before_save
= nil

On Nov 18, 3:59 pm, David Cross dcrosst...@gmail.com wrote:
 I have a boolean column that I would like to modify with a select
 helper element, and have :include_blank map to (database) null.

 This *almost* works.  On the create/edit/update page, if you select
 true/yes it sets the column to true, if you select No/false it sets it
 to false, and if you set it to blank, it sets it to (database) null.
 fantastic.

 Now you edit the record.  If it is True in the database the select
 box picks the correct value.  If it was set to 'no' or (database)null
 however the selection is set to the blank value.

 This is especially problematic if you edit any other field on the
 form, as it resets *everything* back to 'null', regardless of if it
 was false or null to beginwith.

 I have constructed a trivial test application to demonstrate this:

 http://www.cs.rpi.edu/~crossd/selecttest.tar.bz2

 Fire it up in 'rails server' and go tohttp://127.0.0.1:3000/testings

 (I've included a sqlite3 db there with 2 rows in it).  edit one, set
 it to 'Yes', check the 'show' page, edit it again, set it to 'No',
 check the 'show' page, edit it again, set it to blank (you won't have
 to, its already there), and save it and check the show page. notice
 all 3 edits work correctly, but the initial value is NOT set correctly
 for for the 'False' case.

 Is this a bug? am I doing something wrong?
 --
 David E. Cross

-- 
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] Performance issue with Thin

2010-11-19 Thread Elias Gabriel Amaral da Silva
It's not about scalability on a huge site, but the lowest possible
latency for a very small app.

I have a little app with Thin and Sinatra. My app generates the page in
about 50ms. After getting the browser request, thin waits 50ms and then
it takes 300ms sending the page, to Chromium at localhost.

(It takes 300ms to send a static a.html with the word test on it, too,
so it seems to be a lower bound on my machine)

Why is that? Should Mongrel be faster sending the data? Or maybe
Passenger?

The generating time was taken on Sinatra, by doing Time.new.to_f then
printing the diff. The wait / send time was taken at Chromium
resources tab.

The fact that thin waits 50ms before starting to send anything makes
sense, if the app happen to set the header at the end of the output.

But spending 300ms just _sending_ the page to localhost page does
not. It's a 1kb file. Maybe it's forking before every page? (But it
doesn't reload automatically like shotgun, so this makes no sense; it
must be something else)

I could still optimize my app (since its performance is bound by an sql
query that is taking less than 10ms), but my bottleneck isn't there,
it's on Thin.

For comparison, djb's publicfile can send a 100kb image in this same
300ms. (I know it's unfair)

Some versions: ruby 1.9.2p0, thin 1.2.7

-- 
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, Passenger, FreeBSD, Production weird goings on

2010-11-19 Thread Frederick Cheung


On Nov 19, 10:48 am, John Butler li...@ruby-forum.com wrote:
 Hi,

 Our production site is going very slow and i was just wondering if
 anyone has ever seen stuff like this before in the  logs


Is that just multiple simultaneous requests writing to the log file at
the same time, so all the results get interleaved?

If you suspect a database problem then turn on the slow query log (or
even just sitting at the database console and asking it what it's
doing (show processlist for mysql)) to see what queries are slow

Fred
 One request returning four, notice the db times.

 Processing ArticlesController#show (for 193.172.238.146 at 2010-11-18
 16:26:03) [GET]
   Session ID: d3ab8cc7b8bfc3154e1f3cdd11a79ec0
   Parameters: {action=show, id=12,
 controller=education/articles}
 Completed in 201.30773 (0 reqs/sec) | Rendering: 0.84850 (0%) | DB:
 200.23051 (99%) | 200 OK
 [http://xx.xxx-xxx.com/education/articles/15]
 Completed in 201.30773 (0 reqs/sec) | Rendering: 0.67231 (0%) | DB:
 200.58331 (99%) | 200 OK
 [http://xx.xxx-xxx.com/education/articles/64]
 Completed in 198.24940 (0 reqs/sec) | Rendering: 0.76880 (0%) | DB:
 197.43730 (99%) | 200 OK
 [http://xx.xxx-xxx.com/education/articles/35]
 Completed in 199.86349 (0 reqs/sec) | Rendering: 0.66750 (0%) | DB:
 199.01294 (99%) | 200 OK
 [http://xx.xxx-xxx.com/education/articles/54]

 This looks unusual to me too, rendering the same views multiples of
 times.

 Processing ArticlesController#show (for 200.35.190.97 at 2010-11-18
 16:25:14) [GET]
   Session ID: ffcb436fd7bc07baf925eb87ed069aa0
   Parameters: {action=show, id=101,
 controller=education/articles}
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering  within layouts/business/application
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering  within layouts/application
 Rendering  within layouts/application
 Rendering education/articles/show
 Rendering education/articles/show
 Rendering business/articles/show
 Completed in 151.21412 (0 reqs/sec) | Rendering: 0.53775 (0%) | DB:
 149.92393 (99%) | 200 OK
 [http://xx.xxx-xxx.com/business/articles/116]
 Completed in 200.98208 (0 reqs/sec) | Rendering: 0.25980 (0%) | DB:
 200.69937 (99%) | 200 OK
 [http://xx.xxx-.com/education/articles/299]

 The production site runs:

 rails 2.1.0
 postgres
 freebsd
 passenger

 One thing i noticed is Passenger is referencing Ruby Enterprise but the
 app reports that it's runnign under FreeBSD's Ruby

 This is a system we inherited, not our design or what we are used to.

 Anyone shed any light?

 JB

 --
 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: select helper with boolean and null/nil values

2010-11-19 Thread Marnen Laibow-Koser
pepe wrote in post #962574:
 I believe your problems are coming from the fact that you allow
 something different than true/false in your DB column. If the column
 is supposed to contain a boolean value, why are you allowing it to
 contain the null value? A boolean value is either true or false, not
 null.

Poppycock.  It's perfectly OK to have Boolean columns (or any columns) 
be null-capable if the semantics of the data dictate that.

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] Wickedpdf

2010-11-19 Thread johnnybutler7
Im using this plugin to convert a html page into a pdf
https://github.com/mileszs/wicked_pdf
It works great but if i have a file that renders lots of partials then
i need to make copies of them with a view type of .pdf.

So for show.html.erb i need to make a show.pdf.erb, that makes sense.

But if the show file has lots of partials then i need to make copies
of them which i dont need to as i wan tthem to stay the same.

So if i have a header partial i need to have both _header.html.erb and
_header.pdf.erb and so on..

Any ideas how i can avoid having to make a copy of each partial??

JB

-- 
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: modeling questions

2010-11-19 Thread gezope
Hello,

2. http://guides.rubyonrails.org/association_basics.html
Here check has_many :through , has_and_belongs_to_many assotiations,
and I think you may need polymorphic association. You have to try them
out, but there are some help in the tutorial to make decision.

I'm not sure if I understand well your first question, can you write
it more clearly please?

good luck,
gezope


On nov. 19, 05:50, Me chabg...@gmail.com wrote:
 Howdy,  I have a couple questions on the best way to model things in
 rails.

 1.  How to model a table so an admin person can selectively turn on/
 off hard/soft deletes from a table at a table level?
 2.  Model a parent/child relationship that can go infinitely deep.
 specifically equipment,  parent = child = child = child 

-- 
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 3 ActiveRecord queries - I'm missing something very BIG

2010-11-19 Thread comopasta Gr
Hi,

Thanks for the comments. Yeah :include would make only when handling 
some amount of data to include. No much point if it is only a single 
task.

I checked with Mr. Bates and got a lesson about all this. For Rails 2 
but anyway the principle should be the same in Rails 3.

http://asciicasts.com/episodes/181-include-vs-joins

So as some of you pointed out joins is a better option in most of the 
cases, since you can pretty much achieve the same and gain more control.

Regards.

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread pepe
 [...]It's perfectly OK to have Boolean columns (or any columns)
 be null-capable if the semantics of the data dictate that.

Sure. However, in my experience most people make boolean columns null
capable just because or because it's the default behavior of the DB
when defining columns and after a while problems arise because the
returned value is expected to be either true or false, not null: It
is a boolean column, right? Why doesn't it return true or false? Why
do I have to worry about the value being null?.

IMHO boolean columns are just a little different because of their very
nature. Sure, they can be set to be null but I really don't see the
advantage in it. In my experience, if I set the column to default to
either true or false (probably false all the time) and change it as
needed things work much better and things get easier.

-- 
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: Why does Rails try to parse XML received to a controller if mime type sent is text/xml

2010-11-19 Thread Robert Walker
The parameter parsing is happing in middleware.

https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/params_parser.rb

As you can see in the private method parse_formatted_parameters(env) 
the parsing of XML, JSON, YML, etc is based on mime-type.

It seems to me like one could possibly write a small custom middleware 
that overrides the incoming mime-type and insert that middleware just 
before ActionController::ParamsParser.

config.middleware.insert_before(existing_middleware, new_middleware, 
args) – Adds the new middleware before the specified existing middleware 
in the middleware stack.

Seems like that would effectively disable the automatic parsing of 
incoming XML.

-- 
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] how to include view helpers in both action_controller and action_mailer templates (rails 3)

2010-11-19 Thread Ari
There's some terse documentation that helpers can be shared between
action_controller and action_mailer, but I have yet to find an example
of how this is done.  Right now, I'm trying to use a markdown method
in the view templates for both.  I have put the method in the
application helper (app/helpers/application_helper.rb).  It works in
the view templates called from action_controller and descendents, but
not action_mailer.  The action mailer templates return something like
this (from an rspec test):

Failures:
  1) Request should have a send_reject_notice! method which sends a
rejection notice and saves
 Failure/Error: @request.send_reject_notice!
 undefined method `markdown' for ##Class:0x00060441f0:
0x0006041d88
 # ./app/views/request_mailer/reject_notice.html.erb:9:in
`_app_views_request_mailer_reject_notice_html_erb__435172659881060762_50505700__363986106511591665'
 # ./app/mailers/request_mailer.rb:8:in `reject_notice'
 # ./app/models/request.rb:81:in `send_reject_notice!'
 # ./spec/models/request_spec.rb:186:in `block (2 levels) in top
(required)'

Can someone explain what's going 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.



Re: [Rails] Re: Rails 3 ActiveRecord queries - I'm missing something very BIG

2010-11-19 Thread Colin Law
On 19 November 2010 14:45, comopasta Gr li...@ruby-forum.com wrote:
 Hi,

 Thanks for the comments. Yeah :include would make only when handling
 some amount of data to include. No much point if it is only a single
 task.

 I checked with Mr. Bates and got a lesson about all this. For Rails 2
 but anyway the principle should be the same in Rails 3.

 http://asciicasts.com/episodes/181-include-vs-joins

 So as some of you pointed out joins is a better option in most of the
 cases, since you can pretty much achieve the same and gain more control.

However I think that in your example
@proj = Project.find_by_id(params[:id])
@tasks = @proj.tasks

neither is necessary.  Joins will do nothing for you, includes will
provide a small efficiency improvement over not including.

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: I18n::InvalidLocaleData error on load page

2010-11-19 Thread Cluter Vipic
SOLUTION!

take off from /app/config/locales the routes.rb file!

I don't know why the file was there, sorry!!!

bye and I wish all a nice day

Cluter

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread Marnen Laibow-Koser
pepe wrote in post #962590:
 [...]It's perfectly OK to have Boolean columns (or any columns)
 be null-capable if the semantics of the data dictate that.

 Sure. However, in my experience most people make boolean columns null
 capable just because or because it's the default behavior of the DB
[...]

That may be.  For myself, I try to consider carefully whether I need 
null values in a particular field, and what they mean.  For booleans, 
three states are often useful.


 IMHO boolean columns are just a little different because of their very
 nature.

I don't see the difference.  Where do you see it?

 Sure, they can be set to be null but I really don't see the
 advantage in it.

I've run across cases where something was best modeled by SQL-style 
3-valued logic (for example, yes/no/maybe sorts of things).  Why 
*wouldn't* I use a nullable boolean field for that?

 In my experience, if I set the column to default to
 either true or false (probably false all the time) and change it as
 needed things work much better and things get easier.

For a true 2-valued boolean, that's also what I do.

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: modeling questions

2010-11-19 Thread Marnen Laibow-Koser
Please quote when replying.

Zoltan Gero wrote in post #962586:
 Hello,

 2. http://guides.rubyonrails.org/association_basics.html
 Here check has_many :through , has_and_belongs_to_many assotiations,
 and I think you may need polymorphic association. You have to try them
 out, but there are some help in the tutorial to make decision.

Nope.  All you need is awesome_nested_set.


 I'm not sure if I understand well your first question, can you write
 it more clearly please?

 good luck,
 gezope

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: Performance issue with Thin

2010-11-19 Thread Marnen Laibow-Koser
Elias Gabriel Amaral da Silva wrote in post #962579:
 It's not about scalability on a huge site, but the lowest possible
 latency for a very small app.

 I have a little app with Thin and Sinatra.
[...]

Then you're off topic for this list.  This is the Rails mailing list. 
Please go to a Thin or Sinatra forum, or (failing that) to the main Ruby 
list.

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: select helper with boolean and null/nil values

2010-11-19 Thread David Cross
I assure you that if my usage could have been modeled with 2 states instead
of 3, I would have disallowed null :)

Three value is _very_ useful.  If I have to move this to an integer type, I
will (yuck)... but really SQL allows this, the select-box allows this, it
works for OTHER data-types.  (I can have NULL dates that show up as blank in
date_select helpers.  I don't think anyone would suggest that I move to a
text type to support a null date, since NO date isn't a date!).

So, at this point, have we confirmed this is a bug?  Even within ruby, we
could model this as true/false/nil, right?

-- 
David E. Cross

On Fri, Nov 19, 2010 at 11:34 AM, Marnen Laibow-Koser
li...@ruby-forum.comwrote:

 pepe wrote in post #962590:
  [...]It's perfectly OK to have Boolean columns (or any columns)
  be null-capable if the semantics of the data dictate that.
 
  Sure. However, in my experience most people make boolean columns null
  capable just because or because it's the default behavior of the DB
 [...]

 That may be.  For myself, I try to consider carefully whether I need
 null values in a particular field, and what they mean.  For booleans,
 three states are often useful.

 
  IMHO boolean columns are just a little different because of their very
  nature.

 I don't see the difference.  Where do you see it?

  Sure, they can be set to be null but I really don't see the
  advantage in it.

 I've run across cases where something was best modeled by SQL-style
 3-valued logic (for example, yes/no/maybe sorts of things).  Why
 *wouldn't* I use a nullable boolean field for that?

  In my experience, if I set the column to default to
  either true or false (probably false all the time) and change it as
  needed things work much better and things get easier.

 For a true 2-valued boolean, that's also what I do.

 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.comrubyonrails-talk%2bunsubscr...@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] Re: select helper with boolean and null/nil values

2010-11-19 Thread pepe
  IMHO boolean columns are just a little different because of their very
  nature.

 I don't see the difference.  Where do you see it?

  Sure, they can be set to be null but I really don't see the
  advantage in it.

 I've run across cases where something was best modeled by SQL-style
 3-valued logic (for example, yes/no/maybe sorts of things).  Why
 *wouldn't* I use a nullable boolean field for that?

Certainly not very 'academic' but from Wikipedia's page
http://en.wikipedia.org/wiki/Boolean_data_type:

In computer science, the Boolean or logical data type is the most
primitive data type, having one of two values (true or false),
intended to represent the truth values of logic and Boolean algebra.

Why do I think boolean columns are a little different? You could
interpret that null is 'similar' to false because it is not true, but
that could also be the case the other way around. If you look a the
issue from the perspective of well, a boolean column is just a
column, yes, I agree, there is no difference. However if you look at
boolean columns from the perspective of their most likely reason to
exist they are different because they imply that they will always
contain a value, either true or false and null is neither. That is
different IMO than, for example, a date column, which could very
possibly be conceived to contain either a date or no date at all.
Could a boolean column be conceived to be null? Certainly, but again,
not the most likely case in my experience.

Although an interesting proposition I don't think I would ever use a
boolean column to store true/false/maybe sort of things. Of course,
the column could be created to allow it but that, IMO, would defeat
the purpose of the boolean column. I would rather use a different type
because, as it happened to me in the past, a 'true/false/maybe' sort
of scenario can quickly become a 'true/false/maybe/likely/not that
likely/very likely' sort of scenario and then I would need to change
my DB and code.

-- 
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] Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
I have a file, a non-ruby executable or zip file, and I want to trigger
the standard Save file As dialog.

What is the RoR way to do this?

- - - -

I have scoured the net and the only think I can come up with is some
Javascript that gets triggered when the user clicks on an image.


function my_onclick()
{
alert('This is an alert');
var url='/LaunchBrowser.zip';
// window.location = url
window.open(url,'Download');
};

The javascript runs but it opens a new browser tab/window with the
following error:

  Routing Error

  No route matches /LaunchBrowser.zip with {:method=:get}

- - - -

Surely there must be a simple way to enable the user to download a file
that they want to get and that I want to give them.

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread Marnen Laibow-Koser
pepe wrote in post #962618:
 *wouldn't* I use a nullable boolean field for that?
 Certainly not very 'academic' but from Wikipedia's page
 http://en.wikipedia.org/wiki/Boolean_data_type:

 In computer science, the Boolean or logical data type is the most
 primitive data type, having one of two values (true or false),
 intended to represent the truth values of logic and Boolean algebra.

 Why do I think boolean columns are a little different? You could
 interpret that null is 'similar' to false because it is not true,

But I'm not.  I think SQL has it right: null is neither false nor true.

 but
 that could also be the case the other way around. If you look a the
 issue from the perspective of well, a boolean column is just a
 column, yes, I agree, there is no difference. However if you look at
 boolean columns from the perspective of their most likely reason to
 exist they are different because they imply that they will always
 contain a value, either true or false and null is neither.

But that's not even true if we ignore the true 3-valued yes/no/maybe 
case.  The intent of SQL null is to represent *unknown* data.  Imagine 
storing data about your friends, including whether they own a car.  You 
might have a 'has_car' column, which would of course be boolean.

Now, you may not know (because you haven't asked) whether some of your 
friends own a car or not.  So what to put in has_car?  You can't put 
true.  You can't put false.  Guess what, you put null!

 That is
 different IMO than, for example, a date column, which could very
 possibly be conceived to contain either a date or no date at all.
 Could a boolean column be conceived to be null?

Yes, absolutely.  See above.

 Certainly, but again,
 not the most likely case in my experience.

But common enough.  Don't pretend it doesn't happen.


 Although an interesting proposition I don't think I would ever use a
 boolean column to store true/false/maybe sort of things.

Why not?

 Of course,
 the column could be created to allow it but that, IMO, would defeat
 the purpose of the boolean column.

No.  SQL booleans are three-valued.  It makes sense to use that 
property.

 I would rather use a different type
 because, as it happened to me in the past, a 'true/false/maybe' sort
 of scenario can quickly become a 'true/false/maybe/likely/not that
 likely/very likely' sort of scenario and then I would need to change
 my DB and code.

Then change it *at that time*.  You can't know what will happen in the 
future, and therefore you can't really design for it.  Remember YAGNI. 
Don't overdesign.  Don't anticipate if anticipation does not give you a 
present benefit.

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] Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 9:28 AM, Ralph Shnelvar li...@ruby-forum.com wrote:
 I have a file, a non-ruby executable or zip file, and I want to trigger
 the standard Save file As dialog.

 Surely there must be a simple way to enable the user to download a file
 that they want to get and that I want to give them.

What's wrong with putting it somewhere under /public and providing
that URL?

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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 3.0.3 and visit_CoercibleString errors

2010-11-19 Thread anywho
Hi Colin and thanks for your reply.

I had originally just done bundle update rails. When I do that, I
get 40 errors when running my tests. I tried bundle update to update
all my gems incase there were other dependancies. That resulted in 139
failures instead with the visit_CoercibleString error remaining.

The call stack is offering no clues.



On Nov 18, 8:50 am, Colin Law clan...@googlemail.com wrote:
 On 16 November 2010 19:18, anywho eydai...@gmail.com wrote:

  From having no errors with 3.0.2 I now see lots of these errors when
  running my tests.

  undefined method `visit_CoercibleString' for #Arel::Visitors::MySQL:
  0x01074f4298

  Anyone know what this is?

 I saw somewhere that 3.0.3 uses a later version of Arel, with some
 incompatibilities.  Are you using a plugin that has to be updated?
 The call stack when you get the error may tell you which one.

 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] Nested has_many :through problem with Rails 3

2010-11-19 Thread Daniel Berger
Hi,

Rails 3.0.3
Ruby 1.8.7

We've got a nested method we're trying to update for Rails 3. However,
it appears to be generating invalid sql. The old Rails 2 method
worked. What am I doing wrong?

# The tables in question are sites, photos, site_photos

# In the Site model
has_many :photos, :through = :site_photos do
  # Old method. This works.
  #def dates_with_photos
  #  find :all, :select = 'distinct date_taken', :order =
'date_taken'
  #end

  # Attempt at an updated version for Rails 3. This fails.
  def dates_with_photos
order(date_taken).select(distinct(date_taken)).all
  end
end

# Example:
Site.find(5).photos.dates_with_photos

# It generates invalid sql. This is the bit that's invalid:
SELECT photos.*, distinct(date_taken) FROM photos;

Any ideas?

Regards,

Dan

-- 
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[2]: [Rails] Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
Hassan,

Friday, November 19, 2010, 10:37:36 AM, you wrote:

HS On Fri, Nov 19, 2010 at 9:28 AM, Ralph Shnelvar li...@ruby-forum.com 
wrote:
 I have a file, a non-ruby executable or zip file, and I want to trigger
 the standard Save file As dialog.

 Surely there must be a simple way to enable the user to download a file
 that they want to get and that I want to give them.

HS What's wrong with putting it somewhere under /public and providing
HS that URL?

HS -- 
HS Hassan Schroeder  hassan.schroe...@gmail.com
HS twitter: @hassan


I don't understand.   I apologize for being such a novice.

I am also running webrick for testing.   Does that make a difference?

-- 
Best regards,
 Ralphmailto:ral...@dos32.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: Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
I don't understand.   I apologize for being such a novice.

I am also running webrick for testing.   Does that make a difference?

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread David Cross
Ok... lets bring it back around.  Forget it says boolean, for get all of
the baggage that has.  There is a column type called boo (for the sake of
argument) in SQL, that Rails claims to support, but *apparently* the model
is incorrect?  (again, have we confirmed this is a bug, and not something I
am doing wrong?)  and doesn't fully support the boo column type?  This
seems like a rails bug in the boo type.

Interestingly though, it DOES let you set it correctly, and even print it,
just when used in a select() box does it choke?

-- 
David E. Cross

On Fri, Nov 19, 2010 at 12:29 PM, Marnen Laibow-Koser
li...@ruby-forum.comwrote:

 pepe wrote in post #962618:
  *wouldn't* I use a nullable boolean field for that?
  Certainly not very 'academic' but from Wikipedia's page
  http://en.wikipedia.org/wiki/Boolean_data_type:
 
  In computer science, the Boolean or logical data type is the most
  primitive data type, having one of two values (true or false),
  intended to represent the truth values of logic and Boolean algebra.
 
  Why do I think boolean columns are a little different? You could
  interpret that null is 'similar' to false because it is not true,

 But I'm not.  I think SQL has it right: null is neither false nor true.

  but
  that could also be the case the other way around. If you look a the
  issue from the perspective of well, a boolean column is just a
  column, yes, I agree, there is no difference. However if you look at
  boolean columns from the perspective of their most likely reason to
  exist they are different because they imply that they will always
  contain a value, either true or false and null is neither.

 But that's not even true if we ignore the true 3-valued yes/no/maybe
 case.  The intent of SQL null is to represent *unknown* data.  Imagine
 storing data about your friends, including whether they own a car.  You
 might have a 'has_car' column, which would of course be boolean.

 Now, you may not know (because you haven't asked) whether some of your
 friends own a car or not.  So what to put in has_car?  You can't put
 true.  You can't put false.  Guess what, you put null!

  That is
  different IMO than, for example, a date column, which could very
  possibly be conceived to contain either a date or no date at all.
  Could a boolean column be conceived to be null?

 Yes, absolutely.  See above.

  Certainly, but again,
  not the most likely case in my experience.

 But common enough.  Don't pretend it doesn't happen.

 
  Although an interesting proposition I don't think I would ever use a
  boolean column to store true/false/maybe sort of things.

 Why not?

  Of course,
  the column could be created to allow it but that, IMO, would defeat
  the purpose of the boolean column.

 No.  SQL booleans are three-valued.  It makes sense to use that
 property.

  I would rather use a different type
  because, as it happened to me in the past, a 'true/false/maybe' sort
  of scenario can quickly become a 'true/false/maybe/likely/not that
  likely/very likely' sort of scenario and then I would need to change
  my DB and code.

 Then change it *at that time*.  You can't know what will happen in the
 future, and therefore you can't really design for it.  Remember YAGNI.
 Don't overdesign.  Don't anticipate if anticipation does not give you a
 present benefit.

 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.comrubyonrails-talk%2bunsubscr...@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: Re[2]: [Rails] Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 9:57 AM, Ralph Shnelvar ral...@dos32.com wrote:

 Surely there must be a simple way to enable the user to download a file
 that they want to get and that I want to give them.

 HS What's wrong with putting it somewhere under /public and providing
 HS that URL?

 I don't understand.   I apologize for being such a novice.

Files under RAILS_ROOT/public are directly accessible -- like your
app's javascript, css, or image files.

 I am also running webrick for testing.   Does that make a difference?

Nope.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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: Why is my models can't be related using has_one and belongs_to?

2010-11-19 Thread Marnen Laibow-Koser
arga aridarma wrote in post #961823:
 If debug can't be used for checking relationship, how can I check
 whether the
 relationship is already up and running?

With your automated tests.  reflect_on_association should get you 
started.

(If you don't have comprehensive automated tests, write them now, before 
you write any more application code.)

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: Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
Directly accessible how?

What do you recommend as the way to trigger the save dialog?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 10:26 AM, Ralph Shnelvar li...@ruby-forum.com wrote:
 Directly accessible how?

Just provide a link with that URL. This is a basic web operation.

 What do you recommend as the way to trigger the save dialog?

If the file has a .zip or .exe extension, it should be automatic.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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] Ajax Forms: submit_to_remote reliable?

2010-11-19 Thread pipplo
I am trying to implement some ajax forms and I need to have multiple
buttons that submit the whole form.

I initially tried having two submit buttons and I was planning to read
the value of the button in the controller to see which one was
clicked, and then call the appropriate action.  There seems to be a
well known issue with Ajax forms that only the first button gets
serialized so you'll always see the same action. There is a workaround
but it's a little ugly..

I found submit_to_remote which I could use to submit the form data to
different actions, but the book I have says that this function is
unpredictable and shouldn't be used.  I can't find any other place
that mentions this.

Is this still true?  Is it unreliable to use submit_to_remote?  Is
there a better way?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
Hassan Schroeder wrote in post #962641:
 On Fri, Nov 19, 2010 at 10:26 AM, Ralph Shnelvar li...@ruby-forum.com
 wrote:
 Directly accessible how?

 Just provide a link with that URL. This is a basic web operation.


What kind of link?  a ... ... /a
?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 10:59 AM, Ralph Shnelvar li...@ruby-forum.com wrote:

 Just provide a link with that URL. This is a basic web operation.

 What kind of link?  a ... ... /a

Yes. A standard web hyperlink.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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: select helper with boolean and null/nil values

2010-11-19 Thread pepe
  Why do I think boolean columns are a little different? You could
  interpret that null is 'similar' to false because it is not true,

 But I'm not.  I think SQL has it right: null is neither false nor true.

Out of context. I never said it was and 'you' meant 'anybody'. Sorry
if it was misleading. Don't take things so personally.

 But that's not even true if we ignore the true 3-valued yes/no/maybe
 case.  The intent of SQL null is to represent *unknown* data.  Imagine
 storing data about your friends, including whether they own a car.  You
 might have a 'has_car' column, which would of course be boolean.

 Now, you may not know (because you haven't asked) whether some of your
 friends own a car or not.

That is the first thing I ask my friends. Don't you? ;)

So what to put in has_car?  You can't put
 true.  You can't put false.  Guess what, you put null!

I'd put I didn't ask but that wouldn't fit in the boolean
column... ;)

Very true, though.

  That is
  different IMO than, for example, a date column, which could very
  possibly be conceived to contain either a date or no date at all.
  Could a boolean column be conceived to be null?

 Yes, absolutely.  See above.

You have certain ability to repeat yourself.

  Certainly, but again,
  not the most likely case in my experience.

 But common enough.  Don't pretend it doesn't happen.

Not pretending.

  Although an interesting proposition I don't think I would ever use a
  boolean column to store true/false/maybe sort of things.

 Why not?

Fragmented. Because of the explanation I gave. Did you read the whole
paragraph? (see below).

  Of course,
  the column could be created to allow it but that, IMO, would defeat
  the purpose of the boolean column.

 No.  SQL booleans are three-valued.  It makes sense to use that
 property.

I agree with you in the case of *unkown* data.

(From above: you see? this next paragraph explains why. I knew I had
written it somewhere!)

  I would rather use a different type
  because, as it happened to me in the past, a 'true/false/maybe' sort
  of scenario can quickly become a 'true/false/maybe/likely/not that
  likely/very likely' sort of scenario and then I would need to change
  my DB and code.

 Then change it *at that time*.

Sure, and spend who knows how much time changing DB and code if that
happens.

 You can't know what will happen in the
 future, and therefore you can't really design for it.  Remember YAGNI.
 Don't overdesign.  Don't anticipate if anticipation does not give you a
 present benefit.

YAGNI is a very good principle to follow and I certainly try to adhere
to it as much as possible, however it's not the only thing to take
into consideration. There is something else I try to use as much as
possible, it's called personal experience. There have been times when
because of adhering to YAGNI I had to go back and rework A LOT of
code. Now I prefer 'overdesigning' a little bit if I see that there is
a possibility that not doing so might come back to bite me, even if
the only present benefit I get is to have peace of mind and know
that I won't get bitten by it. I'd rather spend 30 or 60 extra minutes
giving a universal solution to a problem or generating related
additional functionality that I might see a use for (but not needed
right now) than having to go back and spend days reworking something
because of those 'saved' 30 or 60 minutes.

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread pepe
Hi David,

I haven't looked at your code, I was just trying to offer a possible
reason/solution to keep you going. I'll try to take a look asap but
I'm busy right now. However, I am using true/false in an HTML select
and it works fine for me.

On Nov 19, 12:59 pm, David Cross dcrosst...@gmail.com wrote:
 Ok... lets bring it back around.  Forget it says boolean, for get all of
 the baggage that has.  There is a column type called boo (for the sake of
 argument) in SQL, that Rails claims to support, but *apparently* the model
 is incorrect?  (again, have we confirmed this is a bug, and not something I
 am doing wrong?)  and doesn't fully support the boo column type?  This
 seems like a rails bug in the boo type.

 Interestingly though, it DOES let you set it correctly, and even print it,
 just when used in a select() box does it choke?

-- 
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] Creating a membership site with Ruby

2010-11-19 Thread Alex A.
Can anyone recommend an off-the-shelf style Ruby membership software?
Or does anyone have experience with how they handled managing members
for a paid subscription membership site?

I was looking for the Ruby equivalent of something like aMember (on
PHP).

Any advice/help would be incredibly, incredibly appreciated.

Cheers,

Alex

-- 
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] Client Needs : Ruby on Rails in NJ ( fast moving position )

2010-11-19 Thread sarah Fernandes


Pls send resumes to sa...@larktechinc.com
Or call 732-372-7051

Here is the requirement for software developer position

Expertise in developing applications for the LINUX environment using
open-source components. Experience in design, development,
implementation and maintenance of web-based applications including
application coding. Experience with Rails is a plus. Experience in the
development of operation, administration and maintenance (OAM)
capabilities, performance and scalability as well as experience with
web application server technologies. Proficiency in both compiled and
scripted languages. Strong communication and leadership skills will be
highly valued. Relevant Technologies: C, C++, Ruby, Rails, Perl,
MySQL, Apache, HTML, CSS, Javascript.

Client: Aviation Industry
Location: NJ
Duration: 6 mths +

Immediate

Kindly refer some of your friends with the same skill. Your help would
be appreciated.
Please let me know if you would be interested. Call  on 732-372-7051
or email your resume on sa...@larktechinc.com
Thanks,
Sarah

-- 
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] Here is the requirement for software developer position

2010-11-19 Thread sarah Fernandes
Client Needs : Ruby on Rails in NJ ( fast moving position )

Pls send resumes to sa...@larktechinc.com
Or call 732-372-7051



Expertise in developing applications for the LINUX environment using
open-source components. Experience in design, development,
implementation and maintenance of web-based applications including
application coding. Experience with Rails is a plus. Experience in the
development of operation, administration and maintenance (OAM)
capabilities, performance and scalability as well as experience with
web application server technologies. Proficiency in both compiled and
scripted languages. Strong communication and leadership skills will be
highly valued. Relevant Technologies: C, C++, Ruby, Rails, Perl,
MySQL, Apache, HTML, CSS, Javascript.

Client: Aviation Industry
Location: NJ
Duration: 6 mths +

Immediate

Kindly refer some of your friends with the same skill. Your help would
be appreciated.
Please let me know if you would be interested. Call  on 732-372-7051
or email your resume on sa...@larktechinc.com
Thanks,
Sarah

-- 
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: Why is my models can't be related using has_one and belongs_to?

2010-11-19 Thread arga aridarma
Thanks for the advice. I have tried to check with the reflections, and surely 
enough the relation is there.
So i tried to change the query in the controller to this:

@users = ComUser.find(:first, :include 
=[:def_jabatan,:def_kelamin,:def_user_role])

and finally the debug shows more attributes, and i can do something like @a = 
@users.def_jabatan.jabatan :D 


Is this the correct way to get the relationship data, that is by adding 
:include in the search, or is there's more elegant way to do it?



- Original Message 
From: Marnen Laibow-Koser li...@ruby-forum.com
To: rubyonrails-talk@googlegroups.com
Sent: Tuesday, November 16, 2010 20:51:44
Subject: [Rails] Re: Re: Why is my models can't be related using has_one and 
belongs_to?

arga aridarma wrote in post #961823:
 If debug can't be used for checking relationship, how can I check
 whether the
 relationship is already up and running?

With your automated tests.  reflect_on_association should get you 
started.

(If you don't have comprehensive automated tests, write them now, before 
you write any more application code.)

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.


-- 
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] Frontend and backend data Not in sync when two requests are made one after other in quick succession

2010-11-19 Thread Uday Shankar
Hi,

We have a web-console that run on rails, on the console we have a button
to add a new entry and below it we show all the entries that are already
present in a box. when we click on the button a request goes to the
backend to add that entry, when that request is complete a pop-up comes
with message that entry was successful or not. This feature has been
working fine. Of late we have observed a bug.
when we click on add a new entry and before that request is complete if
we double click on an entry in the box to view the details of another
entry, the pop-up still comes with success message but when go to the
backend to verify if the entry was made or NOT, we dont find the new
entry.

Can anyone throw light on what could the possible reason be.


This is my first post on this forum, hope i am not breaking any rule by
asking this question here.

Thanks,
Uday.

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Marnen Laibow-Koser
Hassan Schroeder wrote in post #962645:
 On Fri, Nov 19, 2010 at 10:59 AM, Ralph Shnelvar li...@ruby-forum.com
 wrote:

 Just provide a link with that URL. This is a basic web operation.

 What kind of link? a ... ... /a

 Yes. A standard web hyperlink.

In other words: there's nothing magical about HTML files or images.  The 
browser is smart enough to do the right thing with any content you 
provide -- even if that right thing is saving for use with another 
application.

The reason that it's so hard to explicitly trigger a Save dialog in the 
browser is that there's never any need to do so!

 --
 Hassan Schroeder  hassan.schroe...@gmail.com
 twitter: @hassan

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: Nested has_many :through problem with Rails 3

2010-11-19 Thread Alex V.
I am experiencing the same problem as daniel

- has_many through association

- get invalid sql when try to use a scope with select distinct: 
basically, the select i specify does not override the default implicit 
select of the has_many join, but instead gets appended to it (as in 
daniel's example)

Does anyone know if this is by design, or a bug?

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: select helper with boolean and null/nil values

2010-11-19 Thread Marnen Laibow-Koser
pepe wrote in post #962646:
  Why do I think boolean columns are a little different? You could
  interpret that null is 'similar' to false because it is not true,

 But I'm not. I think SQL has it right: null is neither false nor true.

 Out of context. I never said it was and 'you' meant 'anybody'. Sorry
 if it was misleading. Don't take things so personally.

I wasn't taking it personally.  My point was that if I use null in a 
boolean column, I do not interpret it as equivalent to false.  Others 
might, but that would be a mistake, as you know.

[...]
So what to put in has_car? You can't put
 true. You can't put false. Guess what, you put null!

 I'd put I didn't ask but that wouldn't fit in the boolean
 column... ;)

 Very true, though.

Right.  NULL is SQL for I didn't ask.

[...]
  I would rather use a different type
  because, as it happened to me in the past, a 'true/false/maybe' sort
  of scenario can quickly become a 'true/false/maybe/likely/not that
  likely/very likely' sort of scenario and then I would need to change
  my DB and code.

 Then change it *at that time*.

 Sure, and spend who knows how much time changing DB and code if that
 happens.

 You can't know what will happen in the
 future, and therefore you can't really design for it. Remember YAGNI.
 Don't overdesign. Don't anticipate if anticipation does not give you a
 present benefit.

 YAGNI is a very good principle to follow and I certainly try to adhere
 to it as much as possible, however it's not the only thing to take
 into consideration. There is something else I try to use as much as
 possible, it's called personal experience.

Personal experience is valuable, but you can't always know that this 
design will be just like the last one.

 There have been times when
 because of adhering to YAGNI I had to go back and rework A LOT of
 code. Now I prefer 'overdesigning' a little bit if I see that there is
 a possibility that not doing so might come back to bite me, even if
 the only present benefit I get is to have peace of mind and know
 that I won't get bitten by it.

You know nothing of the sort in most cases.  Your actual problems are 
usually not the ones you anticipated -- after all, if you had 
anticipated them, you would have anticipated a solution too.

 I'd rather spend 30 or 60 extra minutes
 giving a universal solution to a problem or generating related
 additional functionality that I might see a use for (but not needed
 right now) than having to go back and spend days reworking something
 because of those 'saved' 30 or 60 minutes.

That's a poor trade-off.  I know it looks good, but it really isn't. 
What you're doing is wasting 30-60 minutes for something that you don't 
need now and may never need.

Barring a few special things like I18N, which really is easier to put in 
at the start, what takes 30-60 minutes to put in now should take 30-60 
minutes to put in two years from now when you actually need it.  If 
that's not the case in your codebase, then you're probably not 
refactoring enough.

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: rails 3.0.3 and visit_CoercibleString errors

2010-11-19 Thread Colin Law
On 19 November 2010 17:43, anywho eydai...@gmail.com wrote:

Could you not top post please, it is easier to follow the thread if
replies are interleaved into previous message as appropriate.  Thanks.

 Hi Colin and thanks for your reply.

 I had originally just done bundle update rails. When I do that, I
 get 40 errors when running my tests. I tried bundle update to update
 all my gems incase there were other dependancies. That resulted in 139
 failures instead with the visit_CoercibleString error remaining.

 The call stack is offering no clues.

Can you show us it?

Colin




 On Nov 18, 8:50 am, Colin Law clan...@googlemail.com wrote:
 On 16 November 2010 19:18, anywho eydai...@gmail.com wrote:

  From having no errors with 3.0.2 I now see lots of these errors when
  running my tests.

  undefined method `visit_CoercibleString' for #Arel::Visitors::MySQL:
  0x01074f4298

  Anyone know what this is?

 I saw somewhere that 3.0.3 uses a later version of Arel, with some
 incompatibilities.  Are you using a plugin that has to be updated?
 The call stack when you get the error may tell you which one.

 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.



-- 
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: Client Needs : Ruby on Rails in NJ ( fast moving position )

2010-11-19 Thread Marnen Laibow-Koser
sarah Fernandes wrote in post #962649:
 Pls send resumes to sa...@larktechinc.com
 Or call 732-372-7051

 Here is the requirement for software developer position

You've now posted this same job 3 times here in less than 24 hours. 
Enough.

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] Frontend and backend data Not in sync when two requests are made one after other in quick succession

2010-11-19 Thread Colin Law
On 19 November 2010 19:52, Uday Shankar li...@ruby-forum.com wrote:
 Hi,

 We have a web-console that run on rails, on the console we have a button
 to add a new entry and below it we show all the entries that are already
 present in a box. when we click on the button a request goes to the
 backend to add that entry, when that request is complete a pop-up comes
 with message that entry was successful or not. This feature has been
 working fine. Of late we have observed a bug.
 when we click on add a new entry and before that request is complete if
 we double click on an entry in the box to view the details of another
 entry, the pop-up still comes with success message but when go to the
 backend to verify if the entry was made or NOT, we dont find the new
 entry.

 Can anyone throw light on what could the possible reason be.

Have a look in the log (log/development.log assuming running in
development mode) to get more information about what is going on.
Also you can use various methods to debug your code in order to
understand the problem.  See the Rails Guide on debugging if you are
not familiar with these techniques.

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: Help: delegated association 'App' returning ActionDispatch::Integration::Session instead

2010-11-19 Thread Stefan Alder
Update- I think the ActionDispatch::Integration::Session is only
returned in console.

Seems that console believes I'm calling it's own 'app' method even
though I've delegated it to an association.

Is this something worth filing a bug report on?  Should I just rename
App to something else, however unnatural it may be?



On Fri, Nov 19, 2010 at 2:51 AM, Stefan Alder twigbra...@gmail.com wrote:
 class Foo  ActiveRecord::Base
  has_one :bar
  delegate :app, :to = :bar
 end

 class Bar  ActiveRecord::Base
  belongs_to :app

  def self.attribute_column_names
    return @@attr_columns if defined?(@@attr_columns)
    readers = content_columns.map { |n| n.name.intern } -
 [:created_at,:updated_at]
    @@attr_columns ||= readers.map { |k| [k, #{k}=.to_sym] }.flatten
  end
 end


 This all worked fine until in the console in my staging and production
 environments, I assigned bar.app to an undefined variable:

 Bar.all.each do |p|
  p.update_attribute(app_id, my_undefined_variable)
 end

 After doing this, I get:
  NameError: undefined local variable or method
 `my_undefined_variable' for main:Object

 and
 for whatever reason Foo.first.app is now returning an
 ActionDispatch::Integration::Session object -- not only in the
 console, but through the web, as well.

 How can I correct this?


-- 
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: Client Needs : Ruby on Rails in NJ ( fast moving position )

2010-11-19 Thread Colin Law
On 19 November 2010 20:33, Marnen Laibow-Koser li...@ruby-forum.com wrote:
 sarah Fernandes wrote in post #962649:
 Pls send resumes to sa...@larktechinc.com
 Or call 732-372-7051

 Here is the requirement for software developer position

 You've now posted this same job 3 times here in less than 24 hours.
 Enough.


It is obviously such a 'fast moving position' that the first two
developers have come and gone, hence the need for a third one.

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: Client Needs : Ruby on Rails in NJ ( fast moving position )

2010-11-19 Thread Marnen Laibow-Koser
Colin Law wrote in post #962675:
 On 19 November 2010 20:33, Marnen Laibow-Koser li...@ruby-forum.com
 wrote:
 sarah Fernandes wrote in post #962649:
 Pls send resumes to sa...@larktechinc.com
 Or call 732-372-7051

 Here is the requirement for software developer position

 You've now posted this same job 3 times here in less than 24 hours.
 Enough.


 It is obviously such a 'fast moving position' that the first two
 developers have come and gone, hence the need for a third one.

LOL!  Well said.


 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.



[Rails] Re: select helper with boolean and null/nil values

2010-11-19 Thread pepe
 Personal experience is valuable, but you can't always know that this
 design will be just like the last one.

I don't think about it as a matter of design but just common sense in
most cases. I'll explain later.

  I'd rather spend 30 or 60 extra minutes
  giving a universal solution to a problem or generating related
  additional functionality that I might see a use for (but not needed
  right now) than having to go back and spend days reworking something
  because of those 'saved' 30 or 60 minutes.

 That's a poor trade-off.  I know it looks good, but it really isn't.
 What you're doing is wasting 30-60 minutes for something that you don't
 need now and may never need.

Just a silly example:

At a place I used to work I was using a much less flexible language
than Ruby. This language didn't have by far the capabilities to
calculate dates or handle strings that Ruby has or the flexibility to
run SQL statements that Rails provides. So during my work there I was
tired of hard coding SQL statements all over the place, escaping
countless quotes, etc. The code statements were ugly looking and
difficult to read. I didn't really 'need' a tool or a system to make
the whole thing more flexible, nobody asked for it!, but I got to it
and created a system to handle the SQL statements in a much more
flexible manner and while I was at it I built additional string and
date handling routines that I didn't need at the time. They were
initially conceived only to solve the SQL string problems. After 1/2 a
day or so of work I had a good additional set of functions that could
handle not only the SQL string problems I had but also much more
generic string functionality that was natively missing in the
language. Think something like 'squeeze'.

Did I need all that? No. Was it nice to work with it after I was done?
You betcha! And the funny thing is that after I created all that the
other developers started using the string and date functions I had
created. So what did the 1/2 day bought me? Personally, not much,
maybe satisfaction would be most of it. To the company it meant
countless of productivity hours gained, only because I over-
engineered something I didn't even need to do.

-- 
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: select helper with boolean and null/nil values

2010-11-19 Thread Marnen Laibow-Koser
pepe wrote in post #962678:
 Personal experience is valuable, but you can't always know that this
 design will be just like the last one.

 I don't think about it as a matter of design but just common sense in
 most cases. I'll explain later.

  I'd rather spend 30 or 60 extra minutes
  giving a universal solution to a problem or generating related
  additional functionality that I might see a use for (but not needed
  right now) than having to go back and spend days reworking something
  because of those 'saved' 30 or 60 minutes.

 That's a poor trade-off. I know it looks good, but it really isn't.
 What you're doing is wasting 30-60 minutes for something that you don't
 need now and may never need.

 Just a silly example:

 At a place I used to work I was using a much less flexible language
 than Ruby. This language didn't have by far the capabilities to
 calculate dates or handle strings that Ruby has or the flexibility to
 run SQL statements that Rails provides. So during my work there I was
 tired of hard coding SQL statements all over the place, escaping
 countless quotes, etc. The code statements were ugly looking and
 difficult to read. I didn't really 'need' a tool or a system to make
 the whole thing more flexible, nobody asked for it!,

At that point, you *did* need it.  Ugly or repetitive code is an example 
of a need -- in this case, for refactoring or generalization.

[...]
 Did I need all that? No.

Yes you did, by the definition of need Im using.

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: Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
I am so frustrated.  My HAML code is

  %div{'id' = becca_chap_1_human_img_div}
 %a{'id' = download_file_a, 'href' = '/public/LaunchBrowser.zip'}
   = image_tag('PhotosOfBecca.png', :'id' = becca_chap_1_human_img)

The HAML parses correctly ...
Yet when I click on the image I get a routing error
  Routing Error

  No route matches /public/LaunchBrowser.zip with {:method=:get}

What am I doing wrong?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 3:09 PM, Ralph Shnelvar li...@ruby-forum.com wrote:

     %a{'id' = download_file_a, 'href' = '/public/LaunchBrowser.zip'}

You could look at your css/js/image references as examples, as I
said previously...

  No route matches /public/LaunchBrowser.zip with {:method=:get}

.. which would show you that '/public' is *not* part of the URL.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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] Enabling preprocessing in Erubis makes views much faster

2010-11-19 Thread Fjan
I wrote a 5 line hack that you can drop into your initializers
directory to enable preprocessing in Erubis. This will run code in 
%=== % brackets at compile time making views considerably faster for
rails helpers that only need to be evaluated once instead of on each
render (the Erubis docs mention 20-40% speed increase but obviously it
depends on the amount you precompile).

For example:
 %=== password_field_tag :password %
will produce this *at compile time*:
input id=password name=password type=password /

Of course, many helpers produce a different output depending on the
context which is not available at compile time so for those you would
need to stick with the usual %= %. For example link_to will work
only if it does not need the action name to generate the route.

It doesn't work yet for stylesheet_link_tag and
javascript_include_tag which is a shame because those would be
excellent candidates to eval at compile time. Perhaps someone with a
deeper knowledge of Rails can say what would be needed to make that
work.

https://gist.github.com/707461

module ActionView
  class Base
def get_binding;return binding;end
  end

  class Template
module Handlers
  class Erubis  ::Erubis::Eruby
def add_expr_debug(src, code)
  src  @output_buffer.safe_concat(' 
escape_text(eval(code,ActionView::Base.new.get_binding).to_s)  ');
end
  end
end
  end
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] Bug when serializing to_xml when :foreign_key is named like association

2010-11-19 Thread turkan
Think of the following models:

class User  ActiveRecord::Base
  has_many :created_entities, :class_name = Entity, :foreign_key =
created_by
end

class Entity  ActiveRecord::Base
  belongs_to :created_by, :class_name = User, :foreign_key =
created_by
end

There is also a created_by integer field in the Entity migration.
Everything seems to work fine with these model (fetching the
association and so on), but when I try to serialize
Entity.to_xml :include = :created_by (or include something other the
model has as association) it fails (NoMethodError: undefined method
`macro' for nil:NilClass).
For full trace see: 
http://stackoverflow.com/questions/4217923/nomethoderror-when-serializing-to-xml

But as soon as I rename the association in the Entity model to:
belongs_to :creator, :class_name = User, :foreign_key =
created_by
the serialization to_xml start to work again.

Im using Rails 3.0.1. Can someone reproduce that?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Ralph Shnelvar
I'm sorry, Hassan, I still don't get it.

When I make that link, i.e.
  /public/LaunchBrowser.zip
why is the link going through rails routing?

If I make the link
  LaunchBrowser.zip
then rails seems to want the link to be
  http://localhost:3000/marketing/LaunchBrowser.zip
which makes sense because the the file setting up the link to 
LaunchBrowser.zip is
  F:\Ralph-Rails-Apps\UltraDedup\app\views\marketing\demodownload.haml

Again, sorry to be so dense.

-- 
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: Bug when serializing to_xml when :foreign_key is named like association

2010-11-19 Thread turkan
Guess what ... solved in Rails 3.0.3 :-)

On Nov 20, 2:12 am, turkan kai.schl...@googlemail.com wrote:
 Think of the following models:

 class User  ActiveRecord::Base
   has_many :created_entities, :class_name = Entity, :foreign_key =
 created_by
 end

 class Entity  ActiveRecord::Base
   belongs_to :created_by, :class_name = User, :foreign_key =
 created_by
 end

 There is also a created_by integer field in the Entity migration.
 Everything seems to work fine with these model (fetching the
 association and so on), but when I try to serialize
 Entity.to_xml :include = :created_by (or include something other the
 model has as association) it fails (NoMethodError: undefined method
 `macro' for nil:NilClass).
 For full trace 
 see:http://stackoverflow.com/questions/4217923/nomethoderror-when-seriali...

 But as soon as I rename the association in the Entity model to:
 belongs_to :creator, :class_name = User, :foreign_key =
 created_by
 the serialization to_xml start to work again.

 Im using Rails 3.0.1. Can someone reproduce that?

-- 
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: Triggering the standard Save dialog

2010-11-19 Thread Hassan Schroeder
On Fri, Nov 19, 2010 at 5:21 PM, Ralph Shnelvar li...@ruby-forum.com wrote:

 If I make the link
  LaunchBrowser.zip
 then rails seems to want the link to be
  http://localhost:3000/marketing/LaunchBrowser.zip
 which makes sense because the the file setting up the link to
 LaunchBrowser.zip is
  F:\Ralph-Rails-Apps\UltraDedup\app\views\marketing\demodownload.haml

Because you haven't made it /LaunchBrowser.zip.

Have you *looked* at any of your standard css/js/image file URLs
that currently live under RAILS_ROOT/public? Pick one. Look at the
generated markup for that. If that doesn't answer your questions, ask
again, pasting it in as an example.

-- 
Hassan Schroeder  hassan.schroe...@gmail.com
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-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: Bug when serializing to_xml when :foreign_key is named like association

2010-11-19 Thread Frederick Cheung


On Nov 20, 1:26 am, turkan kai.schl...@googlemail.com wrote:
 Guess what ... solved in Rails 3.0.3 :-)


I'd say you're skating on thin ice: what's some_entity.created_by
supposed to return: the foreign_key or an instance of User?

Fred
 On Nov 20, 2:12 am, turkan kai.schl...@googlemail.com wrote:



  Think of the following models:

  class User  ActiveRecord::Base
    has_many :created_entities, :class_name = Entity, :foreign_key =
  created_by
  end

  class Entity  ActiveRecord::Base
    belongs_to :created_by, :class_name = User, :foreign_key =
  created_by
  end

  There is also a created_by integer field in the Entity migration.
  Everything seems to work fine with these model (fetching the
  association and so on), but when I try to serialize
  Entity.to_xml :include = :created_by (or include something other the
  model has as association) it fails (NoMethodError: undefined method
  `macro' for nil:NilClass).
  For full trace 
  see:http://stackoverflow.com/questions/4217923/nomethoderror-when-seriali...

  But as soon as I rename the association in the Entity model to:
  belongs_to :creator, :class_name = User, :foreign_key =
  created_by
  the serialization to_xml start to work again.

  Im using Rails 3.0.1. Can someone reproduce that?

-- 
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] This installation of RMagick was configured with ImageMagick 6.6.4 but ImageMagick 6.6.5-0 is in use

2010-11-19 Thread CuriousNewbie
Hi all, just installed ImageMagick on my Mac, then added the gem
rmagick, and not can't launch the server on my local machine. Anyone
experience this or have any ideas?



rails s
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle: This
installation of RMagick was configured with ImageMagick 6.6.4 but
ImageMagick 6.6.5-0 is in use. (RuntimeError)
from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
active_support/dependencies.rb:239:in `require'
from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
active_support/dependencies.rb:225:in `load_dependency'
from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
active_support/dependencies.rb:591:in `new_constants_in'
from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
active_support/dependencies.rb:225:in `load_dependency'
from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
active_support/dependencies.rb:239:in `require'
from /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/rmagick.rb:11
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
64:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
62:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
62:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
51:in `each'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
51:in `require'
from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler.rb:112:in
`require'
from /Users/bhellman/Sites/cline/config/application.rb:7
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
28:in `require'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
28
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
27:in `tap'
from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
27
from script/rails:6:in `require'
from script/rails:6

-- 
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: This installation of RMagick was configured with ImageMagick 6.6.4 but ImageMagick 6.6.5-0 is in use

2010-11-19 Thread CuriousNewbie
Bundle install works fine...

Using rmagick (2.13.1)


On Nov 19, 8:12 pm, CuriousNewbie bhellm...@gmail.com wrote:
 Hi all, just installed ImageMagick on my Mac, then added the gem
 rmagick, and not can't launch the server on my local machine. Anyone
 experience this or have any ideas?

 rails s
 /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle: This
 installation of RMagick was configured with ImageMagick 6.6.4 but
 ImageMagick 6.6.5-0 is in use. (RuntimeError)
         from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
 active_support/dependencies.rb:239:in `require'
         from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
 active_support/dependencies.rb:225:in `load_dependency'
         from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
 active_support/dependencies.rb:591:in `new_constants_in'
         from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
 active_support/dependencies.rb:225:in `load_dependency'
         from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
 active_support/dependencies.rb:239:in `require'
         from /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/rmagick.rb:11
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 64:in `require'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 64:in `require'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 62:in `each'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 62:in `require'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 51:in `each'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
 51:in `require'
         from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler.rb:112:in
 `require'
         from /Users/bhellman/Sites/cline/config/application.rb:7
         from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
 28:in `require'
         from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
 28
         from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
 27:in `tap'
         from /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
 27
         from script/rails:6:in `require'
         from script/rails:6

-- 
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: modeling questions

2010-11-19 Thread Frederick Cheung


On Nov 19, 12:23 pm, Marnen Laibow-Koser li...@ruby-forum.com wrote:


 Hell no!  acts_as_tree should be avoided at all costs.  The adjacency
 list model that it uses is simple, naïve, and inefficient: each level of
 the tree requires a separate query (unless you're using Oracle, which
 has a proprietary extension to its SQL that fixes this).

 What you want instead is a *nested set* or *nested interval* structure
 (do a Web search for articles on how these work).  These allow retrieval
 of an entire tree, to arbitrary depth, with a single query.  Rails
 plugins exist for both.  acts_as_nested_interval was buggy last time I
 used it, but has probably been fixed by now.  awesome_nested_set lives
 up to its name.


Although nested sets make inserts very expensive. Like most data
modelling questions, the sort of access patterns that will be used -
while acts as tree makes getting a whole subtree expensive, if you
never need to do that in your app, who cares?

Fred


  --
  Cheers,
  Bala
  RoR Developer Now Available for Hire

 The fact that you're recommending acts_as_tree means that people ought
 to think twice about hiring you...

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

 Sent from my iPhone

 --
 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] Rails 3 Active Record bug?

2010-11-19 Thread Rajinder Yadav

I'm getting strange results with rails 3.0.1

In each case the query seems to return the correct row, however only one 
of them gives me the correct value for the name field.


ya...@six9:$ rails console
Loading development environment (Rails 3.0.1)

irb(main):001:0 Ticket
= Ticket(id: integer, name: string, seat: string, address: text, price: 
decimal, email: string, created_at: datetime, updated_at: datetime)


irb(main):002:0 t = Ticket.where name like ?, Pushpa Yadav
= [#Ticket id: 2, name: Pushpa Yadav, seat: 12d, address: 12 
Rosewood Ave.,Toronto,ON, price: #BigDecimal:34cd558,'0.1E2',9(18), 
email: ya...@email.ca, created_at: 2010-11-20 06:37:21, updated_at: 
2010-11-20 06:37:21]

irb(main):003:0 t.name
= Ticket

irb(main):004:0 t = Ticket.find 2
= #Ticket id: 2, name: Pushpa Yadav, seat: 12d, address: 12 
Rosewood Ave.,Toronto,ON, price: #BigDecimal:3443dd0,'0.1E2',9(18), 
email: ya...@email.ca, created_at: 2010-11-20 06:37:21, updated_at: 
2010-11-20 06:37:21
irb(main):005:0 t.name 


= Pushpa Yadav

irb(main):007:0* t = Ticket.where name is ?, Pushpa Yadav
= [#Ticket id: 2, name: Pushpa Yadav, seat: 12d, address: 12 
Rosewood Ave.,Toronto,ON, price: #BigDecimal:33d1078,'0.1E2',9(18), 
email: ya...@email.ca, created_at: 2010-11-20 06:37:21, updated_at: 
2010-11-20 06:37:21]
irb(main):008:0 t.name 


= Ticket

irb(main):009:0 t = Ticket.where name = ?, Pushpa Yadav
= [#Ticket id: 2, name: Pushpa Yadav, seat: 12d, address: 12 
Rosewood Ave.,Toronto,ON, price: #BigDecimal:33bcbc8,'0.1E2',9(18), 
email: ya...@email.ca, created_at: 2010-11-20 06:37:21, updated_at: 
2010-11-20 06:37:21]

irb(main):010:0 t.name
= Ticket

irb(main):010:0 t = Ticket.where name like ?, pushpa%
= [#Ticket id: 2, name: Pushpa Yadav, seat: 12d, address: 12 
Rosewood Ave.,Toronto,ON, price: #BigDecimal:33bcbc8,'0.1E2',9(18), 
email: ya...@email.ca, created_at: 2010-11-20 06:37:21, updated_at: 
2010-11-20 06:37:21]

irb(main):010:0 t.name
= Ticket


I am using sqlite3, here is the sqlite3 console output (which seems to 
work fine).


sqlite select * from tickets;
1|Rajinder Yadav|12c|10 Rosewood 
Ave.,Toronto,ON|12|ya...@email.ca|2010-11-20 06:36:12.924931|2010-11-20 
06:36:12.924931
2|Pushpa Yadav|12d|12 Rosewood 
Ave.,Toronto,ON|10|ya...@email.ca|2010-11-20 06:37:21.894155|2010-11-20 
06:37:21.894155


sqlite select * from tickets where name like Pushpa Yadav;

2|Pushpa Yadav|12d|12 Rosewood 
Ave.,Toronto,ON|10|ya...@email.ca|2010-11-20 06:37:21.894155|2010-11-20 
06:37:21.894155


sqlite select * from tickets where name is Pushpa Yadav;

2|Pushpa Yadav|12d|12 Rosewood 
Ave.,Toronto,ON|10|ya...@email.ca|2010-11-20 06:37:21.894155|2010-11-20 
06:37:21.894155


sqlite select * from tickets where name = Pushpa Yadav;

2|Pushpa Yadav|12d|12 Rosewood 
Ave.,Toronto,ON|10|ya...@email.ca|2010-11-20 06:37:21.894155|2010-11-20 
06:37:21.894155


sqlite select * from tickets where name like pushpa%;

2|Pushpa Yadav|12d|12 Rosewood 
Ave.,Toronto,ON|10|ya...@email.ca|2010-11-20 06:37:21.894155|2010-11-20 
06:37:21.894155



my gem list is
ya...@six9:$ gem list

*** LOCAL GEMS ***

abstract (1.0.0)
actionmailer (3.0.1)
actionpack (3.0.1)
activemodel (3.0.1)
activerecord (3.0.1)
activeresource (3.0.1)
activesupport (3.0.1)
arel (2.0.1, 1.0.1)
authlogic (2.1.6)
autotest (4.4.2, 4.4.1)
autotest-rails-pure (4.1.1, 4.1.0)
babosa (0.2.0)
bcrypt-ruby (2.1.2)
builder (2.1.2)
bundler (1.0.3)
calendar_date_select (1.16.1)
cancan (1.4.0)
devise (1.1.3)
diff-lcs (1.1.2)
erubis (2.6.6)
fastri (0.3.1.1)
forgery (0.3.6)
friendly_id (3.1.7)
grackle (0.1.10)
gruff (0.3.6)
i18n (0.4.2)
json (1.4.6)
mail (2.2.9)
mechanize (1.0.0)
mime-types (1.16)
minitest (1.7.2, 1.6.0)
nifty-generators (0.4.2)
nokogiri (1.4.3.1)
oauth (0.4.4, 0.4.3)
patron (0.4.10, 0.4.9)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack-test (0.5.6)
rails (3.0.1)
railties (3.0.1)
rake (0.8.7)
rdoc (2.5.11, 2.5.8)
RedCloth (4.2.3)
rmagick (2.13.1)
rspec (2.0.1)
rspec-core (2.0.1)
rspec-expectations (2.0.1)
rspec-mocks (2.0.1)
rspec-rails (2.0.1)
sqlite3-ruby (1.3.2, 1.3.1)
thor (0.14.4, 0.14.3)
tiny_mce (0.1.4)
tkri (0.9.5)
treetop (1.4.8)
tzinfo (0.3.23)
w3c_validators (1.1.1)
warden (1.0.1, 0.10.7)
webrat (0.7.2)
will_paginate (3.0.pre2, 2.3.15)
wxruby (2.0.0 x86_64-linux)

--
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely

GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1

--
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: This installation of RMagick was configured with ImageMagick 6.6.4 but ImageMagick 6.6.5-0 is in use

2010-11-19 Thread CuriousNewbie
I ended up having to use mac ports to set the older version as active.
that did the trick.

On Nov 19, 8:13 pm, CuriousNewbie bhellm...@gmail.com wrote:
 Bundle install works fine...

 Using rmagick (2.13.1)

 On Nov 19, 8:12 pm, CuriousNewbie bhellm...@gmail.com wrote:







  Hi all, just installed ImageMagick on my Mac, then added the gem
  rmagick, and not can't launch the server on my local machine. Anyone
  experience this or have any ideas?

  rails s
  /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick2.bundle: This
  installation of RMagick was configured with ImageMagick 6.6.4 but
  ImageMagick 6.6.5-0 is in use. (RuntimeError)
          from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
  active_support/dependencies.rb:239:in `require'
          from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
  active_support/dependencies.rb:225:in `load_dependency'
          from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
  active_support/dependencies.rb:591:in `new_constants_in'
          from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
  active_support/dependencies.rb:225:in `load_dependency'
          from /Users/bhellman/.gem/ruby/1.8/gems/activesupport-3.0.0/lib/
  active_support/dependencies.rb:239:in `require'
          from /Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/rmagick.rb:11
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  64:in `require'
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  64:in `require'
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  62:in `each'
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  62:in `require'
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  51:in `each'
          from 
  /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler/runtime.rb:
  51:in `require'
          from /Library/Ruby/Gems/1.8/gems/bundler-1.0.0/lib/bundler.rb:112:in
  `require'
          from /Users/bhellman/Sites/cline/config/application.rb:7
          from 
  /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
  28:in `require'
          from 
  /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
  28
          from 
  /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
  27:in `tap'
          from 
  /Library/Ruby/Gems/1.8/gems/railties-3.0.0/lib/rails/commands.rb:
  27
          from script/rails:6:in `require'
          from script/rails:6

-- 
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.