[Rails] Re: create a table per user

2009-03-26 Thread ruby...@ymail.com



On 27 Mar., 07:01, Silviu Miki 
wrote:
> not sure what to look at...
> how would i go about creating tables within the application? i have my
> users  and say, for each one i want to create another table(s) when they
> register, that would be customized to them and accessible only by them?

That kind of thing should never ever be done. Imagine when you reach,
maybe, a thousand users, you'll have at least thousand tables! Then
imagine when you need to make a change in the users' tables! I
strongly recommend to make use of Rails' has_many and belongs_to
associations to keep track of which records belongs to which users,
instead.

--
Best regards,
David Knorr
http://twitter.com/rubyguy
--~--~-~--~~~---~--~~
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: adding automatic conditions to find method

2009-03-26 Thread ruby...@ymail.com



On 27 Mar., 07:20, Tam Kbe  wrote:
> Hello,
>
> Is there a way to add automatic condition to all active record find
> methods?
>
> I have an attribute in all my tables something like "effective_end_date"
> so that I don't delete records but I keep them by setting
> effective_end_date so I want to put condition is all my find queries
> effective_end_date Is null or effective_end_date > Time.now. I don't
> want to type this for every single query so I was wondering if it's
> possible to automate it.

Yes, you can use default_scope: 
http://api.rubyonrails.org/classes/ActiveRecord/Base.html#M002258
It supports the same options as the find methods.

--
Best regards,
David Knorr
http://twitter.com/rubyguy
--~--~-~--~~~---~--~~
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] New TurnKey appliance for Ruby on Rails 2.3.2

2009-03-26 Thread Liraz

TurnKey Linux has released a new Ruby on Rails Appliance. The new
appliance features an upgrade to Rails 2.3.2, upgraded Gems
components, an important bug fix and significant security enhancements
(regeneration of database password on installation):

http://www.turnkeylinux.org/appliances/rails/updates

About TurnKey Ruby on Rails

TurnKey Rails Appliance is an extremely easy way to get up and running
with Rails in just a couple of minutes.

It's a free, pre-integrated turnkey server which is packaged as a
single universal image capable of supporting installations on both
physical and virtual machines, including VMware, Xen, VirtualBox, and
KVM.

http://www.turnkeylinux.org/appliances/rails

About TurnKey Linux

The largest Linux distributions have over 23,000 packages which are
free for both commercial and non-commercial uses, including updates.
However, currently it can still take considerable skill and effort to
cherry-pick the right components and glue them together into a
compelling solution.

To help unlock this potential we started TurnKey Linux, a community-
oriented open source project developing a family of free, Ubuntu-based
software appliances optimized for ease of use in server-type usage
scenarios.

To maximize leverage and provide a consistent user experience, TurnKey
Linux appliances are all built on top of TurnKey Core, a 100MB base
appliance, from which they inherit the standard features which are
common to all TurnKey appliances.

http://www.turnkeylinux.org/
--~--~-~--~~~---~--~~
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: Invalid Authenticity Token?

2009-03-26 Thread Jan
Hi,

I doubt this is related to a known bug of latest releases, check it here:
https://rails.lighthouseapp.com/projects/8994/tickets/2200-session-support-broken

I got the same invalid token error as you described, and everything
works well again after I downgrade to 2.3.0

- Jan

* Richie  [2009-03-26 23:11:42 -0700]:

> 
> oops, the last paragraph should read:
> 
> "I'm completely stumped because when I revert back so the session
> store is using the default cookiestore things work great and the items
> I expect to appear in my cart do, until the session data is greater
> than 4kb then it breaks again but that's understandable as we
> shouldn't be storing objects in the cookie session data. so this leads
> to the question is this then a problem with this release of rails?"
> --~--~-~--~~~---~--~~
> 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
> -~--~~~~--~~--~--~---

-- 
jan=callcc{|jan|jan};jan.call(jan)


pgpWoaSmQTXob.pgp
Description: PGP signature


[Rails] adding automatic conditions to find method

2009-03-26 Thread Tam Kbe

Hello,

Is there a way to add automatic condition to all active record find
methods?

I have an attribute in all my tables something like "effective_end_date"
so that I don't delete records but I keep them by setting
effective_end_date so I want to put condition is all my find queries
effective_end_date Is null or effective_end_date > Time.now. I don't
want to type this for every single query so I was wondering if it's
possible to automate it.

Thanks,

Tam
-- 
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] ActionMailer not send email and not generate error in log

2009-03-26 Thread Nurzed Lkham

hello guys.. i was trying configuring SMTP with GMail n my rails
appliaction. when running everything seems alright but the mails not
getting delivered. also the logs show the action as successful .

in environment.rb:

ActionMailer::Base.delivery_method =:smtp
ActionMailer::Base.smtp_settings = {
  :address => "smtp.gmail.com",
  :port => "587",
  :domain => "mydomain.com",
  :authentication => :plain,
  :user_name => "my_gmail_account",
  :password => "my_password"
}


Emailer controller :

class EmailerController < ApplicationController
  def sendmail

  recipient = params[:email][:recipient]
  subject = params[:email][:subject]
  message = params[:email][:message]
  Emailer.deliver_contact(recipient, subject, message)

  return if request.xhr?
  render :text => 'Message sent successfully'
  end

  def index
  render :file => 'app/views/emailer/index.html.erb'
  end

end


View :
Send Email
<% form_tag :action => 'sendmail' do %>
Subject:
<%= text_field 'email', 'subject' %>
Recipient:
<%= text_field 'email', 'recipient' %>
Message
<%= text_area 'email', 'message' %>
<%= submit_tag "Send" %>
<% end %>


please help me out and point out the details.
-- 
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: Invalid Authenticity Token?

2009-03-26 Thread Richie

oops, the last paragraph should read:

"I'm completely stumped because when I revert back so the session
store is using the default cookiestore things work great and the items
I expect to appear in my cart do, until the session data is greater
than 4kb then it breaks again but that's understandable as we
shouldn't be storing objects in the cookie session data. so this leads
to the question is this then a problem with this release of rails?"
--~--~-~--~~~---~--~~
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] Invalid Authenticity Token?

2009-03-26 Thread Richie

Hi guys,

Before I explain anything here's my setup:

Mac OS X
Ruby 1.8.7 from source, RubyGems, Rails 2.3.2, MySQL from source, the
ruby mysql adapter gem and mongrel.
Firefox 3.07

I'm new to rails and happily understanding everything as I follow
through the pragmatic programmers depot application tutorial from
their 'agile development with rails v3 p1.0' but one thing has me
completely stumped. I am onto the section where we're storing the cart
items in the session store, specifically this store is the db. Now
when I run rake db:sessions:create & migrate then change the
session_store initializer in the environments folder to use the active
record store things just break! So here's an excerpt from the code:

  def add_to_cart
product = Product.find(params[:id])
@cart = find_cart
@cart.add_product(product)
  end

  private

  def find_cart
session[:cart] ||= Cart.new
  end

Easy enough it seems however when the action 'add_to_cart' is called I
get a nasty page showing an invalid authenticity token. Here's the
request params: {"authenticity_token"=>"x4KicmZNjfb9c+X6prUPu6XLe8QfjB/
uRN+PR0+TNWc=",
 "id"=>"6"}

So that seems straight forward enough - there is an authenticity token
but it's invalid for some reason. I then tried setting the development
environment variable config.action_controller.allow_forgery_protection
to false which made functionality appear to work, however... when
monitoring the db it seems that every time I click add to cart a new
session is created!! I'm completely stumped because when I revert so
the session store is using the default cookiestore things work great
and the items I expect to appear in my cart until the session data is
greater than 4kb then it breaks again but that's understandable as we
shouldn't be storing objects in the cookie session data so is this
then a problem with this release of rails?

Any help is much appreciated I just want to get rocking with rails now
and this has held me back all day!

Thanks in advance

Kind Regards
Richard Delph
--~--~-~--~~~---~--~~
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] create a table per user

2009-03-26 Thread Silviu Miki

not sure what to look at...
how would i go about creating tables within the application? i have my
users  and say, for each one i want to create another table(s) when they
register, that would be customized to them and accessible only by them?

miki
-- 
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] How to pull down menu

2009-03-26 Thread haneef5k

hi,

im new to Ror im learning by video tutorial .i wnt to knw how 2 add
drop down menu..r pull down menu... it means ( select: collect.)
 pls help..me  there s any web site...to learn tis..??
--~--~-~--~~~---~--~~
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] Loading classes

2009-03-26 Thread elioncho

Hello guys,

In my app users are able to upload their own classes into their public
folder and execute certain code on them. I have this code to load the
classes on their folder:

Dir.glob(File.join(path,self.login,'lib','*.rb')).each { |f| load(''+f
+'') }

This is actually loading the classes but not in the order it should.
Sometimes some classes extends from other and therefore should be
added later.

So, I did a test and hardcoded the loads in order:

load 'public/.../lib/foo.rb'
load 'public/.../lib/bar.rb'

and it worked. So my question is: How can I do to load all this
classes without problems. For instance when I put the classes in the
rails lib folder there are no problems loading them. What method does
rails has to load the files on the lib folder? Any help is
appreciated, thanks

Elías

--~--~-~--~~~---~--~~
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: smtp_tls and SMTP/NET required failing

2009-03-26 Thread Bartee Lamar

Any help on this would be appreciated...

I have googled for a hour and cannot find anything..

I am a noob, but trying hard.
-- 
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 2.3.2 server restart does not appear to clear fragment cache

2009-03-26 Thread Sudhir

After upgrading to Rails 2.3.2 I am now experimenting with Rails
caching. I have cache enabled for one action in a few controllers.
This seems to work until I restart the server.

 After restart, I get Invalid Authenticity token errors on POSTS from
pages that were previously cached. I've tried clearing the browser
cookies and cache and the problem does not appear to be on the browser
side.

