[Rails] Re: when migrating add_index error: invalid date

2011-02-11 Thread Nikos Dimitrakopoulos
Replace mysql2 gem with mysql (at least for development mode under windows). 
Solved here 
: https://groups.google.com/d/msg/rubyonrails-talk/a-wyECimZ5g/1F0sgAcje0cJ

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Hbar color - openflash chart

2011-02-11 Thread Jeffrey Bonson
Hi, am using Openflashchart plugin,How can we change the color of each
bar in Hbar openflash chart

this is the code i have inside my controller



def stat_bar
title = Title.new(session[:tag])

hbar = HBar.new

hbar.values = [HBarValue.new(0,10),HBarValue.new(0,20)]
hbar.colour = '#FF8000' # this works for the two bars

chart = OpenFlashChart.new
chart.set_title(title)
chart.add_element(hbar)

x = XAxis.new
x.set_offset(false)
chart.set_x_axis(x)

y = YAxis.new
y.set_offset(true)
y.set_labels([Yes,No])
chart.set_y_axis(y)

render :text = chart.to_s
  end


Please help !!

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@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] Weird form behavior

2011-02-11 Thread Tim Uckun
On Fri, Feb 11, 2011 at 4:40 PM, Tim Uckun timuc...@gmail.com wrote:
 On Fri, Feb 11, 2011 at 4:38 PM, Jim Ruther Nill jvn...@gmail.com wrote:
 I'm not sure but if you look at
 http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
 your params does not have the same format as the one stated in the link.  It
 should be
 contact_methods_attributes=[{details=test, id=1,
 _destroy=false}]


The problem turned out to be attr_accessible You have to put
contact_methods_attributes in there and not contact_methods.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Like gsub but the parameter is matchdata

2011-02-11 Thread Jatin kumar
On Fri, Feb 11, 2011 at 8:02 AM, Ralph Shnelvar li...@ruby-forum.comwrote:

  Check this out.
  http://www.ruby-doc.org/core/classes/String.html#M001186

 I must be blind.   I see no MatchData anywhere.

 I see *match* which is a string ... but no MatchData.

 What exactly do you mean when you say MatchData and not a string. Can you
show a dummy example of what do you want to achieve.

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

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit 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-talk@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] Get request by session id?

2011-02-11 Thread Hans Hartmann
Hello,

i've stored my sessions in a session table and can acces them via:

Session.all (id, session_id, data, c_at, u_at)

also i can get my current session_id via:

request.session_options[:id]

Is there a possibility to find all request containing to every single
session - to get an overview beyond the env of every session.

Something like:
Request.find_by_session_id(session_id).env

Thanks for your answers 'till now.

Hans

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Get request by session id?

2011-02-11 Thread Frederick Cheung


On Feb 11, 10:55 am, Hans Hartmann li...@ruby-forum.com wrote:
 Hello,

 i've stored my sessions in a session table and can acces them via:

 Session.all (id, session_id, data, c_at, u_at)

 also i can get my current session_id via:

 request.session_options[:id]

 Is there a possibility to find all request containing to every single
 session - to get an overview beyond the env of every session.

 Something like:
 Request.find_by_session_id(session_id).env


I'm not sure what you're after - requests aren't persisted anywhere
(unless you're doing something special to do that)

Fred
 Thanks for your answers 'till now.

 Hans

 --
 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-talk@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: Get request by session id?

2011-02-11 Thread Hans Hartmann
 I'm not sure what you're after - requests aren't persisted anywhere
 (unless you're doing something special to do that)

I want to find a possibility to get the PATH_INFO of each session user.

My first opinion to do that was to list the env of all sessions.

The reason I want to do that is to forbid, that two session users can 
access an update form on the same time.

I have to check on which site all session users currently are.

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Weird form behavior

2011-02-11 Thread Jim Ruther Nill
oh right! we forgot about that one when we were discussing it minutes ago.
:D at least you figured it out.

On Fri, Feb 11, 2011 at 6:05 PM, Tim Uckun timuc...@gmail.com wrote:

 On Fri, Feb 11, 2011 at 4:40 PM, Tim Uckun timuc...@gmail.com wrote:
  On Fri, Feb 11, 2011 at 4:38 PM, Jim Ruther Nill jvn...@gmail.com
 wrote:
  I'm not sure but if you look at
 
 http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
  your params does not have the same format as the one stated in the link.
  It
  should be
  contact_methods_attributes=[{details=test, id=1,
  _destroy=false}]
 

 The problem turned out to be attr_accessible You have to put
 contact_methods_attributes in there and not contact_methods.

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Like gsub but the parameter is matchdata

2011-02-11 Thread Jim Ruther Nill
i think what he meant was like the scan function for string but instead of
returning String objects, you get MatchData objects.

On Fri, Feb 11, 2011 at 6:26 PM, Jatin kumar jatinkumar.n...@gmail.comwrote:



 On Fri, Feb 11, 2011 at 8:02 AM, Ralph Shnelvar li...@ruby-forum.comwrote:

  Check this out.
  http://www.ruby-doc.org/core/classes/String.html#M001186

 I must be blind.   I see no MatchData anywhere.

 I see *match* which is a string ... but no MatchData.

 What exactly do you mean when you say MatchData and not a string. Can you
 show a dummy example of what do you want to achieve.

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

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit 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-talk@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.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Map integration with showing places within the particular radius

2011-02-11 Thread Peter Bell
And the geokit-rails3 gem which adds basic finders by distance. It's not a 
completely functional port of the old geokit-rails because of all the changes 
in Rails3, but the basic distance finders work just fine.

https://github.com/jlecour/geokit-rails3

Best Wishes,
Peter

On Feb 11, 2011, at 2:05 AM, Jim Ruther Nill wrote:

 look at http://geokit.rubyforge.org/
 
 On Fri, Feb 11, 2011 at 2:45 PM, Tushar Gandhi li...@ruby-forum.com wrote:
 Hi,
 I have to do the map integration in my upcoming project.
 Also, in the map I have to show the places which are nearer to that
 place within the 10 miles.
 
 Is anyone have any idea how to do this?
 
 
 Thanks,
 Tushar
 
 --
 Posted via http://www.ruby-forum.com/.
 
 --
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at 
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 
 
 
 
 -- 
 -
 visit my blog at http://jimlabs.heroku.com
 
 -- 
 You received this message because you are subscribed to the Google Groups 
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to 
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit 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-talk@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] Problems installing exception_notification plugin

2011-02-11 Thread Jim Burgess
Hi,

I am, trying to install the exception_notification plugin for rails.
I am using rails 2.3, and Windows 7 (64 bit)

The Rails 3 version is here:
https://github.com/rails/exception_notification/
I can install it using git-bash thus:
ruby script/install plugin
git://github.com/rails/exception_notification/
This works fine.

However, I am trying to install the version of the plugin which is
compatible with Rails 2.3
It is here:
https://github.com/rails/exception_notification/tree/2-3-stable/
However, when I try the following in git-bash:
ruby script/install plugin
git://github.com/rails/exception_notification/tree/2-3-stable/
I get the error:
fatal: remote error: rails/exception_notification/tree/2-3-stable/ is
not a valid repository name.

Any ideas how I can install the 2.3 branch of this plugin?
Thanks in advance.

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@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] Form check boxes and Forms

2011-02-11 Thread Ollie
Bit of a newbie question but I've got a form and I want bits of the
form to appear when a checkbox is clicked.

So for example I have a query such as do you want to have a link
attached to this post which is a tick box, then I have another field
which contains the text box for the link to go in.

So I want the link text box to appear when the checkbox is clicked.
Can anyone help?

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] accept_nested_attributes, reject_if doesn't work.

2011-02-11 Thread Mauro
class Post  ActiveRecord::Base
  validates :name,  :presence = true
  validates :title, :presence = true,
:length = { :minimum = 5 }
  has_many :comments, :dependent = :destroy
  has_many :tags

  accepts_nested_attributes_for :tags, :allow_destroy = :true,
:reject_if = proc { |attrs| attrs.all? { |k, v| v.blank? or v.nil? } }
end

rails c

irb(main):001:0 post=Post.first
= #Post id: 1, name: prova, title: titolo prova, content: prova
1, created_at: 2011-02-01 10:03:10, updated_at: 2011-02-01
10:03:10

irb(main):002:0 post.tags.create()
= #Tag id: 5, name: nil, post_id: 1, created_at: 2011-02-11
13:19:22, updated_at: 2011-02-11 13:19:22
irb(main):003:0

irb(main):003:0 post.valid?
= true

Tags has blank or nil attributes but it is saved.
Why I have put :reject_if = proc { |attrs| attrs.all? { |k, v|
v.blank? or v.nil? } } for tags?

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Get request by session id?

2011-02-11 Thread Frederick Cheung


On Feb 11, 11:12 am, Hans Hartmann li...@ruby-forum.com wrote:
  I'm not sure what you're after - requests aren't persisted anywhere
  (unless you're doing something special to do that)

 I want to find a possibility to get the PATH_INFO of each session user.

 My first opinion to do that was to list the env of all sessions.

 The reason I want to do that is to forbid, that two session users can
 access an update form on the same time.

I don't think there's anyway of doing this without you storing details
of all requests (is there even a thing as 'the' PATH_INFO? A user
could have multiple windows)
I think you're approaching this wrong way. I would tackle this by
having a flag saying that a record is being used/edited by someone
else.

Fred

 I have to check on which site all session users currently are.

 --
 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-talk@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] accept_nested_attributes, reject_if doesn't work.

2011-02-11 Thread Jim Ruther Nill
Looking at
http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.html
http://api.rubyonrails.org/classes/ActiveRecord/NestedAttributes/ClassMethods.htmlI
think accepts_nested_attributes expects an #{association}_attributes
key/value pair to be passed
as an attribute to the parent object, in this case Post.

doing post.tags.create doesn't pass by accepts_nested_attributes_for but the
normal Tag.create.

On Fri, Feb 11, 2011 at 9:21 PM, Mauro mrsan...@gmail.com wrote:

 class Post  ActiveRecord::Base
  validates :name,  :presence = true
  validates :title, :presence = true,
:length = { :minimum = 5 }
  has_many :comments, :dependent = :destroy
  has_many :tags

  accepts_nested_attributes_for :tags, :allow_destroy = :true,
:reject_if = proc { |attrs| attrs.all? { |k, v| v.blank? or v.nil? } }
 end

 rails c

 irb(main):001:0 post=Post.first
 = #Post id: 1, name: prova, title: titolo prova, content: prova
 1, created_at: 2011-02-01 10:03:10, updated_at: 2011-02-01
 10:03:10

 irb(main):002:0 post.tags.create()
 = #Tag id: 5, name: nil, post_id: 1, created_at: 2011-02-11
 13:19:22, updated_at: 2011-02-11 13:19:22
 irb(main):003:0

 irb(main):003:0 post.valid?
 = true

 Tags has blank or nil attributes but it is saved.
 Why I have put :reject_if = proc { |attrs| attrs.all? { |k, v|
 v.blank? or v.nil? } } for tags?

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] default values and text_field

2011-02-11 Thread Tony Primerano
I have a model and I set defaults for some values by overriding the
read accessor.  For example

def heading
read_attribute(:heading).nil? ? 'Please select from:' :
read_attribute(:heading)
end

The problem I have found is that text_field ignores this.

%= f.text_field :heading %

is empty even when heading is nil

now I can easily add :value and it works

%= f.text_field :heading,  :value = @site.heading %

but it seems like this shouldn't be necessary.   I also override read
accessors for values that I use in select statements on the same form
and it works fine.

def text_color
read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
read_attribute(:text_color)
end

%= f.select :text_color, SiteColors::COLORS%

This picks up the default fine

Is this a bug in text_field or am I just doing something stupid?

Tony


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails Bad Practice Survey

2011-02-11 Thread Robert O'regan
Hi,

As part of a project I've compiled a VERY short survey on common bad
practices encountered when developing Rails applications.
The survey comtains a number of bad practices (smells) detected in a
sample application.
I'm looking for as many Rails developers as possible to scan through the
proposed smells and state whether they aggree/diagree that these are in
fact smells and hence bad practice.
The survey will literally take only 5 to 10 minutes.
If anyone is interested send me a message via the 'Forum Mail' and I'll
reply with the survey. Or post a reply in this thread and i'll arrange a
way of getting the survey to you.

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-talk@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: default values and text_field

2011-02-11 Thread Frederick Cheung


On Feb 11, 1:37 pm, Tony Primerano tony.primer...@gmail.com wrote:
 I have a model and I set defaults for some values by overriding the
 read accessor.  For example

 def heading
     read_attribute(:heading).nil? ? 'Please select from:' :
 read_attribute(:heading)
 end

Have you double checked this works by calling heading directly on the
object in question?

Fred

 The problem I have found is that text_field ignores this.

     %= f.text_field :heading %

 is empty even when heading is nil

 now I can easily add :value and it works

     %= f.text_field :heading,  :value = @site.heading %

 but it seems like this shouldn't be necessary.   I also override read
 accessors for values that I use in select statements on the same form
 and it works fine.

 def text_color
     read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
 read_attribute(:text_color)
 end

 %= f.select :text_color, SiteColors::COLORS%

 This picks up the default fine

 Is this a bug in text_field or am I just doing something stupid?

 Tony

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] SQL Queries in Rails Console a href=sdf/aobject/object

2011-02-11 Thread hillkj

ActiveRecord::Base.logger = Logger.new(STDOUT)


-- 
View this message in context: 
http://old.nabble.com/SQL-Queries-in-Rails-Console-%3Ca-href%3D%22sdf%22%3E%3C-a%3E%3Cobject%3E%3C-object%3E-tp30901356p30901356.html
Sent from the RubyOnRails Users mailing list archive at Nabble.com.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: default values and text_field

2011-02-11 Thread Tony Primerano


On Feb 11, 8:45 am, Frederick Cheung frederick.che...@gmail.com
wrote:
 On Feb 11, 1:37 pm, Tony Primerano tony.primer...@gmail.com wrote:

  I have a model and I set defaults for some values by overriding the
  read accessor.  For example

  def heading
      read_attribute(:heading).nil? ? 'Please select from:' :
  read_attribute(:heading)
  end

 Have you double checked this works by calling heading directly on the
 object in question?


yes.

This works

%= f.text_field :heading,  :value = @site.heading %

and if I set it in the controller it works fine too.

@site.heading = 'testing'


Maybe text_field is using read_attribute instead of calling the
method?



 Fred



  The problem I have found is that text_field ignores this.

      %= f.text_field :heading %

  is empty even when heading is nil

  now I can easily add :value and it works

      %= f.text_field :heading,  :value = @site.heading %

  but it seems like this shouldn't be necessary.   I also override read
  accessors for values that I use in select statements on the same form
  and it works fine.

  def text_color
      read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
  read_attribute(:text_color)
  end

  %= f.select :text_color, SiteColors::COLORS%

  This picks up the default fine

  Is this a bug in text_field or am I just doing something stupid?

  Tony