I think the default cache store is Memory. I don't see any cached
files on the disk.

I can clear the problem by visiting an uncached page on my application
and POSTing from there. My cache sweeper expires the cache in that
case. After this, everything works since I expire all cached URL's.

Is there a way to definitely clear the Rails cache on server restart?

Also, please confirm that the default cache store is memory. I had
assumed that the memory cache would clear automatically on server
restart. Maybe my assumptions are not correct.

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



[Rails] Method not available within same module as definition

2009-03-26 Thread tyler

# This will probably be embarrassingly obvious. It acts as if it's an
# evaluation order issue (like the method call is happening prior to the
# method definition). But that isn't the case. The model_names method
# works fine on the console. I'm missing a core concept obviously.

# Error message from test
tylers-mbpro:test tyler$ ruby helpers/application_helper_test.rb
/Users/tyler/versioned/tma-code/rails/facilit-e/app/helpers/application_helper.rb:23:
undefined local variable or method `model_names' for
ApplicationHelper:Module (NameError)

# ApplicationHelper
module ApplicationHelper

def self.make_user_select_collects(assoc_id_param)
module_eval %{
def select_collect_by_#{assoc_id_param}(klass, assoc_id,
order_by_col='full_name')
klass.find_all_by_#{assoc_id_param}(assoc_id,
:order => order_by_col.to_sym).collect {|s| [s.full_name, s.id]}
end
}
end

def self.model_names
models = Array.new
Dir["app/models/**/*.rb"].each do |f|
models <<
File.basename(f).sub(/.rb$/,'').titlecase.gsub(/\s/,'').constantize
end
models
end

ids = Array.new
model_names.each do |klass| #model_names
klass.column_names.grep(/_id$/).each do |assoc_id|
unless ids.member?(assoc_id)
ids << assoc_id
make_user_select_collects(assoc_id)
end
end
end

end

# Thanks for any help

-- 
Thanks,

Tyler Arrigoni
President

OneInterface.net Network Engineering, Inc.
7475 North Palm, Suite 105, Fresno, CA 93711
Voice: 559-437-3750 ext. 110
Cell: 559-696-0400
Fax1: 866-691-5145 (confidential)
Fax2: 559-437-3754 (non-confidential)
Email: ty...@oneinterface.net
GnuPG: http://www.oneinterface.net/crypt/tyler.asc

--~--~-~--~~~---~--~~
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] ajax window and Element.show when onclick

2009-03-26 Thread Erwin

in a page I have a list of modules in a div (left), and the
permissions radio boxes for this module displyed on the irght
when clicking on a module name, the related permissions are displayed

when using html, it works well...  a click on a module label (on the
left) show the element  on the right (dib w permissions)
BUT when using an Ajax form, the first display is correct, clicking on
another module name reach directly to html page
to show the permissions.. so I was told that a JS error occursed...

looking into the Firebug console, I can see an error

Error : missing ) after argument list
Source File : http://localhost:3000/intranet-dev/admin
Line : 1, Column : 65
Source Code :
showTab('boards'); this.blur(); Element.show('tab-content-boards'}):
return false;
---|
arrow between  } and )
did I miss any specific parameter w Ajax ?this line execute
correctly when html only

my form view :

<% tabs = role_permissions_tabs %>
<% selected_tab = params[:tab] ? params[:tab].to_s : tabs.first[:name]
%>





<% tabs.each do |tab| -%>
<%= link_to tab[:label], { :tab => tab[:name] },  :id =>
"tab-#{tab[:name]}",  :class => (tab[:name] != selected_tab ? nil :
'selected'),  :onclick => "showTab('#{tab[:name]}'); this.blur();
Element.show('tab-content-#{tab[:name]}'}): return false;" %>
<% end -%>




<% tabs.each do |tab| -%>
<%= content_tag('div', render(:partial => 'roles/
permissions', :locals => {:perms => tab[:perms]}),  :id => "tab-
content-#{tab[:name]}", :style => (tab[:name] != selected_tab ?
'display:none' : nil), :class => 'tab-content') %>
<% end -%>




and the Showtab function in the js file

function showTab(name) {
var f = $$('div#content .tab-content');
for(var i=0; ihttp://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: InstantRails and new gems

2009-03-26 Thread Pierre Pierre

ruby...@ymail.com wrote:
> Are you having multiple versions of Rubygems installed, or something?
> 
> --
> Best regards,
> David Knorr
> http://twitter.com/rubyguy

No, I'm running everything within the InstantRails's ruby console...
Though the gem is installed correctly, I can't use it.
Maybe when its launching that ruby console it's somehow not taking care 
of the gems, but I wouldn't see why...
-- 
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: Request Profiling on Rails 2.3.2

2009-03-26 Thread Perry Smith

Perry Smith wrote:
> scripts/performance/request is gone... and the RequestProfiler class is
> gone from ActionController.
> 
> Is there a simple way to profile a request?

I found the guide... sorry.

http://guides.rubyonrails.org/performance_testing.html

-- 
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: Output to Printer

2009-03-26 Thread Eric

I'm not sure if I understand completely, but I would just render a
'printer_friendly' layout.

And you do know that Rails itself is not GPL, right?

On Mar 26, 5:03 pm, eengnerd  wrote:
> It was very surprising to me to find out that there is no current,
> GPL'ed "ruby-" package designed for outputting HTML / CSS pages to a
> printer.  For reasons of principle, I won't use any add on modules for
> ruby that are not GPL'ed.  Does anyone know of a package currently
> under development that is at least reasonably close to such support?
>
> Arthur
--~--~-~--~~~---~--~~
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] Request Profiling on Rails 2.3.2

2009-03-26 Thread Perry Smith

scripts/performance/request is gone... and the RequestProfiler class is
gone from ActionController.

Is there a simple way to profile a request?

Thanks
pedz
-- 
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] Output to Printer

2009-03-26 Thread eengnerd

It was very surprising to me to find out that there is no current,
GPL'ed "ruby-" package designed for outputting HTML / CSS pages to a
printer.  For reasons of principle, I won't use any add on modules for
ruby that are not GPL'ed.  Does anyone know of a package currently
under development that is at least reasonably close to such support?

Arthur
--~--~-~--~~~---~--~~
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] acts_as_versioned and qa

2009-03-26 Thread Tomasz Bąk

Hi,
I have Article model and it has aasm_column qa, that is initially
"pending".

In order to get it reset qa column on new versions, I have made:

  def set_new_version
write_attribute(:qa, "pending")
  end

But now the aasm methods are also triggering the new version, dispite:

  self.non_versioned_columns << 'updated_at'
  self.non_versioned_columns << 'created_at'
  self.non_versioned_columns << 'qa'
  self.non_versioned_columns << 'published_at'

How to make the approve! method to start working, while data change
should trigger qa reset?

Tom

PS Here is saple code:

class Article < ActiveRecord::Base

  include AASM

  aasm_column :qa
  aasm_initial_state :pending
  aasm_state :pending
  aasm_state :approved
  aasm_state :rejected

  aasm_event :approve do
transitions :from => :pending, :to => :approved, :guard => :valid?
  end

  aasm_event :reject do
transitions :from => :pending, :to => :rejected, :guard => :valid?
  end

  acts_as_versioned

  self.non_versioned_columns << 'updated_at'
  self.non_versioned_columns << 'created_at'
  self.non_versioned_columns << 'qa'
  self.non_versioned_columns << 'published_at'

  def set_new_version
write_attribute(:qa, "pending")
  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-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] Error On relative_url_root

2009-03-26 Thread Alan Gutierrez

I'm attempting to mash together Adva CMS' Fckeditor and the Fckeditor  
plugin provided by Scott Rutherford.

http://blog.caronsoftware.com/2008/6/21/fckeditor-plugin-0-5-1-released

The Scott's plugin has a controller than handles the Fckeditor file  
upload and browse, but it errors out on the following lines.

   def upload_directory_path
 uploaded = request.relative_url_root.to_s+"#{UPLOADED}/ 
#{params[:Type]}"
 "#{uploaded}#{params[:CurrentFolder]}"
   end


If I remove the request.relative_url_root.to_s it works fine.

   def upload_directory_path
 uploaded = "#{UPLOADED}/#{params[:Type]}"
 "#{uploaded}#{params[:CurrentFolder]}"
   end

How do I make this go away without editing the plugin code? I found an  
article that says I'm supposed to set it in enviroment.rb but then I  
get errors that constants are not defined/found.

http://www.hostingrails.com/37/ActionController-AbstractRequestrelative_url_root

Alan Gutierrez

--~--~-~--~~~---~--~~
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] SOAP WSDLFactory

2009-03-26 Thread BenH

I've created a method for creating a SOAP WSDL driver.
I've tested this without basic auth and without SSL and it works
great. The sysadmin has enabled SSL and basic auth and now I'm stuck.

The error is:
HTTPClient::BadResponseError: unexpected response:
#

Which seems to indicate a failed authentication...

Here's the method:

  def create_record_driver # WS for creating a new record
username = "username"
password = "mypassword"
ws_site = "https://#{BASE_SITE}/ws/CreateRecord.asmx";
wsdl = "#{ws_site}?WSDL"
drv = SOAP::WSDLDriverFactory.new(wsdl).create_rpc_driver
drv.options['protocol.http.ssl_config.verify_mode'] =
OpenSSL::SSL::VERIFY_NONE
drv.options["protocol.http.basic_auth"] << [ ws_site, username,
password ]
return drv
  end

Any help would be appreciated.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-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] reverse of simple_format?

2009-03-26 Thread Danimal

Hello!

Is there a way to reverse the TextHelper simple_format? I.e. to take
some text with  tags and  tags and convert them into line
breaks in a smart way? (smarter than just a regexp that is).

TIA!

-Danimal
--~--~-~--~~~---~--~~
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: script/server error on Mac OS X

2009-03-26 Thread Bernard Dubuisson

For some reason, I tried uninstalling fastthread 1.0.5 with the
command gem uninstall fastthread -v 1.0.5 as explained here :
http://railsforum.com/viewtopic.php?pid=91777
It didnt work for me, for some reason fastthread 1.0.5 was still
listed as installed while performing gem -list
Bu then I removed all fastthread versions by hand with rm -dr
fastthread* in the proper directory, then reinstalled fastthread
1.0.4.
script/server was still broken, but script/server webrick worked
(after hitting ctrl-c, strangely).

I'm aware this is just a dirty workaround, not sure everything is in
proper working order.
I think I'll just install passenger and forget about mongrel, unless
anyone comes with a clean solution?

On Mar 26, 5:53 pm, "themikej...@gmail.com" 
wrote:
> the same thing has happened to me.
> Anyone know a solution?
>
> On Mar 26, 11:24 am, Bernard Dubuisson 
> wrote:
>
> > Hello all,
>
> > Recently, my apps stopped functionning properly on my dev machine
> > running Mac OS 10.4.11
>
> > Both script/server and script/console commands return this :
>
> > dub-macbook:~/Sites/contacts dub$ script/server
> > dyld: NSLinkModule() error
> > dyld: Symbol not found: _rb_thread_alive_p
> >   Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
> > fastthread.bundle
> >   Expected in: flat namespace
>
> > Trace/BPT trap
> > dub-macbook:~/Sites/contacts dub$ script/server
> > dyld: NSLinkModule() error
> > dyld: Symbol not found: _rb_thread_alive_p
> >   Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
> > fastthread.bundle
> >   Expected in: flat namespace
>
> > Trace/BPT trap
> > -
> > The apps were working properly before I proceeded to update some gems
> > including capistrano and mongrel.
>
> > This affects apps in development that run the latest versions of rails
> > (2.2.2), although I have an old app running 1.1.6 and it works fine.
>
> > I could not find this type of error documented anywhere, does anyone
> > have a clue?
>
> > Things I tried :
> > check if a new fresh app renders the same error (it does)
> > reinstalling ruby 1.8.6 (still the same error)
> > reinstalling gems (error still there)
> > updating mongrel, fastthread, rails (idem)
>
> > Thanks in advance for any advice or clue as to what's going on!
>
> > Bernard Dubuisson
--~--~-~--~~~---~--~~
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: cross site scripting security

2009-03-26 Thread Larz


The other thing seems to be that if this is set in the base
controller:
protect_from_forgery :secret => '10aedsfsdafdasfasdfxvcxvhg'

Then it generates the authenticity tokens, regardless of whether the
check is made. That seems to break my remote_function call as
mentioned in the previous post (because the :with js stuff doesn't get
put into the url/ params.

since protect_from_forgery I guess it's called at the class level, I'm
not sure I can disable it for one action and have it turned on for
others ..

I can turn this off at the instance level:
self.allow_forgery_protection
but that doesn't fix my other problem ...



--~--~-~--~~~---~--~~
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: adding a class in loops

2009-03-26 Thread Philip Hallstrom

> how do I only apply first to the first item?
>
> <% @clients.each do |client| %>
>   <%= link_to client.name, client, :class=> "first" %>
> <% end %>

if client == @clients.first

end

Not super efficient though.

Why not use CSS?

http://www.w3schools.com/CSS/css_pseudo_classes.asp

-philip



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



[Rails] adding a class in loops

2009-03-26 Thread limeyd

how do I only apply first to the first item?

<% @clients.each do |client| %>
   <%= link_to client.name, client, :class=> "first" %>
<% end %>

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



[Rails] Re: cross site scripting security

2009-03-26 Thread Larz

>
> To make it dynamic, I would use form_authenticity_token, not the
> actual value of it.
>

Thanks,

 So I make the call like this, it works fine except I'm not sure why
the stuff in the :with part from javascript
 doesn't make it into params when I have authenticity_token in
the :url part:


 <%= remote_function(:url => {:action => 'resize_field',
  :authenticity_token =>
form_authenticity_token,
  },
  :with =>
'{col:info.col,width:info.width}')
   %>


--~--~-~--~~~---~--~~
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: Trim all input fields

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 4:15 PM, Nikhil Vijayan
 wrote:
>
> Thanks Greg,
>
> Is there anyway to change this to something better ?
>
> require "#{ RAILS_ROOT }/app/models/trimmer"
>
> is there any way to move it to plugin or helper or somewhere else and
> load it in a better way .. thanks ..


You can put it wherever you want it.  Seemed like a model-like thing
so I put it in with the models.


-- 
Greg Donald
http://destiney.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: Trim all input fields

2009-03-26 Thread Nikhil Vijayan

Thanks Greg,

Is there anyway to change this to something better ?

require "#{ RAILS_ROOT }/app/models/trimmer"

is there any way to move it to plugin or helper or somewhere else and 
load it in a better way .. 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] Noob test Q

2009-03-26 Thread elliottg

I have been working with restful_authentication. I have made some
changes to it and now I'm trying to get all the default tests that
came with the plugin to pass.

Here's one of the tests that error out:

def test_should_require_login_on_signup
assert_no_difference 'User.count' do
  create_user(:login => nil)
  assert assigns(:user).errors.on(:login)
  assert_response :success
end
  end

This is the error:
NoMethodError: You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.errors

When using running debugger and checking in on assigns(:user) it
returns nil, so I assume this is the trouble.

Finally here's my question, what is "create_user" doing? Is it
creating a new User based upon the users.yml fixture that the test
suit is loading, or is it something else? I couldn't find reference
for this "dynamic??" method anywhere.

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



[Rails] Re: cross site scripting security

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 3:58 PM, Larz  wrote:
>  I'm still learning here, but what happens is if I copy the token from
> some other action that works so I now have this:
>
>  <%= remote_function(:url => {:action => 'resize_field',
>                              :authenticity_token
> =>"sda4354326hfghgfsf-whatever"},


To make it dynamic, I would use form_authenticity_token, not the
actual value of it.

http://api.rubyonrails.org/classes/ActionController/RequestForgeryProtection.html#M000491



-- 
Greg Donald
http://destiney.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: cross site scripting security

2009-03-26 Thread Larz


Thanks,

 I'm still learning here, but what happens is if I copy the token from
some other action that works so I now have this:

 <%= remote_function(:url => {:action => 'resize_field',
  :authenticity_token
=>"sda4354326hfghgfsf-whatever"},
 :with => '{col:info.col,width:info.width}')
   %>

then the :with part of the clause does not get into the parameters it
seems like ..


--~--~-~--~~~---~--~~
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: cross site scripting security

2009-03-26 Thread Robert Walker

Larz wrote:
> But I get the error (below). I'm not sure if there's a proper way to
> do it with remote_function() ?
> Anyway, first I did the main dev, now I am trying to learn more on
> security ..
> 
> Processing ShgridController#resize_field (for 155.x.x.x at 2009-03-26
> 16:28:11) [POST]
>   Session ID: 92c3ef636f552fbeff8e574d96bedb9f
>   Parameters: {"col"=>"5", "action"=>"resize_field",
> "controller"=>"shgrid", "width"=>"66"}
>   User Load (0.000269)   SELECT * FROM "users" WHERE (name = 'Zack2')
> LIMIT 1
>   AdminSetting Load (0.000156)   SELECT * FROM "admin_settings" LIMIT
> 1
> 
> 
> ActionController::InvalidAuthenticityToken
> (ActionController::InvalidAuthenticityToken):
> /usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/
> action_controller/request_forgery_protection.rb:86:in
> `verify_authenticity_token'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
> active_support/callbacks.rb:173:in `send'
> /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
> active_support/callbacks.rb:173:in `evaluate_method'