-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Gem to work with image attachement

2011-02-11 Thread Andre Fonseca
Thanks.  I gonna take a look on Ruby toolbox

-- 
Abraços Sinceros e Agradecidos
Andre Fonseca
http://www.andrefonseca.net

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Rails Bad Practice Survey

2011-02-11 Thread Jim Ruther Nill
Send them this way :D

On Fri, Feb 11, 2011 at 9:44 PM, Robert O'regan li...@ruby-forum.comwrote:

 Hi,

 As part of a project I've compiled a VERY short survey on common bad
 practices encountered when developing Rails applications.
 The survey comtains a number of bad practices (smells) detected in a
 sample application.
 I'm looking for as many Rails developers as possible to scan through the
 proposed smells and state whether they aggree/diagree that these are in
 fact smells and hence bad practice.
 The survey will literally take only 5 to 10 minutes.
 If anyone is interested send me a message via the 'Forum Mail' and I'll
 reply with the survey. Or post a reply in this thread and i'll arrange a
 way of getting the survey to you.

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




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: default values and text_field

2011-02-11 Thread Jim Ruther Nill
are you sure that heading is nil? could you double check if it's not an
empty string?

On Fri, Feb 11, 2011 at 9:50 PM, Tony Primerano tony.primer...@gmail.comwrote:



 On Feb 11, 8:45 am, Frederick Cheung frederick.che...@gmail.com
 wrote:
  On Feb 11, 1:37 pm, Tony Primerano tony.primer...@gmail.com wrote:
 
   I have a model and I set defaults for some values by overriding the
   read accessor.  For example
 
   def heading
   read_attribute(:heading).nil? ? 'Please select from:' :
   read_attribute(:heading)
   end
 
  Have you double checked this works by calling heading directly on the
  object in question?


 yes.

 This works

 %= f.text_field :heading,  :value = @site.heading %

 and if I set it in the controller it works fine too.

 @site.heading = 'testing'


 Maybe text_field is using read_attribute instead of calling the
 method?


 
  Fred
 
 
 
   The problem I have found is that text_field ignores this.
 
   %= f.text_field :heading %
 
   is empty even when heading is nil
 
   now I can easily add :value and it works
 
   %= f.text_field :heading,  :value = @site.heading %
 
   but it seems like this shouldn't be necessary.   I also override read
   accessors for values that I use in select statements on the same form
   and it works fine.
 
   def text_color
   read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
   read_attribute(:text_color)
   end
 
   %= f.select :text_color, SiteColors::COLORS%
 
   This picks up the default fine
 
   Is this a bug in text_field or am I just doing something stupid?
 
   Tony
 
 

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rvm install 1.8.7 prompts There has been an error while running make. Halting the installation.

2011-02-11 Thread John Merlino
Frederick Cheung wrote in post #980922:
 Error running 'make ', please read
 /Users/jmerlino/.rvm/log/ruby-1.8.7-p330/make.log

 So, what was in it?

 Fred

Towards bottom it says this:

readline.c: In function ‘username_completion_proc_call’:
readline.c:730: error: ‘username_completion_function’ undeclared (first 
use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Delete routes to Edit?

2011-02-11 Thread pete
Hi-

I encountered a problem I have never seen before.  For some reason,
requests for Destroy are routing to Edit.

Here's the route:
 DELETE /instructions/:id(.:format)
{:action=destroy, :controller=instructions}

Here's the call to render it:
  %= link_to 'Delete', instruction, :confirm = 'Are you
sure?', :method = :delete %

This is all from the scaffolding created by Rails.  Whenever that link
is clicked, it routes the user to the Edit page.

If I look at the logs, it looks like a GET request is made instead of
a Delete.

Has anyone seen this before?

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: default values and text_field

2011-02-11 Thread Tony Primerano
The string is nil.   I even created a new rails project to test this
out.

(Rails 3 / 1.9.2)

rails generate scaffold test value1:string value2:integer

app/models/test.rb
class Test  ActiveRecord::Base
  def value1
read_attribute(:value1).nil? ? 'hello' : read_attribute(:value1)
  end
  def value2
read_attribute(:value2).nil? ? 3 : read_attribute(:value2)
  end
end

app/views/tests/_form.html.erb
%= form_for(@test) do |f| %
  value 1 is %= @test.value1.inspect % and value 2 is %=
@test.value2.inspect %
div class=field
%= f.label :value1 %br /
%= f.text_field :value1 %
  /div
  div class=field
%= f.label :value2 %br /
%= f.select :value2, (1..10) %
  /div
  div class=actions
%= f.submit %
  /div
% end %

At the top of the form we see
value 1 is hello and value 2 is 3

the select statement has 3 selected but the text field has nothing.

Adding ':value = @test.value1' fixes the issue but shouldn't be
necessary AFAIK
%= f.text_field :value1,  :value = @test.value1 %


On Feb 11, 10:00 am, Jim Ruther Nill jvn...@gmail.com wrote:
 are you sure that heading is nil? could you double check if it's not an
 empty string?

 On Fri, Feb 11, 2011 at 9:50 PM, Tony Primerano 
 tony.primer...@gmail.comwrote:





  On Feb 11, 8:45 am, Frederick Cheung frederick.che...@gmail.com
  wrote:
   On Feb 11, 1:37 pm, Tony Primerano tony.primer...@gmail.com wrote:

I have a model and I set defaults for some values by overriding the
read accessor.  For example

def heading
    read_attribute(:heading).nil? ? 'Please select from:' :
read_attribute(:heading)
end

   Have you double checked this works by calling heading directly on the
   object in question?

  yes.

  This works

  %= f.text_field :heading,  :value = @site.heading %

  and if I set it in the controller it works fine too.

  @site.heading = 'testing'

  Maybe text_field is using read_attribute instead of calling the
  method?

   Fred

The problem I have found is that text_field ignores this.

    %= f.text_field :heading %

is empty even when heading is nil

now I can easily add :value and it works

    %= f.text_field :heading,  :value = @site.heading %

but it seems like this shouldn't be necessary.   I also override read
accessors for values that I use in select statements on the same form
and it works fine.

def text_color
    read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
read_attribute(:text_color)
end

%= f.select :text_color, SiteColors::COLORS%

This picks up the default fine

Is this a bug in text_field or am I just doing something stupid?

Tony

  --
  You received this message because you are subscribed to the Google Groups
  Ruby on Rails: Talk group.
  To post to this group, send email to rubyonrails-talk@googlegroups.com.
  To unsubscribe from this group, send email to
  rubyonrails-talk+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.

 --
 -
 visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Delete routes to Edit?

2011-02-11 Thread Jim Ruther Nill
are you using rails 3? this problem usually occur if you remove the
javascripts to be used to handle the :confirm argument and the csrf meta
tag.

On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com wrote:

 Hi-

 I encountered a problem I have never seen before.  For some reason,
 requests for Destroy are routing to Edit.

 Here's the route:
  DELETE /instructions/:id(.:format)
 {:action=destroy, :controller=instructions}

 Here's the call to render it:
  %= link_to 'Delete', instruction, :confirm = 'Are you
 sure?', :method = :delete %

 This is all from the scaffolding created by Rails.  Whenever that link
 is clicked, it routes the user to the Edit page.

 If I look at the logs, it looks like a GET request is made instead of
 a Delete.

 Has anyone seen this before?

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Delete routes to Edit?

2011-02-11 Thread pete
Yes, and I did remove the CSRF meta tag.

Thanks, I'll look into it!

On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:
 are you using rails 3? this problem usually occur if you remove the
 javascripts to be used to handle the :confirm argument and the csrf meta
 tag.









 On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com wrote:
  Hi-

  I encountered a problem I have never seen before.  For some reason,
  requests for Destroy are routing to Edit.

  Here's the route:
   DELETE /instructions/:id(.:format)
  {:action=destroy, :controller=instructions}

  Here's the call to render it:
   %= link_to 'Delete', instruction, :confirm = 'Are you
  sure?', :method = :delete %

  This is all from the scaffolding created by Rails.  Whenever that link
  is clicked, it routes the user to the Edit page.

  If I look at the logs, it looks like a GET request is made instead of
  a Delete.

  Has anyone seen this before?

  --
  You received this message because you are subscribed to the Google Groups
  Ruby on Rails: Talk group.
  To post to this group, send email to rubyonrails-talk@googlegroups.com.
  To unsubscribe from this group, send email to
  rubyonrails-talk+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.

 --
 -
 visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Delete routes to Edit?

2011-02-11 Thread pete
Hmm, I uncommented the CSRF meta tag, ensured I was including the
default javascripts and restarted, same issue.

I have added my own js files, is it likely a conflict with those?

On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:
 Yes, and I did remove the CSRF meta tag.

 Thanks, I'll look into it!

 On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:







  are you using rails 3? this problem usually occur if you remove the
  javascripts to be used to handle the :confirm argument and the csrf meta
  tag.

  On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com wrote:
   Hi-

   I encountered a problem I have never seen before.  For some reason,
   requests for Destroy are routing to Edit.

   Here's the route:
    DELETE /instructions/:id(.:format)
   {:action=destroy, :controller=instructions}

   Here's the call to render it:
    %= link_to 'Delete', instruction, :confirm = 'Are you
   sure?', :method = :delete %

   This is all from the scaffolding created by Rails.  Whenever that link
   is clicked, it routes the user to the Edit page.

   If I look at the logs, it looks like a GET request is made instead of
   a Delete.

   Has anyone seen this before?

   --
   You received this message because you are subscribed to the Google Groups
   Ruby on Rails: Talk group.
   To post to this group, send email to rubyonrails-talk@googlegroups.com.
   To unsubscribe from this group, send email to
   rubyonrails-talk+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/rubyonrails-talk?hl=en.

  --
  -
  visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Delete routes to Edit?

2011-02-11 Thread Jim Ruther Nill
hmm, just to be sure, try removing the confirm argument and check if it goes
to the destroy action.

On Sat, Feb 12, 2011 at 12:05 AM, pete peterbattag...@gmail.com wrote:

 Hmm, I uncommented the CSRF meta tag, ensured I was including the
 default javascripts and restarted, same issue.

 I have added my own js files, is it likely a conflict with those?

 On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:
  Yes, and I did remove the CSRF meta tag.
 
  Thanks, I'll look into it!
 
  On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:
 
 
 
 
 
 
 
   are you using rails 3? this problem usually occur if you remove the
   javascripts to be used to handle the :confirm argument and the csrf
 meta
   tag.
 
   On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com
 wrote:
Hi-
 
I encountered a problem I have never seen before.  For some reason,
requests for Destroy are routing to Edit.
 
Here's the route:
 DELETE /instructions/:id(.:format)
{:action=destroy, :controller=instructions}
 
Here's the call to render it:
 %= link_to 'Delete', instruction, :confirm = 'Are you
sure?', :method = :delete %
 
This is all from the scaffolding created by Rails.  Whenever that
 link
is clicked, it routes the user to the Edit page.
 
If I look at the logs, it looks like a GET request is made instead of
a Delete.
 
Has anyone seen this before?
 
--
You received this message because you are subscribed to the Google
 Groups
Ruby on Rails: Talk group.
To post to this group, send email to
 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/rubyonrails-talk?hl=en.
 
   --
   -
   visit my blog athttp://jimlabs.heroku.com

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: default values and text_field

2011-02-11 Thread Jim Ruther Nill
Sorry, I can't help you out as I'm not on my dev box.  One thing off the top
of my mind (so you wont have to worry about that) is to use a placeholder
attribute instead of doing that check.  Good luck!

http://davidwalsh.name/html5-placeholder

On Fri, Feb 11, 2011 at 11:57 PM, Tony Primerano
tony.primer...@gmail.comwrote:

 The string is nil.   I even created a new rails project to test this
 out.

 (Rails 3 / 1.9.2)

 rails generate scaffold test value1:string value2:integer

 app/models/test.rb
 class Test  ActiveRecord::Base
  def value1
read_attribute(:value1).nil? ? 'hello' : read_attribute(:value1)
  end
  def value2
read_attribute(:value2).nil? ? 3 : read_attribute(:value2)
  end
 end

 app/views/tests/_form.html.erb
 %= form_for(@test) do |f| %
  value 1 is %= @test.value1.inspect % and value 2 is %=
 @test.value2.inspect %
 div class=field
%= f.label :value1 %br /
%= f.text_field :value1 %
  /div
  div class=field
%= f.label :value2 %br /
%= f.select :value2, (1..10) %
  /div
  div class=actions
%= f.submit %
  /div
 % end %

 At the top of the form we see
 value 1 is hello and value 2 is 3

 the select statement has 3 selected but the text field has nothing.

 Adding ':value = @test.value1' fixes the issue but shouldn't be
 necessary AFAIK
 %= f.text_field :value1,  :value = @test.value1 %


 On Feb 11, 10:00 am, Jim Ruther Nill jvn...@gmail.com wrote:
  are you sure that heading is nil? could you double check if it's not an
  empty string?
 
  On Fri, Feb 11, 2011 at 9:50 PM, Tony Primerano 
 tony.primer...@gmail.comwrote:
 
 
 
 
 
   On Feb 11, 8:45 am, Frederick Cheung frederick.che...@gmail.com
   wrote:
On Feb 11, 1:37 pm, Tony Primerano tony.primer...@gmail.com wrote:
 
 I have a model and I set defaults for some values by overriding the
 read accessor.  For example
 
 def heading
 read_attribute(:heading).nil? ? 'Please select from:' :
 read_attribute(:heading)
 end
 
Have you double checked this works by calling heading directly on the
object in question?
 
   yes.
 
   This works
 
   %= f.text_field :heading,  :value = @site.heading %
 
   and if I set it in the controller it works fine too.
 
   @site.heading = 'testing'
 
   Maybe text_field is using read_attribute instead of calling the
   method?
 
Fred
 
 The problem I have found is that text_field ignores this.
 
 %= f.text_field :heading %
 
 is empty even when heading is nil
 
 now I can easily add :value and it works
 
 %= f.text_field :heading,  :value = @site.heading %
 
 but it seems like this shouldn't be necessary.   I also override
 read
 accessors for values that I use in select statements on the same
 form
 and it works fine.
 
 def text_color
 read_attribute(:text_color).nil? ? SiteColors::TEXT_DEFAULT :
 read_attribute(:text_color)
 end
 
 %= f.select :text_color, SiteColors::COLORS%
 
 This picks up the default fine
 
 Is this a bug in text_field or am I just doing something stupid?
 
 Tony
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Ruby on Rails: Talk group.
   To post to this group, send email to rubyonrails-talk@googlegroups.com
 .
   To unsubscribe from this group, send email to
   rubyonrails-talk+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/rubyonrails-talk?hl=en.
 
  --
  -
  visit my blog athttp://jimlabs.heroku.com

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Delete routes to Edit?

2011-02-11 Thread pete
Nope, I removed the confirm and it still goes to Edit.

On Feb 11, 9:10 am, Jim Ruther Nill jvn...@gmail.com wrote:
 hmm, just to be sure, try removing the confirm argument and check if it goes
 to the destroy action.









 On Sat, Feb 12, 2011 at 12:05 AM, pete peterbattag...@gmail.com wrote:
  Hmm, I uncommented the CSRF meta tag, ensured I was including the
  default javascripts and restarted, same issue.

  I have added my own js files, is it likely a conflict with those?

  On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:
   Yes, and I did remove the CSRF meta tag.

   Thanks, I'll look into it!

   On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:

are you using rails 3? this problem usually occur if you remove the
javascripts to be used to handle the :confirm argument and the csrf
  meta
tag.

On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com
  wrote:
 Hi-

 I encountered a problem I have never seen before.  For some reason,
 requests for Destroy are routing to Edit.

 Here's the route:
  DELETE /instructions/:id(.:format)
 {:action=destroy, :controller=instructions}

 Here's the call to render it:
  %= link_to 'Delete', instruction, :confirm = 'Are you
 sure?', :method = :delete %

 This is all from the scaffolding created by Rails.  Whenever that
  link
 is clicked, it routes the user to the Edit page.

 If I look at the logs, it looks like a GET request is made instead of
 a Delete.

 Has anyone seen this before?

 --
 You received this message because you are subscribed to the Google
  Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to
  rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

--
-
visit my blog athttp://jimlabs.heroku.com

  --
  You received this message because you are subscribed to the Google Groups
  Ruby on Rails: Talk group.
  To post to this group, send email to rubyonrails-talk@googlegroups.com.
  To unsubscribe from this group, send email to
  rubyonrails-talk+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.

 --
 -
 visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Own theme

2011-02-11 Thread Bhasker Harihara
Solved, I missed out a ; that;s it.

Anyway thaks.

On Fri, Feb 11, 2011 at 8:23 AM, Hassan Schroeder 
hassan.schroe...@gmail.com wrote:

 On Thu, Feb 10, 2011 at 6:37 PM, Bhasker Harihara
 harihara.bhas...@gmail.com wrote:

  So inside my custom.css I use background-color: (url:--)
  This works just  by itself but when I add other parts of the custom and
  header it does not work.

 Then this has nothing to with Rails -- you should post your question to
 a general HTML/CSS/web dev mailing list, after validating both markup
 and stylesheet(s).

 Though background-color (url:--) ?? that's just obviously wrong; look
 at the CSS docs for starters.

 Good luck,
 --
 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-talk@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-talk@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: Delete routes to Edit?

2011-02-11 Thread Jim Ruther Nill
btw, see if you can figure something out on this thread.
http://railsforum.com/viewtopic.php?id=41563
http://railsforum.com/viewtopic.php?id=41563good luck!

On Sat, Feb 12, 2011 at 12:21 AM, Jim Ruther Nill jvn...@gmail.com wrote:

 hmm. that's weird. i can't think of any cause atm.

 what js framework are you using?


 On Sat, Feb 12, 2011 at 12:15 AM, pete peterbattag...@gmail.com wrote:

 Nope, I removed the confirm and it still goes to Edit.

 On Feb 11, 9:10 am, Jim Ruther Nill jvn...@gmail.com wrote:
  hmm, just to be sure, try removing the confirm argument and check if it
 goes
  to the destroy action.
 
 
 
 
 
 
 
 
 
  On Sat, Feb 12, 2011 at 12:05 AM, pete peterbattag...@gmail.com
 wrote:
   Hmm, I uncommented the CSRF meta tag, ensured I was including the
   default javascripts and restarted, same issue.
 
   I have added my own js files, is it likely a conflict with those?
 
   On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:
Yes, and I did remove the CSRF meta tag.
 
Thanks, I'll look into it!
 
On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:
 
 are you using rails 3? this problem usually occur if you remove
 the
 javascripts to be used to handle the :confirm argument and the
 csrf
   meta
 tag.
 
 On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com
   wrote:
  Hi-
 
  I encountered a problem I have never seen before.  For some
 reason,
  requests for Destroy are routing to Edit.
 
  Here's the route:
   DELETE /instructions/:id(.:format)
  {:action=destroy, :controller=instructions}
 
  Here's the call to render it:
   %= link_to 'Delete', instruction, :confirm = 'Are you
  sure?', :method = :delete %
 
  This is all from the scaffolding created by Rails.  Whenever
 that
   link
  is clicked, it routes the user to the Edit page.
 
  If I look at the logs, it looks like a GET request is made
 instead of
  a Delete.
 
  Has anyone seen this before?
 
  --
  You received this message because you are subscribed to the
 Google
   Groups
  Ruby on Rails: Talk group.
  To post to this group, send email to
   rubyonrails-talk@googlegroups.com.
  To unsubscribe from this group, send email to
  rubyonrails-talk+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.
 
 --
 -
 visit my blog athttp://jimlabs.heroku.com
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Ruby on Rails: Talk group.
   To post to this group, send email to
 rubyonrails-talk@googlegroups.com.
   To unsubscribe from this group, send email to
   rubyonrails-talk+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/rubyonrails-talk?hl=en.
 
  --
  -
  visit my blog athttp://jimlabs.heroku.com

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.




 --
 -
 visit my blog at http://jimlabs.heroku.com




-- 
-
visit my blog at http://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Counting items in associate with a limit

2011-02-11 Thread Rob Nichols
Rails 3
---

I have a relationship where Category has_and_belongs_to_many Article. I
want to grab a small subsection of articles related to a particular
category. When I try to iterate over these, Rails tries to count the
records and gets the wrong number.

The issue is that there is bug in the way ActiveRecord counts records in
associations.

For example:

  c = Category.first
  c.articles.count

Outputs 8 which is correct.

  c.articles.limit(3).count

Also outputs 8, when it should be 3

The problem is that the SQL ActiveRecord generates, just appends the
limit to end of the SQL string:

SELECT COUNT(*) AS count_id FROM `articles` INNER JOIN
`articles_categories` ON `articles`.id =
`articles_categories`.article_id WHERE
(`articles_categories`.category_id = 9 ) LIMIT 3

All the limit statement does here is limit the number of output lines:
which is always 1.

If ActiveRecord generated this, it would work:

SELECT count(*) FROM (
  SELECT *
  FROM `articles`
  INNER JOIN `articles_categories` ON `articles`.id =
`articles_categories`.article_id
  WHERE (`articles_categories`.category_id = 9 )
  LIMIT 6, 4) inner_table

To correct this I think I'd need to override
ActiveRecord::Calculations#count. Is there a better way?

If this was just a has_many relationship I could use:

  Article.where([category_id = ?, c.id]).limit(3).count

but that won't work with a has_and_belongs_to_many because articles
doesn't have a category_id field

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Decimal Columns Allow Defaults?

2011-02-11 Thread Philip Hallstrom

On Feb 10, 2011, at 1:54 PM, Karl Smith wrote:

 Is :default allowed as an option for decimal columns?
 
 A migration:
 class CreateMoney  ActiveRecord::Migration
  def self.up
create_table :money do |t|
  t.decimal :amount, :defaut = 0.0, :precision = 8, :scale = 2
end
  end
 
  def self.down
drop_table :money
  end
 end
 
 Creates the following schema:
 
 create_table money, :force = true do |t|
  t.decimal  amount,  :precision = 8, :scale = 2
 end
 
 What happened to the default, it's gone!
 
 Bug? or do decimal columns disallow the :default option? or is it
 because :precision/:scale are also set?


defaut != default

You've got a typo.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Delete routes to Edit?

2011-02-11 Thread pete
It's a JS problem.

I am using a number of mapping libraries but I think the heart of the
problem is JQuery, looks like it conflicts with Prototype??

Thanks for your feedback!

On Feb 11, 9:26 am, Jim Ruther Nill jvn...@gmail.com wrote:
 btw, see if you can figure something out on this 
 thread.http://railsforum.com/viewtopic.php?id=41563
 http://railsforum.com/viewtopic.php?id=41563good luck!

 On Sat, Feb 12, 2011 at 12:21 AM, Jim Ruther Nill jvn...@gmail.com wrote:









  hmm. that's weird. i can't think of any cause atm.

  what js framework are you using?

  On Sat, Feb 12, 2011 at 12:15 AM, pete peterbattag...@gmail.com wrote:

  Nope, I removed the confirm and it still goes to Edit.

  On Feb 11, 9:10 am, Jim Ruther Nill jvn...@gmail.com wrote:
   hmm, just to be sure, try removing the confirm argument and check if it
  goes
   to the destroy action.

   On Sat, Feb 12, 2011 at 12:05 AM, pete peterbattag...@gmail.com
  wrote:
Hmm, I uncommented the CSRF meta tag, ensured I was including the
default javascripts and restarted, same issue.

I have added my own js files, is it likely a conflict with those?

On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:
 Yes, and I did remove the CSRF meta tag.

 Thanks, I'll look into it!

 On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:

  are you using rails 3? this problem usually occur if you remove
  the
  javascripts to be used to handle the :confirm argument and the
  csrf
meta
  tag.

  On Fri, Feb 11, 2011 at 11:46 PM, pete peterbattag...@gmail.com
wrote:
   Hi-

   I encountered a problem I have never seen before.  For some
  reason,
   requests for Destroy are routing to Edit.

   Here's the route:
    DELETE /instructions/:id(.:format)
   {:action=destroy, :controller=instructions}

   Here's the call to render it:
    %= link_to 'Delete', instruction, :confirm = 'Are you
   sure?', :method = :delete %

   This is all from the scaffolding created by Rails.  Whenever
  that
link
   is clicked, it routes the user to the Edit page.

   If I look at the logs, it looks like a GET request is made
  instead of
   a Delete.

   Has anyone seen this before?

   --
   You received this message because you are subscribed to the
  Google
Groups
   Ruby on Rails: Talk group.
   To post to this group, send email to
rubyonrails-talk@googlegroups.com.
   To unsubscribe from this group, send email to
   rubyonrails-talk+unsubscr...@googlegroups.com.
   For more options, visit this group at
  http://groups.google.com/group/rubyonrails-talk?hl=en.

  --
  -
  visit my blog athttp://jimlabs.heroku.com

--
You received this message because you are subscribed to the Google
  Groups
Ruby on Rails: Talk group.
To post to this group, send email to
  rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at
   http://groups.google.com/group/rubyonrails-talk?hl=en.

   --
   -
   visit my blog athttp://jimlabs.heroku.com

  --
  You received this message because you are subscribed to the Google Groups
  Ruby on Rails: Talk group.
  To post to this group, send email to rubyonrails-talk@googlegroups.com.
  To unsubscribe from this group, send email to
  rubyonrails-talk+unsubscr...@googlegroups.com.
  For more options, visit this group at
 http://groups.google.com/group/rubyonrails-talk?hl=en.

  --
  -
  visit my blog athttp://jimlabs.heroku.com

 --
 -
 visit my blog athttp://jimlabs.heroku.com

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: Delete routes to Edit?

2011-02-11 Thread Rob Biedenharn


On Feb 11, 2011, at 11:56 AM, pete wrote:


It's a JS problem.

I am using a number of mapping libraries but I think the heart of the
problem is JQuery, looks like it conflicts with Prototype??

Thanks for your feedback!


Have you replaced the rails.js with the one for jQuery?

https://github.com/rails/jquery-ujs

-Rob



On Feb 11, 9:26 am, Jim Ruther Nill jvn...@gmail.com wrote:

btw, see if you can figure something out on this 
thread.http://railsforum.com/viewtopic.php?id=41563
http://railsforum.com/viewtopic.php?id=41563good luck!

On Sat, Feb 12, 2011 at 12:21 AM, Jim Ruther Nill  
jvn...@gmail.com wrote:



hmm. that's weird. i can't think of any cause atm.



what js framework are you using?


On Sat, Feb 12, 2011 at 12:15 AM, pete peterbattag...@gmail.com  
wrote:



Nope, I removed the confirm and it still goes to Edit.



On Feb 11, 9:10 am, Jim Ruther Nill jvn...@gmail.com wrote:
hmm, just to be sure, try removing the confirm argument and  
check if it

goes

to the destroy action.



On Sat, Feb 12, 2011 at 12:05 AM, pete peterbattag...@gmail.com

wrote:

Hmm, I uncommented the CSRF meta tag, ensured I was including the
default javascripts and restarted, same issue.



I have added my own js files, is it likely a conflict with those?



On Feb 11, 9:01 am, pete peterbattag...@gmail.com wrote:

Yes, and I did remove the CSRF meta tag.



Thanks, I'll look into it!



On Feb 11, 8:58 am, Jim Ruther Nill jvn...@gmail.com wrote:



are you using rails 3? this problem usually occur if you remove

the

javascripts to be used to handle the :confirm argument and the

csrf

meta

tag.


On Fri, Feb 11, 2011 at 11:46 PM, pete  
peterbattag...@gmail.com

wrote:

Hi-



I encountered a problem I have never seen before.  For some

reason,

requests for Destroy are routing to Edit.



Here's the route:
 DELETE /instructions/:id(.:format)
{:action=destroy, :controller=instructions}



Here's the call to render it:
 %= link_to 'Delete', instruction, :confirm = 'Are you
sure?', :method = :delete %



This is all from the scaffolding created by Rails.  Whenever

that

link

is clicked, it routes the user to the Edit page.



If I look at the logs, it looks like a GET request is made

instead of

a Delete.



Has anyone seen this before?


Rob Biedenharn  
r...@agileconsultingllc.com http://AgileConsultingLLC.com/
r...@gaslightsoftware.com   http://GaslightSoftware.com/

--
You received this message because you are subscribed to the Google Groups Ruby on 
Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Rails 3 working with and SSL

2011-02-11 Thread Mark C.
I have a Rails 3 app using Ruby 1.9.2 configured to work on the Linux
server. The uses SSL to access all there resources. Now, I am dealing
with the SSL so that I can display the application on the client side.
The user LDAP credentials are being passed to the Linux server through
instructions in the httpd.conf file. I can see the
handshake in the SSL_error logs. I also know the cert information is
being
passed because I can see the information in the SSL_client logs and also
in the Rails WEBrick server console as my application boots
(http://www.nearinfinity.com/blogs/chris_rohr/configuring_webrick_to_use_ssl.html).
However
when I go to the Https port on my desktop I get the browser error 503
Service Temporarily Unavailable. I know the cert was passed to the
browser because I get the lock icon.

Can someone help me understand the 503 error?

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Rails 3 working with webrick and SSL

2011-02-11 Thread Fernando Perez
If I recall correctly, webrick doesn't support SSL. Mongrel neither.

You'll have to use Apache or Nginx for that.

Yes, SSL dev for Rails is a bit painful.

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: understanding rails project

2011-02-11 Thread Megas Megas
Michael Pavling wrote in post #980954:
 (Partial, I assume).
 Yes, a little searching... but the context-sensitive control-clicking
 in my IDE lets me follow through very quickly, and I generally try to
 name stuff to be simple to find again (the self-documenting approach)
Yes, you're right, partial
In my IDE (RubyMine) some partial can't be reached by clicking, i 
assumed that if the good IDE can't do this job so another IDE's do worse 
job. I think that self-documented approach helps read the code locally, 
but to build the mind-image of the project is reading whole code many 
times. That's why the diagram tools were built, to help to create image 
of the project in mind. But all visual tools which I used are based on 
structure approach, no actions view. I think the action is very similar 
to goal, when I do the action it means I want to do something 
specifically: add new comment, create new account and etc. If I can see 
which controller, model, view are using now and where it comes from, 
while the current action is operating, then it helps me to understand 
the project.

 I don't know what you mean for sure. What place? Do you mean
 controller action? If so, I look at the URL... and I can open any
 file by name with a couple of key-presses.
The place where is user click the action. In my example the comment 
views composed in another view, so this is not easy to find out what's 
going on.


 That's great to hear. I hope it works well for you. I'm all for people
 working in whatever way is best for them.
 For me; it's not so much help to have the controller/view drawing.
 But if the time it takes to build is off-sets in time you save from
 your previous searching, then it's a win.

 But I would say that if others can find it quicker and easier while
 not using the drawing, then maybe the problem you're fixing with the
 diagram isn't the biggest win you could achieve?
Actually I tried to describe one thing which have two sides and you 
separated it in two things. And you might be right, if Im not so good at 
Rails technology, it doesn't mean that others have the same problems. I 
think these difficulties appear only when we're reading the new someone 
else's project, not the our own project.

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Real-time web traffic alert notifications (email or SMS) on the cheap?

2011-02-11 Thread Brian Morearty
I'm a big fan of New Relic. One of the services they provide is alerts
when your traffic goes up unexpectedly above a predetermined level.

Does anyone have a favorite, inexpensive traffic alert tool that can
be used on a small site--a site that's not yet big enough for monthly
payments of $150 for New Relic Silver (or even the $36 price tag for New
Relic Silver on Heroku). Maybe a nice little does-just-one-thing-well
tool that's $2-3/month or something.

The closest I've found are Clicky and Chartbeat, both of which seem to
have real-time alerts for just under $10 a month. That's not bad, but
it's more than $2 or $3.

A server-side tool in Ruby would be preferable to a client-side tool in
JavaScript. Because a server-side tool would also track API traffic.

I know Google Analytics sends email alerts but they're daily. I'm
thinking more of a you've been slashdotted kind of thing where you can
know in a few minutes.

Thanks! And if no one knows about one maybe I'll write one myself.

Brian

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Complex Active_record associations

2011-02-11 Thread tspore
So I have 3 models -
Users, Roles, Records.
For each record X user, can have 1 of 3 roles, and those roles will
give different permissions on each record.
So for example, user 1 - has a role of follower on record 5, also user
1 - is a manager(role) of record 4, etc.
So what I am trying to do, is figure out how to create that
situation.
Would something like this work?
User
has_and_belongs_to roles
has_many records through = role_record

user_status -- table
  user_id
  status_id

roles
has_and_Belongs_to Users
has_and_belongs_to records

  role_record -- table
role_id
record_id
(user_id)

records
has_and_belongs_to roles

The final goal is I want to call - user(1).role(1) - and have it spit
out all the associated records that I have.

I have n amount of users and records, but currently only 3 roles.
Thanks for the help!

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: rvm install 1.8.7 prompts There has been an error while running make. Halting the installation.

2011-02-11 Thread Frederick Cheung


On Feb 11, 3:36 pm, John Merlino li...@ruby-forum.com wrote:
 Frederick Cheung wrote in post #980922:

  Error running 'make ', please read
  /Users/jmerlino/.rvm/log/ruby-1.8.7-p330/make.log

  So, what was in it?

  Fred

 Towards bottom it says this:

 readline.c: In function ‘username_completion_proc_call’:
 readline.c:730: error: ‘username_completion_function’ undeclared (first
 use in this function)
 readline.c:730: error: (Each undeclared identifier is reported only once
 readline.c:730: error: for each function it appears in.)
 make[1]: *** [readline.o] Error 1
 make: *** [all] Error 1

Well it's clearly a readline based problem - did you try passing --
with-readline-dir=$rvm_path/usr  as you did when building 1.9.2 ?

Fred

 --
 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-talk@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] Regex for string first chars - Model validation

2011-02-11 Thread Rodrigo Alves Vieira


Hello everyone, in my Rails app I need to validate a string that on creation 
can not have its first chars empty or composed by any special chars.

For example:  file and %file aren't valid. Do you know what Regex I 
should use?

Thanks!

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Regex for string first chars - Model validation

2011-02-11 Thread kedar mhaswade
On Fri, Feb 11, 2011 at 11:30 AM, Rodrigo Alves Vieira
rodrig...@gmail.comwrote:

 Hello everyone, in my Rails app I need to validate a string that on
 creation can not have its first chars empty or composed by any special
 chars.

 For example:  file and %file aren't valid. Do you know what Regex I
 should use?

You could utilize the anchor for this -- that is you say that the line
must begin with the characters that match the following regex.
Something like: /\A[\w]+$/ would work.


 Thanks!

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Talk group.
 To post to this group, send email to rubyonrails-talk@googlegroups.com.
 To unsubscribe from this group, send email to
 rubyonrails-talk+unsubscr...@googlegroups.com.
 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-talk@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] Regex for string first chars - Model validation