Sure it will fail on that because there is no authenticity token in your 
params:

Example:

Processing ThingsController#create (for 127.0.0.1 at 2009-03-26 
16:42:40) [POST]
  Parameters: {"commit"=>"Create", 
"authenticity_token"=>"wM7T6k++1upx4BO+fVy571jwqx0d4z0U92PPSGP+UUQ=", 
"thing"=>{"name"=>"Widget"}}

You may just want to disable forgery protection for this one action, but 
use it for all others. There might be a better solution than that, but 
it should get you past this problem.
-- 
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: cross site scripting security

2009-03-26 Thread Larz

> If you're concerned about security then commenting that out to resolve
> the errors you were getting in development was probably a mistake.
>

 Right, well I had this funny feeling about it, but at the time I was
trying to get some javascript stuff to work ..

 Anyway, there is a javascript call like this:


function update_server(info)
{

 <%= remote_function(:url => {:action => 'resize_field'},
 :with => '{col:info.col,width:info.width}')
   %>
}

So I just set some routing, I'm not a routing expert, but I did this:

map.connect 'shgrid/resize_field/:col/:width',
  :controller => 'shgrid',
  :action => 'resize_field'

But I get the error (below). I'm not sure if there's a proper way to
do it with remote_function() ?
Anyway, first I did the main dev, now I am trying to learn more on
security ..

Processing ShgridController#resize_field (for 155.x.x.x at 2009-03-26
16:28:11) [POST]
  Session ID: 92c3ef636f552fbeff8e574d96bedb9f
  Parameters: {"col"=>"5", "action"=>"resize_field",
"controller"=>"shgrid", "width"=>"66"}
  User Load (0.000269)   SELECT * FROM "users" WHERE (name = 'Zack2')
LIMIT 1
  AdminSetting Load (0.000156)   SELECT * FROM "admin_settings" LIMIT
1