2011-02-11 Thread Philip Hallstrom
 On Fri, Feb 11, 2011 at 11:30 AM, Rodrigo Alves Vieira rodrig...@gmail.com 
 wrote:
 Hello everyone, in my Rails app I need to validate a string that on creation 
 can not have its first chars empty or composed by any special chars.
 
 For example:  file and %file aren't valid. Do you know what Regex I 
 should use?
 
 You could utilize the anchor for this -- that is you say that the line must 
 begin with the characters that match the following regex.
 Something like: /\A[\w]+$/ would work.

Note that \w will match an underscore.  Don't know if you consider that 
special or not...

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Regex for string first chars - Model validation

2011-02-11 Thread Rodrigo Alves Vieira
Hello, thanks for the reply, but after applying this regex I go to rails 
console and run 

a = File.new
a.file_name =  example.txt

It still works, when it shouldn't... any more help?

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Regex for string first chars - Model validation

2011-02-11 Thread Rodrigo Alves Vieira
Undescore is allowed.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Regex for string first chars - Model validation

2011-02-11 Thread Rodrigo Alves Vieira
Underscore is allowed.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: can you portably store infinity via AR?

2011-02-11 Thread Fearless Fool
Where it stands:

Infinity can be represented in IEEE floating point numbers.

Infinity can be represented in Ruby, as evidenced by
 (1.0/0.0).infinite?