ActionController::InvalidAuthenticityToken
(ActionController::InvalidAuthenticityToken):
/usr/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/
action_controller/request_forgery_protection.rb:86:in
`verify_authenticity_token'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
active_support/callbacks.rb:173:in `send'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.2/lib/
active_support/callbacks.rb:173:in `evaluate_method'



--~--~-~--~~~---~--~~
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: Trim all input fields

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 2:59 PM, Greg Donald  wrote:
> u[n] = u[n].strip if u[n].respond_to?( 'strip' )

Sorry, this line should actually be:

model[n] = model[n].strip if model[n].respond_to?( 'strip' )



-- 
Greg Donald
http://destiney.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: Naming Conventions for Associations

2009-03-26 Thread David T.

Thank you both for your suggestions.  For one reason or another, these
options didn't occur to me originally in this situation, even though I
was familiar with both.  Both make a lot of sense -- you've given me a
lot to think about for now.  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
-~--~~~~--~~--~--~---



[Rails] Re: Trim all input fields

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 2:39 PM, Nikhil Vijayan
 wrote:
>
> Hi all,
>
> What is the easiest way to trim all input fields before validation.
>
> Also on error the field should show the trimed version of the data.
>
> Any help would be appreciated, Thanks.

Append a new feature to your models:

module Trimmer
  def self.append_features( base )
base.before_validation do |model|
  model.attribute_names.each do |n|
u[n] = u[n].strip if u[n].respond_to?( 'strip' )
  end
end
  end
end

require "#{ RAILS_ROOT }/app/models/trimmer"
class ActiveRecord::Base
  include Trimmer
end



-- 
Greg Donald
http://destiney.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: what is taking so long to display this page?

2009-03-26 Thread Denis Haskin
And where was it going? ;-)

dwh

Scott Kulik wrote:
> Rob Biedenharn wrote:
>   
>> You can try New Relic's Rails Performance Monitor [1] to find out some
>> of those details.
>> 
> thanks rob!  i just installed the plugin and I can see where all the cpu
> is going.
>   

--~--~-~--~~~---~--~~
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: cross site scripting security

2009-03-26 Thread Robert Walker

wbsurf...@yahoo.com wrote:
>  protect_from_forgery :secret => 'hgfjh...kjhghglh' (whatever)
> 
>   self.allow_forgery_protection = false
> 
> 
>  I had commented those out during development because certain actions
> would error out because of these.

If you're concerned about security then commenting that out to resolve 
the errors you were getting in development was probably a mistake.

> For instance, I think I called remote_function() from java script and
> just added :width=>something.
> That added width into params, but I guess since it wasn't part of the
> routing the forgery protection
> flagged an error on it, is my guess.
> 
>  Is the best way to go through and try to fix the routing for
> everything ? I guess that might be the way I have to do it, I wanted
> to check if I really need to do that for security as it's sort of a
> pain in the neck to have to try to test
> all the methods, fix the routing and such ..

Also note that your subject line says Cross Site Scripting (XSS), which 
is not the same as Cross Site Request Forgery (CSRF). The method 
protect_from_forgery does nothing (as far as I understand it) to protect 
against XSS. It only provides protection against CSRF.
-- 
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] Trim all input fields

2009-03-26 Thread Nikhil Vijayan

Hi all,

What is the easiest way to trim all input fields before validation.

Also on error the field should show the trimed version of the data.

Any help would be appreciated, 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: what is taking so long to display this page?

2009-03-26 Thread Scott Kulik

Rob Biedenharn wrote:

> You can try New Relic's Rails Performance Monitor [1] to find out some
> of those details.
> 
> [1] http://newrelic.com/get-RPM.html
> 
> -Rob
> 
> Rob Biedenharnhttp://agileconsultingllc.com
> r...@agileconsultingllc.com

thanks rob!  i just installed the plugin and I can see where all the cpu
is going.
-- 
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: Naming Conventions for Associations

2009-03-26 Thread Robert Walker

Greg Donald wrote:
> On Thu, Mar 26, 2009 at 8:29 AM, David T.  wrote:
>> I seem to continually have this internal debate on how I should
>> approach naming certain associations on models. �For example, let's
>> say I have a User model and a User has one Status. �Although, let's
>> also say that in my system that 'Status' would be ambiguous with other
>> types of statuses, so I want to name the model UserStatus. �The
>> problem that I face now, is that when I say a user has one UserStatus,
>> the way I would refer to the associated model would, by default, look
>> like:
> 
> 
> Sounds like you want a polymorphic association.

If it were me, I would also consider whether a status warrants a 
separate model in the first place. I would consider managing a user's 
status using a "finite state machine" design pattern.

Of course, it's entirely possible that your design does warrant a 
separate UserStatus model, but the generic nature of Status leads me to 
think maybe it doesn't. I'm just saying that sometimes de-normalizing a 
database schema can greatly simplify the system design. And in some 
cases even increase system's performance.
-- 
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: Turning off the layout in ActionMailer?

2009-03-26 Thread Danimal

Found it: have to monkeypatch but at least it's simple:
http://blog.kreeti.com/rails/multipart-emails-with-mailer-templates

Hopefully that'll soon go in as a bug fix. (and maybe it is for 2.3.
I'm still on 2.2.2)

-Danimal

P.S. I posted just in case this helps someone else.

On Mar 25, 10:34 pm, Danimal  wrote:
> So I'm happy to see that ActionMailer supports layouts now (it may
> have for a while, but I just now realized it).
>
> But I don't see a way to turn them off selectively or by multipart
> type.
>
> For example, if I have a layout that's really simple in "layouts/
> email.html.erb":
>
> 
>   <%= yield %>
> 
>
> I can then use that in my ActionMailer class with a line at the top:
> layout 'email'
>
> But when I use multipart and have an HTML and a PLAIN file, they both
> use the layout and thus the plain contains the  tag.
>
> Is there any way to avoid this? or turn it off in certain cases?
>
> Thanks,
>
> -Danimal
--~--~-~--~~~---~--~~
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: Defining fixtures in Unit Tests necessary?

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 8:43 AM, Frederick Cheung
 wrote:
> For a while rails apps (by default) have fixtures :all in their
> test_helper.rb, which does pretty much what you would imagine.

When I moved an app from 2.2.2 to 2.3.2 a couple days ago, I was
prompted to remove the fixtures :all from my test_helper.rb,
deprecation warning if I recall correctly.  And then removing it broke
all my tests.  I had to put explicit fixture entries back into in all
my tests to get them working again.


-- 
Greg Donald
http://destiney.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: ActionMailer Layout on HTML version not Plain Text

2009-03-26 Thread Danimal

Woo hoo! Fix discovered!

http://blog.kreeti.com/rails/multipart-emails-with-mailer-templates

Whew! I wasted 4 hours last night trying to monkeypatch ActionMailer
but I was futzing around in the wrong places.

I added Surendra's suggestion as a monkeypatch and it works great!

Ok, on to other stuff...

-Danimal

On Mar 25, 11:02 pm, Danimal  wrote:
> BTW, looks like this has been a known bug for a little 
> while:https://rails.lighthouseapp.com/projects/8994/tickets/1799-actionmail...
>
> (since January at least).
>
> *sigh*
>
> Hopefully someone will fix it. If I knew the internals of Rails
> better, I'd give it a go myself.
>
> -Danimal
--~--~-~--~~~---~--~~
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: Naming Conventions for Associations

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 8:29 AM, David T.  wrote:
> I seem to continually have this internal debate on how I should
> approach naming certain associations on models.  For example, let's
> say I have a User model and a User has one Status.  Although, let's
> also say that in my system that 'Status' would be ambiguous with other
> types of statuses, so I want to name the model UserStatus.  The
> problem that I face now, is that when I say a user has one UserStatus,
> the way I would refer to the associated model would, by default, look
> like:


Sounds like you want a polymorphic association.

http://wiki.rubyonrails.org/howtos/db-relationships/polymorphic




-- 
Greg Donald
http://destiney.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: How to add .patch

2009-03-26 Thread Greg Donald

On Wed, Mar 25, 2009 at 9:30 PM, jko170  wrote:
>
> Noob question here: How do I add this patch to activemerchant?
>
> http://jadedpixel.lighthouseapp.com/attachments/24184/paymentech_gateway.patch


cd to the src code you want to patch then do something like:

wget -O - 
http://jadedpixel.lighthouseapp.com/attachments/24184/paymentech_gateway.patch
| patch -p1


http://linux.die.net/man/1/patch

http://www.google.com/search?q=how+to+apply+a+patch



-- 
Greg Donald
http://destiney.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: 2.3 Nested Forms, dynamically add an attribute

2009-03-26 Thread John Small


> I'd be very thankful for any advice!! Perhaps there are good examples
> on the web? I tried to understand Eloy's example, but it's quite
> difficult.
> 
> Best regards
Yes, it's very much on the level of "here's how to ride a bike, now go 
off and race a Formula 1 car, remember to break on the corners"

The example is very fragile, there's lots of different bits to it all 
over the place and they have to fit together just right or it won't 
work. So when you move the example over into your own code you'll get 
caught out trying to work out what has to stay the same and what can be 
changed.

I think he expects you to be a hard core coder to be able to understand 
what's going on. But here's a few clues I've picked up from reading 
through it.

1) You'll need to understand how delegation works in unobtrusive 
javascript. That business of  blah blah 
 is crucial to get the thing to work.

2) It creates a template for each type of association on the nested 
level, and you're expected to have a partial with the singularized name 
of the association which can be used to generate the template.

3) When you create a new nested record, the js code copies the template, 
replaces the string "NEW_RECORD" with a time stamp and puts it inside 
the div with the id set as the pluralized name of the association, at 
the bottom.

I'm trying to get it to work with has_and_belongs_to_many associations 
and it doesn't. Reading the code it looks like it can't work with habtm 
associations without a bit of a rethink, it uses record ids which is 
fine for hm associations, but not for habtm. You mention that you need 
to set things up for different object classes, so it sounds like you 
might be using polymorphic associations. It might not work with them 
either.

I've given up with it, I'm writing my own code to handle habtm.

John Small



-- 
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: Help with a validation issue..? Tying 2 validations together

2009-03-26 Thread Greg Donald

On Thu, Mar 26, 2009 at 1:26 PM, dhmspector  wrote:
> In essence:  validates_numericality_of :admin_comp,
> unless :admin_headcount <= 0
>
>
> any simple and obvious way to accomplish this..?


validates_numericality_of :admin_comp, :unless => Proc.new{ |r|
r.admin_headcount <= 0 }




-- 
Greg Donald
http://destiney.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] Help with a validation issue..? Tying 2 validations together

2009-03-26 Thread dhmspector

Hi,

I am trying to validate a field upon the presence of a value of
another field -- the two are linked

for example  my records have fields like this:

t.decimal  "admin_headcount",:precision =>
10, :scale => 2,  :default => 0.0
t.decimal  "admin_comp",   :precision =>
10, :scale => 2,  :default => 0.0

My forms have fields for entering of both values, however, the form
should post an error if the user tries to submit the form if there is
a non-zero value for headcount but the compensation amount is zero,
and vice versa.

Is there a way to tie
 validates_numericality_of :admin_comp
 validates_numericality_of :admin_headcount

to each other..?
In essence:  validates_numericality_of :admin_comp,
unless :admin_headcount <= 0


any simple and obvious way to accomplish this..?

regards,
  DHMS
--~--~-~--~~~---~--~~
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: Caching for a method in application helper

2009-03-26 Thread Maurício Linhares

http://www.rubyinside.com/and-now-the-best-rails-action-and-fragment-caching-tutorial-ever-427.html

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)



On Thu, Mar 26, 2009 at 2:34 PM, D  wrote:
>
> Hello All,
> I have a partial which is rendering on all pages of my web site. Which
> is using a method from application helper to get datas. Because of
> this partial loading in all pages making my site slow.Any one have a
> good idea of how to do caching for the method inside the application
> helper. Basically this method getting me three object arrays using find
> (:all) and using that I have to build a tree.
>
> Thanks in advance
> >
>

--~--~-~--~~~---~--~~
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: Who are the ROR guru's on this board ?

2009-03-26 Thread Cwi Tech guy

Cwi Tech guy wrote:
> Hi,
>   I am looking for the most knowledgeable ROR developers on this board.
> In your opinion, who are the most knowledgeable and helpful users on
> this board?
> 
> I am offering a free 1 year hosting account for development in exchange
> for feedback on our setup.  We are trying to improve our setup and are
> looking for a RoR developer to test it.
> 
> If your skilled in RoR development, and open to providing meaningful
> feedback, please reply or point me in the right direction.


Fred, Ryan , Matt
  Would any of you be interested in this opportunity or can you point me 
in the direction of someone who would be ?
-- 
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: help with code

2009-03-26 Thread Jose vicente Ribera pellicer

Jose vicente Ribera pellicer wrote:
>>  Are you 
>> seriously trying to put PHP code in your views? Or do you want to port 
>> the php to ruby?
>> 
>> SH
> 
> 
> I want to port the php, but i am a begginer developper and i only 
> program with RoR. I don't know how to port it to my rails application :(

I try with this:

<%-  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif 
%>


but firefox shows me this error:
 SyntaxError in Videos#show

Showing videos/show.html.erb where line #17 raised:

compile error
/Users/jose/mimandote.com/app/views/videos/show.html.erb:17: syntax 
error, unexpected tGVAR
_erbout.concat((  if(isset($_POST)): echo("Value is: 
".$_POST["input-rating"]); endif ).to_s); _erbout.concat "\n"
 ^
/Users/jose/mimandote.com/app/views/videos/show.html.erb:17: syntax 
error, unexpected ')', expecting kEND
_erbout.concat((  if(isset($_POST)): echo("Value is: 
".$_POST["input-rating"]); endif ).to_s); _erbout.concat "\n"
  ^
/Users/jose/mimandote.com/app/views/videos/show.html.erb:35: syntax 
error, unexpected $end, expecting ')'

Extracted source (around line #17):

14: 
15: 
16:
17: <%=  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); 
endif %>
18:
19: 

[Rails] Re: help with code

2009-03-26 Thread Jose vicente Ribera pellicer

>  Are you 
> seriously trying to put PHP code in your views? Or do you want to port 
> the php to ruby?
> 
> SH


I want to port the php, but i am a begginer developper and i only 
program with RoR. I don't know how to port it to my rails application :(
-- 
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] cross site scripting security

2009-03-26 Thread wbsurf...@yahoo.com


 I just changed my session store to use active record because it
appears session expiration and so on may be easier that way and it
seems like a better option.

In my base controller I have:

 protect_from_forgery :secret => 'hgfjh...kjhghglh' (whatever)

  self.allow_forgery_protection = false


 I had commented those out during development because certain actions
would error out because of these.
For instance, I think I called remote_function() from java script and
just added :width=>something.
That added width into params, but I guess since it wasn't part of the
routing the forgery protection
flagged an error on it, is my guess.

 Is the best way to go through and try to fix the routing for
everything ? I guess that might be the way I have to do it, I wanted
to check if I really need to do that for security as it's sort of a
pain in the neck to have to try to test
all the methods, fix the routing and such ..

--~--~-~--~~~---~--~~
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] helper caching issue

2009-03-26 Thread Greg Donald

I have a helper:

def pretty_datetime( dt )
  dt.strftime( "%b %d, %Y %I:%m%p" )
end


and I have a partial that uses the helper like this:

<%= pretty_datetime alert.updated_at %>


The problem is when I update the record the previous updated_at value
is still being displayed.


When I don't use the helper I see the updated_at value change every time.

<%= alert.updated_at %>


When I put the helper call back again, the partial again shows me the
previous updated_at value, even after multiple updates and me taking
it away and putting it back multiple times.  Even if I restart the
server I'm still seeing the old updated_at values from when the record
was first created.  I see the values changing in the database when I
update the record so I know the problem isn't there.


So why is the output of my helper (or partial) being cached?

This is in development mode, Rails 2.3.2.


-- 
Greg Donald
http://destiney.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: Using Rails Scaffold command does not preserve Case on Table Name

2009-03-26 Thread ruby...@ymail.com



On 26 Mar., 17:54, eengnerd  wrote:
> The following command issued at the terminal prompt for a Rails
> project should create a PostGreSQL table with the actual Table Name of
> Customers, but instead it creates a Table Name of customers.  This is
> extremely disconcerting to me.  Especially when I discovered that
> after using single quote marks (in the hope of remedying this), the
> command could not succeed in creating the other "serialization table"
> for tracking the autoincrementing id field.
>
> The command in question:
>
> ruby script/generate scaffold Customer LegalName:string Address:string
> City:string State:string PostalCode:string
>
> The real surprise was that the field name cases were actually
> preserved!  But not the Table Name.  I don't know why, but apparently
> there are a lot of programmers who think that "case does not matter"
> where table names are concerned.  But they matter a Great Deal to
> me...ok?

In Rails there is a set of naming conventions you need to use, in
order to make the development process of your Rails application
painless. Tables are plural nouns in snake case. Models are singular
nouns in camel case. These two conventions were made to enable Rails
to automatically detect the name of a table, based on the name of a
model.

RacingCar model => racing_cars table.

This kind of strict conventions does not exist for column names,
because Rails doesn't have to link them up to something else. Even
though, it's recommended to name your columns with snake case. If you
really, really want to get around this, you can go to the migration
file that the scaffold generator created for you and edit the table's
name manually and then, in your model, add this line:

set_table_name "Customers"

(But I hope you'll learn to accept the naming conventions of Rails,
soon.)

--
Best regards,
David Knorr
http://twitter.com/rubyguy
--~--~-~--~~~---~--~~
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: Ordering of messages in error_messages_for

2009-03-26 Thread Freddy Andersen

You can do this:

<%= f.text_field :email, :label => "Email Address", :required => true
%>
<%= error_message_on @user, :email %>

--~--~-~--~~~---~--~~
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] Caching for a method in application helper

2009-03-26 Thread D

Hello All,
I have a partial which is rendering on all pages of my web site. Which
is using a method from application helper to get datas. Because of
this partial loading in all pages making my site slow.Any one have a
good idea of how to do caching for the method inside the application
helper. Basically this method getting me three object arrays using find
(:all) and using that I have to build a tree.

Thanks in advance
--~--~-~--~~~---~--~~
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: help with code

2009-03-26 Thread Starr Horne

On Thu, 26 Mar 2009 18:05:54 +0100
Jose vicente Ribera pellicer  wrote:

> I don´t know PHP, and I understant this lines:
>if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif
> ?>
> 
> Anybody that works with PHP too can says me the equivalence for rails??

Post parameters are available in the view via the params method. Are you 
seriously trying to put PHP code in your views? Or do you want to port the php 
to ruby?

SH

-- 
Starr Horne
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/


--~--~-~--~~~---~--~~
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: How to prevent user assign value to attribute in ActiveRecord

2009-03-26 Thread ruby...@ymail.com



On 26 Mar., 18:16, noelnoelu  wrote:
> I have class bill like below
>
> class Bill < ActiveRecord::Base
>
>  #total = field in database
>
>  has_many :items
>
>  after_save :calculate_total
>
>  def calculate_total
>    total = self.items.map{|item| item.price}.sum
>   end
>
> end
>
> From the code above, the total will be auto calculated from on the
> price on each items in this bill. However, user can try to assign the
> value of this bill but when save the value with be replace with
> after_save calculate_total.
>
> The question is
>
> Do we have a way to prevent user to directly assign the total value
> but allow the calculate_total to assign the value?

Back in episode 26 of Railscasts, Ryan Bates covered this excact
problem with mass assignment. Enjoy the screencast:
http://railscasts.com/episodes/26-hackers-love-mass-assignment

--
Best regards,
David Knorr
http://twitter.com/rubyguy
--~--~-~--~~~---~--~~
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] Send a collection from view to controller

2009-03-26 Thread Hiro

Hi everybody,

Maybe this is a sort of newbie question but I've been trying to solve
it for several days without a solution.

Basically what I want to do is to pass a collection from the view to
my controller. I paste here the relevant part of both.

Controller:

@member=Member.find(:all)

if params[:new_member]=nil
  @list=[]
  @list.push(Member.new)
else
  @list=params['list']
  @list.push(Member.find(params[:new_member]))
end


View:

Inside a form that redirects to the controller


   <%...@member.each do |member|%>
 <%=member.name>
   <%end%>


<%=submit_tag("Add")%>


<%= hidden_field "list", @list %> # [1]


[1] Here's the problem. The error I got is

   "undefined method `push' for {"#"=>""}:HashWithIndifferentAccess"