= 1

Infinity can be represented in sqlite (and probably other databases):
  sqlite select * from test_recs;
  1|Inf|

Yet it appears that there's no portable way to store a Ruby infinity in
a database using AR.  Does anyone disagree?

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

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] rails 3 initialize module, running cucumber

2011-02-11 Thread Me
I have this in my environment file, I get The error occurred while 
evaluating nil.[] (NoMethodError) on the  S3Config.key= line  when running 
cucumber.  Why is it not loading up the module when running cucumber?

module S3Config
  mattr_accessor :key
  mattr_accessor :sec
end

class ActiveRecord::Base
  include S3Config
  extend DynamicMethods
end

S3Config.key = AppConfig['access_key_id']
S3Config.sec = AppConfig['secret_access_key']
ActionMailer::Base.default_url_options[:host]=AppConfig['base_url']

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] An hash of arrays, how to use?

2011-02-11 Thread Norbert Melzer
Hello everybody!

I have a problem with an Hash of Arrays.

ruby-1.9.2-p136 :001  x = Hash.new Array.new
 = {}
ruby-1.9.2-p136 :002  x[test]  test
 = [test]
ruby-1.9.2-p136 :003  x
 = {}
ruby-1.9.2-p136 :004  x.keys
 = []
ruby-1.9.2-p136 :005  x[test]
 = [test]
ruby-1.9.2-p136 :006 

Why is keys empty?

What I am trying to do is build a hash of arrays from an XML file:

  b = Hash.new(Array.new)
  h = XmlSimple.xml_in self.raw

  h[data][0][bank][0][item].each do |item|
b[item[cat]]  item[name]
  end

This is the code, but b has like the test in irb no keys, or seems to
be empty, unless you dont know the key i advance, but that is
impossible, since the item[cat] is dynamic and it is known of 10
categories at the moment, but it is also known that the number of
categories will go up in the future, so I want to do it future-proof
already today :D

Thank you in Advance
Norbert

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] Re: Real-time web traffic alert notifications (email or SMS) on the cheap?

2011-02-11 Thread tspore
for a cheap simple monitor tool for a site that is up or down -
http://monitor.rootinternet.co.uk/en/index.php


On Feb 11, 10:53 am, Brian Morearty li...@ruby-forum.com wrote:
 I'm a big fan of New Relic. One of the services they provide is alerts
 when your traffic goes up unexpectedly above a predetermined level.

 Does anyone have a favorite, inexpensive traffic alert tool that can
 be used on a small site--a site that's not yet big enough for monthly
 payments of $150 for New Relic Silver (or even the $36 price tag for New
 Relic Silver on Heroku). Maybe a nice little does-just-one-thing-well
 tool that's $2-3/month or something.

 The closest I've found are Clicky and Chartbeat, both of which seem to
 have real-time alerts for just under $10 a month. That's not bad, but
 it's more than $2 or $3.

 A server-side tool in Ruby would be preferable to a client-side tool in
 JavaScript. Because a server-side tool would also track API traffic.

 I know Google Analytics sends email alerts but they're daily. I'm
 thinking more of a you've been slashdotted kind of thing where you can
 know in a few minutes.

 Thanks! And if no one knows about one maybe I'll write one myself.

 Brian

 --
 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-talk@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: An hash of arrays, how to use?