But more important in parameters[error log]:

""list"=>{"#"=>""}}"

It means that the params['list'] value is taken as @list.name [that is
just garbage]


I Hope someone can help me! 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
-~--~~~~--~~--~--~---



[Rails] How to prevent user assign value to attribute in ActiveRecord

2009-03-26 Thread noelnoelu

I have class bill like below

class Bill < ActiveRecord::Base

 #total = field in database

 has_many :items

 after_save :calculate_total

 def calculate_total
   total = self.items.map{|item| item.price}.sum
  end


end

>From the code above, the total will be auto calculated from on the
price on each items in this bill. However, user can try to assign the
value of this bill but when save the value with be replace with
after_save calculate_total.

The question is

Do we have a way to prevent user to directly assign the total value
but allow the calculate_total to assign the value?
--~--~-~--~~~---~--~~
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: Using same variable in controller

2009-03-26 Thread Robert Walker

Phlip wrote:
> A Controller class is different. Rails creates an instance for you, each 
> time
> the routes.rb map tells Rails to. Then this object lives long enough to 
> service
> one and only one action.
> 
> Then it dies. All its instance variables go away, too.

Even if this were not the case reusing that instance variable would not 
cause any errors or problems.

When the action is called the variable gets assigned a value. If the 
instance variable already had a value then the old value would be 
dereferenced by the assignment. Then the variable would be set to 
reference the new value. The memory that was previously used by the old 
value would subsequently be freed by the Ruby automatic garbage 
collector.
-- 
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: what is taking so long to display this page?

2009-03-26 Thread Rob Biedenharn

On Mar 26, 2009, at 12:32 PM, Scott Kulik wrote:
> I have a page that does a lot of calculations...that for some reason
> takes 19 seconds to load when running in my development environment.
>
> Looking at my logs I can see Rendering took .8 seconds and the DB took
> 2.38 seconds:
>
> Completed in 19.81708 (0 reqs/sec) | Rendering: 0.80910 (4%) | DB:
> 2.38379 (12%) | 200 OK [http://wldev.kuliksco.com/compounds]
>
> where is the rest of the time coming from?  is this time when the  
> cpu is
> chugging away doing calculations?  I don't think it would be a  
> bandwidth
> issue since I'm testing from the same router/subnet.
> -- 


Yes, the remaining 16.62419 seconds are your code heating up the CPU.  
(Of course, not all of what falls outside of Rendering and DB is  
necessarily code written by you, but you'd have to instrument your  
code to find out more details.)

You can try New Relic's Rails Performance Monitor [1] to find out some  
of those details.

[1] http://newrelic.com/get-RPM.html

-Rob

Rob Biedenharn  http://agileconsultingllc.com
r...@agileconsultingllc.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] help with code

2009-03-26 Thread Jose vicente Ribera pellicer

Hi everybody, first at ll sorry if my english is not the best. I'm
trying to implement this javascript in my aplication:

http://www.ribosomatic.com/articulos/barra-de-calificacion-con-estrellas-rating-star-con-javascript-yui/

It´s a simple start rating implemented with javascript. There´s no
problem because I put it in public/javascripts and i can call them in my
application.html.rb but there´s one problem. I have this in my view:

.
.
.


  
" />









  var pValue = '';
  var r = new rating('stars', 5,  pValue || 0 , true, 'input-rating');

.
.
.
I don´t know PHP, and I understant this lines:


Anybody that works with PHP too can says me the equivalence for rails??
-- 
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: I have nill object when i didn't expect it

2009-03-26 Thread Robert Walker

Eelke Wolters wrote:
> You have a nil object when you didn't expect it!
> You might have expected an instance of ActiveRecord::Base.
> The error occurred while evaluating nil.[]=
> 
> I made a simple pages admin. When i tried to automate the permalink by
> adjusting the title i got tis error the model is enclosed in the
> attachment.
> whatever is commented on the page i do not wish to have on my page
> anymore, but i did not wan't to delete them either,

You posed the wrong code. This error is not happening in your view code 
it's happening in your controller.

You need to examine the code used to find @page. My guess is that it 
trying to do something like:

@page = Page.find(x)

Where x used to be the id of the record to find, but it now a string 
containing your permalink. That's is purely a guess since you didn't 
post the controller code that is throwing this exception.

So basically Rails is telling you that you were probably expecting 
form_for(@page) to be a form for an ActiveRecord::Base instance, but you 
are actually creating a form for nil form_for(nil).
-- 
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: Need suggestion Ruby To Gtk

2009-03-26 Thread Andrew Porter

Arulalan T wrote:
> 
> But even though mostly all people using GTK+ to develop GUI in ubuntu 
> and few more distributions. But my suggestion is Gtk+ is too tough , so 
> i planned to develop Ruby To Gtk+  same thing like Ruby To c...
> 

Doesn't this already exist ? -> http://ruby-gnome2.sourceforge.jp/

--~--~-~--~~~---~--~~
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] Using Rails Scaffold command does not preserve Case on Table Name

2009-03-26 Thread eengnerd

The following command issued at the terminal prompt for a Rails
project should create a PostGreSQL table with the actual Table Name of
Customers, but instead it creates a Table Name of customers.  This is
extremely disconcerting to me.  Especially when I discovered that
after using single quote marks (in the hope of remedying this), the
command could not succeed in creating the other "serialization table"
for tracking the autoincrementing id field.

The command in question:

ruby script/generate scaffold Customer LegalName:string Address:string
City:string State:string PostalCode:string

The real surprise was that the field name cases were actually
preserved!  But not the Table Name.  I don't know why, but apparently
there are a lot of programmers who think that "case does not matter"
where table names are concerned.  But they matter a Great Deal to
me...ok?


--~--~-~--~~~---~--~~
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: script/server error on Mac OS X

2009-03-26 Thread themikej...@gmail.com

the same thing has happened to me.
Anyone know a solution?

On Mar 26, 11:24 am, Bernard Dubuisson 
wrote:
> Hello all,
>
> Recently, my apps stopped functionning properly on my dev machine
> running Mac OS 10.4.11
>
> Both script/server and script/console commands return this :
>
> dub-macbook:~/Sites/contacts dub$ script/server
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rb_thread_alive_p
>   Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
> fastthread.bundle
>   Expected in: flat namespace
>
> Trace/BPT trap
> dub-macbook:~/Sites/contacts dub$ script/server
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rb_thread_alive_p
>   Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
> fastthread.bundle
>   Expected in: flat namespace
>
> Trace/BPT trap
> -
> The apps were working properly before I proceeded to update some gems
> including capistrano and mongrel.
>
> This affects apps in development that run the latest versions of rails
> (2.2.2), although I have an old app running 1.1.6 and it works fine.
>
> I could not find this type of error documented anywhere, does anyone
> have a clue?
>
> Things I tried :
> check if a new fresh app renders the same error (it does)
> reinstalling ruby 1.8.6 (still the same error)
> reinstalling gems (error still there)
> updating mongrel, fastthread, rails (idem)
>
> Thanks in advance for any advice or clue as to what's going on!
>
> Bernard Dubuisson
--~--~-~--~~~---~--~~
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: restful_authentication - how does encryption work?

2009-03-26 Thread Robert Walker

Oops, forgot to make my actual direct point to the OP question...

I assume that restful_authentication uses the SHA1 algorithm. But, you 
will have to confirm that. There are many different hash functions and 
each will result in a very different output. Since you must compare the 
outputs to know if the clear text passwords matched, you must ensure you 
are using the same algorithm.

-- 
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] Need suggestion Ruby To Gtk

2009-03-26 Thread Arulalan T
Hi to all,


I am very much interested in ruby and also likes to participate in gsoc
2009.

In ruby having TK to develop GUI.

But even though mostly all people using GTK+ to develop GUI in ubuntu and
few more distributions. But my suggestion is Gtk+ is too tough , so i
planned to develop Ruby To Gtk+  same thing like Ruby To c...

if it will done means, any one can develop GUI using Ruby coding  (with GTK
as backend program)

So please any one can give me your ideas, and any mentors give me your
suggestions to participate in gsoc09,,,

-- 
Thanks,

T.Arulalan

--~--~-~--~~~---~--~~
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] script/server error on Mac OS X

2009-03-26 Thread Bernard Dubuisson

Hello all,

Recently, my apps stopped functionning properly on my dev machine
running Mac OS 10.4.11

Both script/server and script/console commands return this :

dub-macbook:~/Sites/contacts dub$ script/server
dyld: NSLinkModule() error
dyld: Symbol not found: _rb_thread_alive_p
  Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
fastthread.bundle
  Expected in: flat namespace

Trace/BPT trap
dub-macbook:~/Sites/contacts dub$ script/server
dyld: NSLinkModule() error
dyld: Symbol not found: _rb_thread_alive_p
  Referenced from: /Users/dub/.gem/ruby/1.8/gems/fastthread-1.0.5/lib/
fastthread.bundle
  Expected in: flat namespace

Trace/BPT trap
-
The apps were working properly before I proceeded to update some gems
including capistrano and mongrel.

This affects apps in development that run the latest versions of rails
(2.2.2), although I have an old app running 1.1.6 and it works fine.