2011-02-11 Thread Frederick Cheung


On Feb 11, 9:09 pm, Norbert Melzer timmel...@googlemail.com wrote:
 Hello everybody!

 I have a problem with an Hash of Arrays.

 ruby-1.9.2-p136 :001  x = Hash.new Array.new
  = {}
 ruby-1.9.2-p136 :002  x[test]  test
  = [test]
 ruby-1.9.2-p136 :003  x
  = {}
 ruby-1.9.2-p136 :004  x.keys
  = []
 ruby-1.9.2-p136 :005  x[test]
  = [test]
 ruby-1.9.2-p136 :006 

 Why is keys empty?

because you've never actually done x[test]= ...
(all you're doing is modifying the hash's default value)

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-talk@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: Regex for string first chars - Model validation

2011-02-11 Thread Kai Middleton
Philip's idea seems pretty good:
^\w+
That says: look for any string that starts with one or more word
characters (letters, numbers, underscores).
Try it out in rubular:
http://rubular.com/
It let's you quickly experiment with lots of regular expressions and
has a quick-ref right there on the page.

On Feb 11, 11:58 am, Rodrigo Alves Vieira rodrig...@gmail.com wrote:
 Underscore is allowed.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] is equal operator to check current user is owner

2011-02-11 Thread msaspence
I'm want to restrict access to an object show action to the owner

in my action I have this

def show
@thing = Thing.find(params[:id])
if current_user  @thing.owner == current_user
  respond_to do |format|
format.json  { render :json = @thing }
  end
else
  render :status = :forbidden, :text = API requires
authentication for the minute.
end
end

Which works in the browser, however when running functional tests even
though @thing.owner is the same user as current_user it is not the
same object so the comparison fails as I see it I have a few options
but wanted to try and gauge what people feel is the best way

1) adjust the test setup so the logged in user is the same object and
the comparison returns true (I have no idea how I would go about doing
this)

2) just do current_user.id == @thing.owner.id, this seems like the
most obvious and easiest but somehow less elegant

3) write my own comparison method on my user class, either:

def is_equal_to user(user)
  return user.id == self.id
end

or:

def is_current_user
  return current_user.id == self.id
end

4) something else I haven't thought about

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: An hash of arrays, how to use?

2011-02-11 Thread Norbert Melzer
2011/2/11 Frederick Cheung frederick.che...@gmail.com:


 On Feb 11, 9:09 pm, Norbert Melzer timmel...@googlemail.com wrote:

 Why is keys empty?

 because you've never actually done x[test]= ...
 (all you're doing is modifying the hash's default value)

OK, now I tried the following

  b = Hash.new(Array.new)
  h = XmlSimple.xml_in self.raw

  h[data][0][bank][0][item].each do |item|
if b.key? item[cat]
  b[item[cat]] = item
else
  b[item[cat]]  item
end
  end

  pp b.keys

but b.keys is still empty...

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] Re: An hash of arrays, how to use?

2011-02-11 Thread botp
On Sat, Feb 12, 2011 at 9:25 AM, Norbert Melzer
timmel...@googlemail.com wrote:
 OK, now I tried the following
      b = Hash.new(Array.new)
      h = XmlSimple.xml_in self.raw
      h[data][0][bank][0][item].each do |item|
 delete line        if b.key? item[cat]
 add line        if !b.key? item[cat]
          b[item[cat]] = item
        else
          b[item[cat]]  item
        end
      end

      pp b.keys

 call me stupid... But with above marked change it works as I want it
 to behave :D


try this,

b = Hash.new {|h,k| h[k]=[]}
h = XmlSimple.xml_in self.raw

h[data][0][bank][0][item].each do |item|
  b[item[cat]]  item
end

best regards -botp

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



[Rails] DRY in rspec tests

2011-02-11 Thread S. Widmann
Hi,

I've got a lot of rspec controller tests. At the beginning of each 
controller, I have:

def authenticate
 ...
end

def logout
 ...
end

Authenticates creates me a @current_user, logout destroys the @current_user. 
As I said, this code is at the beginning of each controller, not very DRY 
:-)

Any hints for me, where to put this code and how to integrate it in my 
tests, to not always rewrite this two methods?

Regards
sewid

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.



Re: [Rails] DRY in rspec tests

2011-02-11 Thread Philip Hallstrom
 I've got a lot of rspec controller tests. At the beginning of each 
 controller, I have:
 
 def authenticate
  ...
 end
 
 def logout
  ...
 end
 
 Authenticates creates me a @current_user, logout destroys the @current_user. 
 As I said, this code is at the beginning of each controller, not very DRY :-)
 
 Any hints for me, where to put this code and how to integrate it in my tests, 
 to not always rewrite this two methods?

You could create a file in spec/support/current_user.rb  (or whatever, doesn't 
matter as long as it's in spec/support/*.rb) and put them in there.  Then 
they'll be available to all your specs...

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Talk group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.