I could not find this type of error documented anywhere, does anyone
have a clue?

Things I tried :
check if a new fresh app renders the same error (it does)
reinstalling ruby 1.8.6 (still the same error)
reinstalling gems (error still there)
updating mongrel, fastthread, rails (idem)

Thanks in advance for any advice or clue as to what's going on!

Bernard Dubuisson

--~--~-~--~~~---~--~~
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] ruby script/server error

2009-03-26 Thread themikej...@gmail.com

I updated the ruby gems and now I keep getting this error when trying
to run: ruby script/server


dyld: NSLinkModule() error
dyld: Symbol not found: _rb_thread_alive_p
  Referenced from: /Users/mikejahn/.gem/ruby/1.8/gems/fastthread-1.0.5/
lib/fastthread.bundle
  Expected in: flat namespace

Trace/BPT trap


any suggestions on how to fix it?

--~--~-~--~~~---~--~~
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: no such file to load -- config/environment - Apache2 & Passenger 2.1.1

2009-03-26 Thread doron

: ok, solved for me.
it is very important to read section 8.1 in the user guide:
 http://www.modrails.com/documentation/Users%20guide.html#_tips

and also to remember set the correct RailsEnv in the conf file.


we went with:

PassengerUserSwitching off
PassengerDefaultUser www
RailsEnv something_that_is_not_production

On 26 מרץ, 15:40, doron  wrote:
> I have the same problem, and the owner:group is root:www
> changing to www:www seems to only make things worse and i don't even
> get thepassengererror page.
> do you have any other idea?
>
> i use:
> Rails 1.2.3passenger2.1.2
> Apache/2.0.52 (CentOS)
>
> On 25 מרץ, 19:17, Charles Johnson  wrote:
>
> > On Wed, Mar 25, 2009 at 9:40 AM, doron  wrote:
>
> > > try here:
> > >http://blog.scopeport.org/ruby-on-rails/phusion-passenger-error-file-...
>
> > > Basti כתב:
> > > > Hi,
> > > > i recently started using Ruby and Ruby on Rails. For Development i'm
> > > > using RadRails and InstantRails on my local Windows machine.
>
> > > > Atm i'm trying to get a basic application running on Ubuntu Server
> > > > 8.10 with Apache 2.2.9 & Phusion_Passenger 2.1.1.
> > > > Frist i tried to get just the app-sceleton generate by RadRails to
> > > > work (which worked fine on InstantRails) and the i tried the same with
> > > > Typo(blog).
>
> > > > In both cases i recieve the following error:
>
> > > > no such file to load -- config/environment
>
> > Change the owner and group of the environment.rb file to the user and group
> > of your apache2 instance (probably www-data). See if that helps.
> > Cheers--
>
> > Charles
--~--~-~--~~~---~--~~
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: restful_authentication - how does encryption work?

2009-03-26 Thread Robert Walker

Ar Chron wrote:
> Very generally speaking:
> 
> For a login, when the login was first created and validated, the code 
> takes the clear text password and the salt, sticks them in a blender 
> (SHA1.hexdigest if I recall correctly) and creates the encrypted 
> password.
> 
> By storing the salt and the encrypted password, any subsequent login 
> attempt just submits a password, which is run through the same blender 
> with the stored salt, and is compared to the stored encrypted password.

For clarity's sake SHA1 is not an encryption. It is a message digest 
(hash). Encryption is a two-way function, but a message digest such as 
SHA1 is one-way only. In fact that is its fundamental feature. A hashed 
result from SHA1 can never (at least that's the idea) be reversed back 
to the clear text used to generate it. It should never reveal 
information about the original clear text. Good hash function like SHA1 
should also vary greatly (more the 50%) with very small changes to the 
input text (1 bit difference in clear text should produce something like 
50% of the bits changing in the hash).

A "salt" value is something that is appended, or mixed in, with the 
original clear text in an effort to strengthen what otherwise might be a 
weak input. The longer the input to the message digest the better it can 
hide any information leakage into the resulting hash output thereby 
strengthening the result.
-- 
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] what is taking so long to display this page?

2009-03-26 Thread Scott Kulik

I have a page that does a lot of calculations...that for some reason
takes 19 seconds to load when running in my development environment.

Looking at my logs I can see Rendering took .8 seconds and the DB took
2.38 seconds:

Completed in 19.81708 (0 reqs/sec) | Rendering: 0.80910 (4%) | DB:
2.38379 (12%) | 200 OK [http://wldev.kuliksco.com/compounds]


where is the rest of the time coming from?  is this time when the cpu is
chugging away doing calculations?  I don't think it would be a bandwidth
issue since I'm testing from the same router/subnet.
-- 
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] 2.3 Nested Forms, dynamically add an attribute

2009-03-26 Thread tilt

Hi,

I'm implementing some nested forms with Rails 2.3 which works pretty
well as long as I only have to edit the objects that are already
associated to the original object.

I'm not sure though how to implement an "Add new object" button which
adds another associated object. Unfortunately I can't pre-build
another attribute while loading the form, which would be the standard
way presented in the example form of "What's new in Rails 2.3". The
reason why this wouldn't work for me is that the user first has to
choose which kind of object he's about to add, so the application
knows which select options to generate the user is able to choose from
to configure the newly created object afterwards.

One way to go presented by Ryan Bates' in his Railscasts  (but
designed for Rails 2.2) was to dynamically load an object with a
"link_to_function" request and render it to the fields_for block:

Within the partial associated_object.html.erb this would look like

<% fields_for "object[associated_object][]", associated_object do |
object_form| %>
...
<% end %>

...with an iterator named "associated_object".

Within the view there's:

link_to_function "name" do |page|
  page.insert_html :bottom, :associated_objects, :partial =>
'associated_object', :object => AssociatedObject.new
  end

Unfortunately I don't understand thoroughly how this one's working so
I can't transfer it to the Rails 2.3 situation where the view looks
like this:

<% f.fields_for :associated_objects do |associated_object_form| %>

<%= associated_object_form.object.name %>
...

So what I want to do is:

a) provide a "New" button to dynamically insert a new
associated_object into the view (as done in the Rails 2.2 example)
b) load not just any object into the nested form as done above, but a
specific one the user chooses from a select box before clicking "New"

I'd be very thankful for any advice!! Perhaps there are good examples
on the web? I tried to understand Eloy's example, but it's quite
difficult.

Best regards



--~--~-~--~~~---~--~~
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: Version fu problem

2009-03-26 Thread Roderick van Domburg

Freddy Andersen wrote:
> I have a class that uses version_fu (Page class) the issue is that if
> I run a clean migration it fails on the version_fu declaration in the
> Page class, Its looking for the page_versions column that has not been
> created yet.

For this reason you should use rake db:schema:load instead of 
db:migrate.
Otherwise, you'll have to come up with ugly tricks.

--
Roderick van Domburg
http://www.nedforce.com
-- 
Posted via http://www.ruby-forum.com/.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-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 2.3.2 nested forms, option_groups etc

2009-03-26 Thread John Small

Working in 2.3.2 and working from the examples in Github for nested
forms, this works fine for simple text fields, or simple selects but
option_groups_from_collection_for_select is a bit more complicated.

The js code he's used generates a template to be used for each nested
form, but it does it in the simple example by using a f.select helper.
This will generate the correct html for the new record. But if you're
doing something a bit more complex e.g. using
option_groups_from_collection_for_select then you have to wrap the
options in your own select tag. So how do I get everything in place in
my hand coded  and also allow the js to create the right
template?

All comments welcome

Ta

John Small
-- 
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: about show list

2009-03-26 Thread thitima panyayai
thank you for your suggestion .

2009/3/26 Ar Chron 

>
> >   def index
> > @title = "list of  sequences"
> > @items = Seq.find(:all)
> >   end
>
> That method shouldn't be doing a wide-open find. You need to scope the
> find somehow, and deal with the case where the current user isn't logged
> in yet.
> --
> 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] another problem starting mongrel

2009-03-26 Thread Sergio Ruiz

i am having yet another problem starting mongrel on my production
server..

i am getting error [1] .. i thought it was that i needed to install a
new gem, but nothing is ringing any bells..

any ideas?

thanks!

--

[1]

/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:442:in
`load_missing_constant': uninitialized constant Localization::CONFIG
(NameError)
from
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:77:in
`const_missing'
from
/home/redredftp/Sites/Deployed/Red_Red_FTP/releases/20090326150545/lib/localization.rb:85
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from
/usr/lib64/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:155:in
`require'
from
/home/redredftp/Sites/Deployed/Red_Red_FTP/releases/20090326150545/app/controllers/application.rb:4
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
from
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
 ... 30 levels...
from
/usr/lib64/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in
`run'
from
/usr/lib64/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
from /usr/bin/mongrel_rails:19:in `load'
from /usr/bin/mongrel_rails:19
[redred...@redred current]$
-- 
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: Suming total spend

2009-03-26 Thread Ruby on Rails: Talk

Thanks!

That's done the trick perfectly.

On Mar 26, 3:30 pm, "David T."  wrote:
> How about using sum conditions / includes to do it all in one SQL
> query.  Something like:
>
> @total = Treatment.sum(:price, :include => :appointment, :conditions
> => {'appointments.customer_id' => @cust.id})
>
> David
--~--~-~--~~~---~--~~
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: Suming total spend

2009-03-26 Thread David T.

How about using sum conditions / includes to do it all in one SQL
query.  Something like:

@total = Treatment.sum(:price, :include => :appointment, :conditions
=> {'appointments.customer_id' => @cust.id})

David
--~--~-~--~~~---~--~~
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: restful_authentication - how does encryption work?

2009-03-26 Thread Ar Chron

Very generally speaking:

For a login, when the login was first created and validated, the code 
takes the clear text password and the salt, sticks them in a blender 
(SHA1.hexdigest if I recall correctly) and creates the encrypted 
password.

By storing the salt and the encrypted password, any subsequent login 
attempt just submits a password, which is run through the same blender 
with the stored salt, and is compared to the stored encrypted password.
-- 
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: Data from DB based on role

2009-03-26 Thread Serafino Picozzi

Ar Chron wrote:
> You'll have to scope the find at some point, and if this requirement is 
> really pervasive, I'd recommend creating a find_using_role_or_id method 
> (or something like that) which at least lets you write and maintain that 
> "find scoping" code in a single place, not in every controller's index 
> method.
> 
> Patch it in to ActiveRecord, or create an abstract class that sits 
> between ActiveRecord and the rest of your models and implements the 
> method.

Thanks for your reply. It's a good suggestion, but in fact the scope is 
not limited to the find, sometimes I have to perform some code in the 
controller not related to AR but different from user to user.

In the past in thos situations I used to create a different namespace 
for every user, with shared views, but this has the disadvantage to have 
a lot of controllers which are really similar
-- 
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: Data from DB based on role

2009-03-26 Thread Ar Chron

You'll have to scope the find at some point, and if this requirement is 
really pervasive, I'd recommend creating a find_using_role_or_id method 
(or something like that) which at least lets you write and maintain that 
"find scoping" code in a single place, not in every controller's index 
method.

Patch it in to ActiveRecord, or create an abstract class that sits 
between ActiveRecord and the rest of your models and implements the 
method.
-- 
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] Gem remote Fetch error

2009-03-26 Thread Tamilselvi Srinivasan

I keep getting this error while trying to run gem update:

D:\blog>gem update --system
Updating RubyGems...
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
Bad file descriptor - connect(2)(Errno::EBADF)

can anyone put some light on this..

thanks for any 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
-~--~~~~--~~--~--~---



[Rails] Strange error in development mode in 2.3.2 when streaming data

2009-03-26 Thread Jeff

I've recently upgraded to 2.3.2 from 2.2.2.  We used to have code in
our controller that streamed data back to the browser in chunks, and
that no longer works in 2.3.2.  It seems to be messing up the
dependency-loading mechanism. Here's a simplified version of the code:

# visitor.rb
class Visitor < ActiveRecord::Base
  has_many :events
end

# event.rb
class Event < ActiveRecord::Base
  belongs_to :visitor
end

# Now the interesting part...

class MyController < ActionController::Base

  def index
 render  :status => 200, :layout => false,
 :text => Proc.new { |response, output| output.write
Visitor.first.events.inspect}
  end

The error we get is:

A copy of Admin::VisitorEventsController has been removed from the
module tree but is still active!

This only happens if we try to reference an ActiveRecord model within
the proc.  We can't move our code out of the proc, because the whole
idea is that we'll be streaming data that's being dynamically
generated inside the proc.

Anybody else seen this?

Thanks
Jeff
--~--~-~--~~~---~--~~
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] Suming total spend

2009-03-26 Thread Ruby on Rails: Talk

Hi

I have an application with a number of models. The one's I'm
interested in are customers, who have appointments. Each appointment
has a number of treatments associated.

I'm trying to calculate the total amount spent by the customer on
treatments over all the appointments.

@cust = Customer.find(1)
@cust.appointments[0].treatments.sum(:price)

The above works for just the first appointment found. But how to I get
it to sum across all appointments?

I've tried something like:

@total = @cust.appointments.sum{|u| u.treatments.sum(:price)}

But to no avail.

Any help would be gratefully appreciated!

Darren
--~--~-~--~~~---~--~~
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: trouble starting mongrel

2009-03-26 Thread Sergio Ruiz


> rails should start. The fact that it works in development probably
> means you're running a different rails version there.


thanks, fred.. removing now..

the weird part is that i am running 2.2.2 on both machines..

hmm..

thanks again!

-- 
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: Deleting files after they are sent via send_file

2009-03-26 Thread elioncho

I have been doing some research and only found about using cron jobs
to do the cleaning (a point I discussed on my initial message) and
also found this:

There is an send_file option:
:stream - whether to send the file to the user agent as it is read
(true) or to read the entire file before sending (false). Defaults to
true. When U set :stream => false U can delete the file just after
send_file return.

I wonder if someone has used this before and if there is any
disadvantage to this approach.

Thanks again,

Elías




On Mar 26, 4:41 am, "Simone R." 
wrote:
> Elias Orozco wrote:
> > Hello guys,
>
> > I am having the option to download certain folders on my app in zip
> > format. So every time a user requests one I'm doing a system call to
> > zip the folder (ex: system('cd '+path+' && zip ...) and then the
> > send_file method to send it.
>
> > What happens is that I'm keeping track of disk space so I need to
> > delete the zip immediately. I was wondering if there is a way of
> > creating the zip file in a sort of tmp directory and send it via
> > send_file from the tmp path. I don't know when the file transfer is
> > over to delete the zip file and having a cron job to delete zip files
> > is not an option (disk space could be surpassed by the zip file and
> > the user will have to wait for it to be deleted to be able to create
> > new files). Can anyone point me in the right direction please. Thanks,
>
> > El as
>
> I dont'know how to do it in RoR (i'm a newbie) but wen i was using the
> old ASP there was an "onSessionEnd" where you can script some task to do
> when a session end (both for logout or timeout)
>
> You can just bind the zip to a session and when the session end you can
> delete the file
>
> --
> 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: implementation of internationalization

2009-03-26 Thread Leonardo Borges

This should get you going: 
http://www.artweb-design.de/2008/7/18/the-ruby-on-rails-i18n-core-api

Leonardo Borges
www.leonardoborges.com


On Mar 26, 11:02 am, "railsb...@gmail.com" 
wrote:
> Hello there,
>
>       I am trying to implement a small application to know about
> internationalization. I would like to change links, button names etc
> to different languages which are of user interest.
>
>    Can anybody tell me how to start and what do I need to implement
> it.
>
> Thank you.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Defining fixtures in Unit Tests necessary?

2009-03-26 Thread Frederick Cheung



On Mar 26, 12:27 am, yachtman  wrote:
> Is it necessary to define fixtures in my test file
> ('fixtures :users')?
>
> My test are working with the definition, but I decided to debug and
> checked for the fixtures existence even without the definition and all
> of them had been loaded. So what's the purpose of the declaration?

For a while rails apps (by default) have fixtures :all in their
test_helper.rb, which does pretty much what you would imagine.

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: about show list

2009-03-26 Thread Ar Chron

>   def index
> @title = "list of  sequences"
> @items = Seq.find(:all)
>   end

That method shouldn't be doing a wide-open find. You need to scope the 
find somehow, and deal with the case where the current user isn't logged 
in yet.
-- 
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: no such file to load -- config/environment - Apache2 & Passenger 2.1.1

2009-03-26 Thread doron

I have the same problem, and the owner:group is root:www
changing to www:www seems to only make things worse and i don't even
get the passenger error page.
do you have any other idea?

i use:
Rails 1.2.3
passenger 2.1.2
Apache/2.0.52 (CentOS)

On 25 מרץ, 19:17, Charles Johnson  wrote:
> On Wed, Mar 25, 2009 at 9:40 AM, doron  wrote:
>
> > try here:
> >http://blog.scopeport.org/ruby-on-rails/phusion-passenger-error-file-...
>
> > Basti כתב:
> > > Hi,
> > > i recently started using Ruby and Ruby on Rails. For Development i'm
> > > using RadRails and InstantRails on my local Windows machine.
>
> > > Atm i'm trying to get a basic application running on Ubuntu Server
> > > 8.10 with Apache 2.2.9 & Phusion_Passenger 2.1.1.
> > > Frist i tried to get just the app-sceleton generate by RadRails to
> > > work (which worked fine on InstantRails) and the i tried the same with
> > > Typo(blog).
>
> > > In both cases i recieve the following error:
>
> > > no such file to load -- config/environment
>
> Change the owner and group of the environment.rb file to the user and group
> of your apache2 instance (probably www-data). See if that helps.
> Cheers--
>
> Charles
--~--~-~--~~~---~--~~
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] Passenger 2.1.2 and mod_rewrite

2009-03-26 Thread Michał Kalbarczyk

Hey.
Is anybody has working mod_rewrite with passenger 2.1.2 ? Redirects
work, but rewrites not.
I have rewrite logging on, and it looks like 'local path' rewrites
just fine, but rails can't see it.

Thanks.
FaziBear.

--~--~-~--~~~---~--~~
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] Naming Conventions for Associations

2009-03-26 Thread David T.

Hi Everyone,

I seem to continually have this internal debate on how I should
approach naming certain associations on models.  For example, let's
say I have a User model and a User has one Status.  Although, let's
also say that in my system that 'Status' would be ambiguous with other
types of statuses, so I want to name the model UserStatus.  The
problem that I face now, is that when I say a user has one UserStatus,
the way I would refer to the associated model would, by default, look
like:

@user.user_status

I feel that in this context, the double 'user' references are
redundant.  Something like this would be more natural:

@user.status (where status is UserStatus)

I realize that I can achieve the second syntax in a couple of ways.
In the User model, I can change the association name, like:

belongs_to :status, :class_name => 'UserStatus', :foreign_key =>
'user_status_id'

This works, but it creates the getters/setters:

@user.status
@user.user_status_id

I would expect for it to also let me change the id through something
like @user.status_id, not @user.user_status_id.   So, this only cleans
things up half-way.

I realize too, that I can rename the actual database foreign key to
status_id instead of user_status_id, and then do something like this
in my user model:

belongs_to :status, :class_name => 'UserStatus'

This let's me access the status and status_id setters/getters as I
would expect.  The thing about both of these changes though is that I
feel like I'm straying from the conventions, which I really want to
try to avoid.  I wanted to get a survey of how other people usually
approach this.  Any advice with this would be appreciated.

Thanks,
David



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



  1   2   >