[Rails] Re: gems not loading and causing Internal Server Error

2008-11-07 Thread comopasta Gr

Hi,

I think I'm having a very similar problem as you have. I have it with 
openid plugin:
http://www.ruby-forum.com/topic/170134#new

I can use the gem after setting ENV['GEM_PATH'] = 
'/home/mydomain/ruby/gems'

But rake is broken, I can't migrate, or do anything with it, even 
script/about complains about the gem.

I´ve spent 2 days with it with no luck.

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

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



[Rails] Re: gems not loading and causing Internal Server Error

2008-11-07 Thread Freddy Andersen

I have seen stuff like this before and it was environment issues...
The rake command was running from a different install of ruby than the
console/server scripts...

Did you install ruby from source and maybe you have the rpms for ruby
installed...
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: ruby-openid is breaking my rake

2008-11-07 Thread Maurício Linhares

Oh, i'm sorry, i missed it, just saw the::

 gem 'ruby-openid', '>=2.0.4'

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
João Pessoa, PB, +55 83 8867-7208



On Fri, Nov 7, 2008 at 6:20 PM, comopasta Gr
<[EMAIL PROTECTED]> wrote:
>
> Hey, Mauricio thanks a lot for dropping by.
>
>> The call should be:
>>  gem 'ruby-openid', :lib => 'openid'
>
> Isn't that covered with this line in the init.rb?
> config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'
>
> Maybe I didn't get your point. Do you mean a similar call is needed
> somewhere else?
>
> Regards
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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



[Rails] gems not loading and causing Internal Server Error

2008-11-07 Thread Marli Ba

I'm running rails 2.1.2 on a hostmonster.com server where I don't have
control over the web server for restarts.  My problem is that I can
install gems, but they don't seem to work and my app can never find them
and throws errors.

The relevant lines in my environment.rb
-
Rails::Initializer.run do |config|
...
config.gem "ezcrypto"
config.gem "acts_as_secure"
...
end
-

Now when I try to run ruby script/console I get:
-
Loading development environment (Rails 2.1.2)
Missing these required gems:
  ezcrypto
  acts_as_secure

You're running:
  ruby 1.8.6.287 at /usr/bin/ruby
  rubygems 1.3.1 at /home/marlibau/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.
-

I can run rake gems:install, and it produces this output:
-
(in /home/myuser/rails/my_app)
gem install ezcrypto
Successfully installed ezcrypto-0.7
1 gem installed
Installing ri documentation for ezcrypto-0.7...
Installing RDoc documentation for ezcrypto-0.7...
gem install acts_as_secure
Successfully installed acts_as_secure-0.0.3
1 gem installed
-

But then if I run ruby script/console, it throws the same error as
before.

During all this my app otherwise runs correctly except it can't use the
gems.  When the web server does restart, then my app stops working and
throws:
-
Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, [EMAIL PROTECTED] and
inform them of the time the error occurred, and anything you might have
done that may have caused the error.

More information about this error may be available in the server error
log.

Additionally, a 404 Not Found error was encountered while trying to use
an ErrorDocument to handle the request.
Apache/2.2.9 (Unix) mod_ssl/2.2.9 OpenSSL/0.9.8i DAV/2
mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 Server
at www.my_website.com Port 80
--

I have tried freezing rails / unfreezing rails, using include paths in
the environment.rb file, using "require" statements and I just have no
idea what else to do.  The only thing that seems to solve it is to
remove the gems from the environment.rb file, but then I don't get to
use them.

My plugins work fine once the server restarts so that is not an issue.

Anyone have any ideas??  Does my server just suck or is there something
I can do about this?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Problem autenticating user

2008-11-07 Thread Margareth Florián
hi every body

I need help..
I have the following code in a user model. But when i try to autenticate an
user always returns nil, my session controller calls the autenticate method.
I proves comparing only the database password with new encrypted password
but always returns nil. The database password was encryted with the same
encrypt method. I dont know what i need to do.
TNKS a lot..

# Authenticates a user by their login name and unencrypted password. Returns
the user or nil.
*

def self*.authenticate(login, password)

u = find_by_login(login) # need to get the salt and user_password

u && u.authenticated?(password) ? u :* nil

end
*

# Encrypts some data with the salt.
*

def self*.encrypt(password, salt)

Digest::SHA1.hexdigest("--#{salt}--#{password}--")
*

end
*

# Encrypts the password with the user salt
*

def* encrypt(password)
*

self*.class.encrypt(password, salt)
*

end
*

*

def* authenticated?(password)

user_password == encrypt(password)
*

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] IO Error

2008-11-07 Thread AD
has anyone seen an IO error like this?  Trying to track it down, running
Jruby/Rails on Tomcat here...

INFO: /!\ FAILSAFE /!\  Fri Nov 07 17:26:01 -0500 2008
  Status: 500 Internal Server Error
  IO Error

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/request.rb:420:in
`parse_formatted_request_parameters'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/cgi_process.rb:80:in
`request_parameters'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/request.rb:307:in
`parameters'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/request.rb:22:in
`request_method'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/request.rb:35:in
`method'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:431:in
`extract_request_environment'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/routing/route_set.rb:384:in
`recognize'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:148:in
`handle_request'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:107:in
`dispatch'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:104:in
`dispatch'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:120:in
`dispatch_cgi'

 
/usr/local/tomcat/webapps/myapp/WEB-INF/gems/gems/actionpack-2.1.1/lib/action_controller/dispatcher.rb:35:in
`dispatch'

 
file:/usr/local/tomcat/webapps/myapp/WEB-INF/lib/jruby-rack-0.9.1.jar!/rack/adapter/rails.rb:37:in
`serve_rails'

 
file:/usr/local/tomcat/webapps/myapp/WEB-INF/lib/jruby-rack-0.9.1.jar!/rack/adapter/rails.rb:44:in
`call'

 
file:/usr/local/tomcat/webapps/myapp/WEB-INF/lib/jruby-rack-0.9.1.jar!/jruby/rack/rails.rb:141:in
`call'

 
file:/usr/local/tomcat/webapps/myapp/WEB-INF/lib/jruby-rack-0.9.1.jar!/rack/handler/servlet.rb:17:in
`call'
:1

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



[Rails] Re: Speak at Acts as Conference 2009

2008-11-07 Thread Robert Dempsey

Good afternoon everyone,

There's been some confusion on what we are looking for this year, so
here's what we need from you all in terms of a submission:

* Your name
* A little about yourself (what you do, who you do it for)
* What you want to talk about, and how it ties into the theme of
improving productivity and maintaining a competitive edge.

Here are some examples of topics to get you started:

* Following the Ruby idioms
* Refactoring
* Pair programming and agile techniques
* Understanding the tools that are available
* Building on existing applications to give yourself a head start

Thanks.

- Rob
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: ruby-openid is breaking my rake

2008-11-07 Thread comopasta Gr

Hey, Mauricio thanks a lot for dropping by.

> The call should be:
>  gem 'ruby-openid', :lib => 'openid'

Isn't that covered with this line in the init.rb?
config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'

Maybe I didn't get your point. Do you mean a similar call is needed 
somewhere else?

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

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



[Rails] Re: Schema and relationships between tables

2008-11-07 Thread Marli Ba

Shandy Nantz wrote:
> I am trying to allow a user to answer some questions and then save those
> questions but I am unsure if I am getting the layout correct. Here is
> what I have so far:
> 
> There is a questions table holding the questions to ask
> 
> There is an answers tables which holds the answers to the questions
> asked of a user.
> 
> Then there is of course the Users table which hold a variety of user
> info
> 
> I figure my migrations would look something like:
> 
> Questions: has_many :answers
> 
> Answers: belong_to :user, belongs_to :question
> 
> User has_many :answers
> 
> so my table would look like:
> 
> User: id, username, . . .
> 
> Questions: id, question
> 
> Answer: id, user_id, question_id, answer
> 
> Where I am a little confused is if the belongs_to :question should
> rather be a has_one :question and would that change the schema at all?
> Also, can anyone point me to some good online tutorials involving Model
> Relationships, thanks,
> 
> -S

For what it's worth, I would probably do something like:

User:  has_many :questions
   has_many :answers

Question:  has_many :answers
   belongs_to :user

Answer:  belongs_to :question
 belongs_to :user

Tables:
User: id | user_name
Question: id | user_id | question
Answer:   id | user_id | question_id | answer


hope this helps
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: ruby-openid is breaking my rake

2008-11-07 Thread Maurício Linhares

The call should be:

 gem 'ruby-openid', :lib => 'openid'

The name of the file to be required is 'openid' and not ruby-openid.

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
João Pessoa, PB, +55 83 8867-7208



On Fri, Nov 7, 2008 at 6:05 PM, comopasta Gr
<[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> Still fighting with this one. I think the problem is actually the
> open_id_authentication plugin, not the ruby-openid gem.
>
> This is the init.rb of the pluging, which should be ok and up to rails
> 2.x changes.
>
> if config.respond_to?(:gems)
>  config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'
> else
>  begin
>require 'openid'
>  rescue LoadError
>begin
>  gem 'ruby-openid', '>=2.0.4'
>rescue Gem::LoadError
>  puts "Install the ruby-openid gem to enable OpenID support"
>end
>  end
> end
>
> config.to_prepare do
>  ActionController::Base.send :include, OpenIdAuthentication
> end
>
> --
>
> But still running rake gives:
>
> [~/rails/try]# rake
> (in /home/mydomain/rails/try)
> Missing these required gems:
>  ruby-openid  >= 2.0.4
>
> You're running:
>  ruby 1.8.6.287 at /usr/bin/ruby
>  rubygems 1.3.1 at /home/mydomain/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8
>
> Run `rake gems:install` to install the missing gems.
>
> --
>
> Lots of googling lately but no real hints how to solve it.
> As mentioned the funny thing is that I can use openid in the app with no
> problems. The feature works.
>
> Cheers.
>
>
>
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: ruby-openid is breaking my rake

2008-11-07 Thread comopasta Gr

Hi,

Still fighting with this one. I think the problem is actually the 
open_id_authentication plugin, not the ruby-openid gem.

This is the init.rb of the pluging, which should be ok and up to rails 
2.x changes.

if config.respond_to?(:gems)
  config.gem 'ruby-openid', :lib => 'openid', :version => '>=2.0.4'
else
  begin
require 'openid'
  rescue LoadError
begin
  gem 'ruby-openid', '>=2.0.4'
rescue Gem::LoadError
  puts "Install the ruby-openid gem to enable OpenID support"
end
  end
end

config.to_prepare do
  ActionController::Base.send :include, OpenIdAuthentication
end

--

But still running rake gives:

[~/rails/try]# rake
(in /home/mydomain/rails/try)
Missing these required gems:
  ruby-openid  >= 2.0.4

You're running:
  ruby 1.8.6.287 at /usr/bin/ruby
  rubygems 1.3.1 at /home/mydomain/.gem/ruby/1.8, /usr/lib/ruby/gems/1.8

Run `rake gems:install` to install the missing gems.

--

Lots of googling lately but no real hints how to solve it.
As mentioned the funny thing is that I can use openid in the app with no 
problems. The feature works.

Cheers.




-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strange bug in has_and_belongs_to_many

2008-11-07 Thread Marli Ba

Under your Job class you have an association_foreign_key, do you need a 
comparable line under your building class as well?  This will depend on 
what your join table looks like.

Otherwise, I don't see any problems.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Changing routes

2008-11-07 Thread elioncho

Hello,

Well I am working on an app and wanted to make some changes on the
URL's. I have the following:

#---
map.resources :groups do |groups|
groups.resources :events, :member => { :invite => :get }
end
#---

So my events are mapping into:

#---
www.xxx.com/groups/1/events/2
#---

What I want to do now is take out the 'group' from there and only
leave the id. Make it look like this:

#---
www.xxx.com/1/events/2
#---

I tried something like the following and now I have an events_path
route that works.

#---
map.events ':group_id/events', :controller => 'events', :action =>
'index'
#---

My question is: Should I then repeat this same line 5 times to map all
the other actions? That without counting the member actions?

map.events_new 
map.events_create...
...
..

It just seems wrong and tedious. It's there any other way to do this?

Thanks for your attention,

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread Ar Chron


> 
> That way it works. But can you explain me the reason ?
> What's the meaning of the parameter :collection => {:arg => :get} ?
> 
> Every time i create a new action, I have to update the routes.rb file ??

http://api.rubyonrails.org/classes/ActionController/Resources.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread David Trasbo

Davide Spaggiari wrote:

>> That is true, yes.



> So, if i don't specify a method (as we did), the default one would be 
> POST ??
> Or DELETE ??
> Or PUT ??
> 
> Which one ??

Sorry for being a little unclear but this was my point: Rails will NOT 
try to guess which method you want and there is no default. In other 
words, since we don't only use GET now, we have to tell Rails which one 
to use (no matter if it's GET, POST, PUT or DELETE).

map.resources :questions, :collection => {:arg => :get}

In the example above we pass an option called :collection that specifies 
which custom actions that is going to affect a _collection_ of (in your 
case) questions. Then we define one custom action ("arg") that is going 
to use the GET method. See the point? :arg => :get

The collection option accepts a hash with action name as key and method 
name (GET, POST, PUT, DELETE) as value, so there is no default. Also 
remember that if you want to make an action that is only going to affect 
_one_ question you'll want to use the :member option instead, like this:

map.resources :questions, :collection => {:arg => :get}, :member => 
{:affecting_one_question => :get}

Hope that helped. (:
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange dependency error after going Ruby1.8.6, Rails 2.1.0 -> Ruby1.8.7, Rails 2.1.2

2008-11-07 Thread Frederick Cheung



On Nov 7, 6:22 pm, Java <[EMAIL PROTECTED]> wrote:
> Ah, yes, thanks.
>
> I'll try to investigate this a bit further.
> The case you linked to describes a different problem though, it seems.
> In my case the model (Price) and the ApplicationHelper are fairly
> vanilla,
> not loading any fancy external libraries through ways untrackable by
> Rails dependency mechanisms.

You can also confuse the dependency system by using require when you
could/should be using require_dependency.

> That's what's bothering me so much (after all, I got my code running
> by pulling the Price reference out of the helper),
> all this seems to indicate a bug somewhere in the dependency/
> autoreload mechanism.

Hard to say from what I've seen.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Schema and relationships between tables

2008-11-07 Thread Maurício Linhares

When you "belong_to" it means that the foreing key is at your side,
you belong to the question 'cos you wouldn't be able to exist without
it, there's no reason to have a question without a user or an answer.

A has_one means that you have of of that, but you usually don't need
it to exist. it also means that the foreign key lives at the other
side.

Look for weak and strong entities in database design

-
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en)
João Pessoa, PB, +55 83 8867-7208



On Fri, Nov 7, 2008 at 2:51 PM, Shandy Nantz
<[EMAIL PROTECTED]> wrote:
>
> I am trying to allow a user to answer some questions and then save those
> questions but I am unsure if I am getting the layout correct. Here is
> what I have so far:
>
> There is a questions table holding the questions to ask
>
> There is an answers tables which holds the answers to the questions
> asked of a user.
>
> Then there is of course the Users table which hold a variety of user
> info
>
> I figure my migrations would look something like:
>
> Questions: has_many :answers
>
> Answers: belong_to :user, belongs_to :question
>
> User has_many :answers
>
> so my table would look like:
>
> User: id, username, . . .
>
> Questions: id, question
>
> Answer: id, user_id, question_id, answer
>
> Where I am a little confused is if the belongs_to :question should
> rather be a has_one :question and would that change the schema at all?
> Also, can anyone point me to some good online tutorials involving Model
> Relationships, thanks,
>
> -S
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread Davide Spaggiari

> That is true, yes. The RESTful design methodology requires you to define 
> custom actions in your routes file. That is because earlier when we used 
> map.connect ':controller/:action/:id' we always used the GET method - 
> for the destroy, create and update actions.
> 
> Then someone found out that you could make the urls prettier (and 
> respect the RESTful design philosophy) by using other standard HTTP 
> methods like DELETE, POST and PUT. Therefore you have to actually tell 
> Rails what method you'ld like to use, it will not use GET by default. 
> That is actually good. Imagine having half of your custom actions being 
> using the GET method, the other half using the POST, PUT or DELETE 
> method. Then you'ld need to define what method to use for half of them 
> in your routes file (instead of all of them). What a mess... (:

So, if i don't specify a method (as we did), the default one would be 
POST ??
Or DELETE ??
Or PUT ??

Which one ??
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Which is the best attachment plugin for my situation?

2008-11-07 Thread David Trasbo

Jl Smith wrote:

> I'm trying to decide which attachment plugin best suites the needs for
> my project.  I have a model that I want to associate one or many
> attachments to.  The content-type of the attachment will vary as well
> (pdf, jpeg, doc, zip), not just an image type.  Thanks for any help!

I Agree, Paperclip is just great. Ryan Bates made an excellent 
screencast on it. Railscasts #134 "Paperclip" 
(http://railscasts.com/episodes/134-paperclip)
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread David Trasbo

Davide Spaggiari wrote:

>> What's the url that is supposed to be invoking the arg action?
> 
> http://localhost:3000/questions/arg
> 
>> if you want arg as an action for the whole collection, then I'd expect 
>> to see something like
>> 
>> map.resources :questions, :collection => {:arg => :get}
> 
> That way it works. But can you explain me the reason ?
> What's the meaning of the parameter :collection => {:arg => :get} ?
> 
> Every time i create a new action, I have to update the routes.rb file ??

That is true, yes. The RESTful design methodology requires you to define 
custom actions in your routes file. That is because earlier when we used 
map.connect ':controller/:action/:id' we always used the GET method - 
for the destroy, create and update actions.

Then someone found out that you could make the urls prettier (and 
respect the RESTful design philosophy) by using other standard HTTP 
methods like DELETE, POST and PUT. Therefore you have to actually tell 
Rails what method you'ld like to use, it will not use GET by default. 
That is actually good. Imagine having half of your custom actions being 
using the GET method, the other half using the POST, PUT or DELETE 
method. Then you'ld need to define what method to use for half of them 
in your routes file (instead of all of them). What a mess... (:
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Restful AND Pretty Urls

2008-11-07 Thread David Trasbo

Joe Blow wrote:



> But what if I wanted my urls to be pretty like
> 
> Instead of
> 
> http://www.mysite.com/users/
> 
> I want
> 
> http://www.mysite.com/list_all_my_damn_users
> 
> Basically I want the nice little helpers AND pretty urls.

Let me start out by saying that I actually think your "pretty" url is 
uglier than the "ugly" url... (: Anyway, I don't think Rails explicitly 
provides the possibility to completely redefine the look and feel of 
urls (unless you'ld use map.connect manually that doesn't provide any 
helper methods), but you can rid of the id's by using the to_param 
method in your ActiveRecord models as described in Railscasts #63 "Model 
Name in URL" (http://railscasts.com/episodes/63-model-name-in-url).

Hope that helps...
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: one db - many rails projects -> many schema_migrations table

2008-11-07 Thread Jf Rejza


> 
> poking round the source I see:
> 
>   def schema_migrations_table_name
> Base.table_name_prefix + 'schema_migrations' +
> Base.table_name_suffix
>   end

I need to over write this method only for one app not for all.
Is it possible to do so into the app? If so where to over_write the 
code?



> Have you tried just having multiple migrations and just letting the
> migration code work it out for itself? Rails should handle
> intermediate migrations with timestamps (I think!)


you mean the mean the timestamps that prefixe the migrations file?
I replace it by an integer.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Restful AND Pretty Urls

2008-11-07 Thread Joe Blow

Is there anyway to have restful AND pretty urls?

For example:

map.resources :users

Would give us nice little helpers
users_url
new_user_url
edit_user_url(@user)

etc.

But what if I wanted my urls to be pretty like

Instead of

http://www.mysite.com/users/

I want

http://www.mysite.com/list_all_my_damn_users

Basically I want the nice little helpers AND pretty urls.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread Davide Spaggiari

> What's the url that is supposed to be invoking the arg action?

http://localhost:3000/questions/arg

> if you want arg as an action for the whole collection, then I'd expect 
> to see something like
> 
> map.resources :questions, :collection => {:arg => :get}

That way it works. But can you explain me the reason ?
What's the meaning of the parameter :collection => {:arg => :get} ?

Every time i create a new action, I have to update the routes.rb file ??
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] please unsubscribe me

2008-11-07 Thread David Gutierrez C.
the " [EMAIL PROTECTED]"  mail is not  
working for me, there are another way to unsubscribe me?

thnx!



David Gutiérrez C.
Danilo Black : WebMedia
[EMAIL PROTECTED]
tel. +52 (81) 8173 7053


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Strange dependency error after going Ruby1.8.6, Rails 2.1.0 -> Ruby1.8.7, Rails 2.1.2

2008-11-07 Thread Java

Ah, yes, thanks.

I'll try to investigate this a bit further.
The case you linked to describes a different problem though, it seems.
In my case the model (Price) and the ApplicationHelper are fairly
vanilla,
not loading any fancy external libraries through ways untrackable by
Rails dependency mechanisms.
That's what's bothering me so much (after all, I got my code running
by pulling the Price reference out of the helper),
all this seems to indicate a bug somewhere in the dependency/
autoreload mechanism.

Jan
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller Problem

2008-11-07 Thread Ar Chron


> The error is: "Couldn't find Question with ID=arg"

What's the url that is supposed to be invoking the arg action?

What do your routes look like?

rake routes >routes.lst

then browse that file to see the routes that are available

it seems that 'arg' is being interpreted as an id parameter for an 
existing route...

if you want arg as an action for the whole collection, then I'd expect 
to see something like

map.resources :questions, :collection => {:arg => :get}

in routes.rb to add that as a recognized route

If it's for a specific question, then

map.resources :questions, :member => {:arg => :get}
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: one db - many rails projects -> many schema_migrations table

2008-11-07 Thread Allan

Hi,

poking round the source I see:

  def schema_migrations_table_name
Base.table_name_prefix + 'schema_migrations' +
Base.table_name_suffix
  end

in activerecord-2.1.0/lib/active_record/migration.rb

I suppose you could override this method in that class and then call
initialize_schema_migrations_table.

Have you tried just having multiple migrations and just letting the
migration code work it out for itself? Rails should handle
intermediate migrations with timestamps (I think!)

Allan
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Which is the best attachment plugin for my situation?

2008-11-07 Thread blasterpal

I think paperclip is SOOO much easier to work with than attachment_fu.
But if things get more complicated attachment_fu is very good too.

H

On Nov 7, 11:32 am, "Benjamin Curtis" <[EMAIL PROTECTED]>
wrote:
> Either paperclip or attachment_fu will serve you well.
> --
> Benjamin Curtishttp://railskits.com/- Ready-made Rails 
> codehttp://catchthebest.com/- Team-powered 
> recruitinghttp://www.bencurtis.com/- Personal blog
>
> On Wed, Nov 5, 2008 at 1:23 PM, JL Smith <[EMAIL PROTECTED]> wrote:
>
> > I'm trying to decide which attachment plugin best suites the needs for
> > my project.  I have a model that I want to associate one or many
> > attachments to.  The content-type of the attachment will vary as well
> > (pdf, jpeg, doc, zip), not just an image type.  Thanks for any help!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Schema and relationships between tables

2008-11-07 Thread Shandy Nantz

I am trying to allow a user to answer some questions and then save those
questions but I am unsure if I am getting the layout correct. Here is
what I have so far:

There is a questions table holding the questions to ask

There is an answers tables which holds the answers to the questions
asked of a user.

Then there is of course the Users table which hold a variety of user
info

I figure my migrations would look something like:

Questions: has_many :answers

Answers: belong_to :user, belongs_to :question

User has_many :answers

so my table would look like:

User: id, username, . . .

Questions: id, question

Answer: id, user_id, question_id, answer

Where I am a little confused is if the belongs_to :question should
rather be a has_one :question and would that change the schema at all?
Also, can anyone point me to some good online tutorials involving Model
Relationships, thanks,

-S
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Webservice with Ruby

2008-11-07 Thread blasterpal

http://www.texperts.com/2007/12/21/using-action-web-service-with-rails-20/

On Nov 7, 12:23 pm, Kittu <[EMAIL PROTECTED]> wrote:
> Right now we are using java based webservices and want to move them to
> ruby on rails webservice. I did not find any ActionWebservice package
> under gems folder.
>
> I appreciate if anyone can help me to find examples on SOAP based
> webservice with ruby.
>
> Ruby version: 1.8.7
>
> Thanks
>   Krishna
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Error: A copy of ApplicationHelper has been removed from...

2008-11-07 Thread Ben Knight

Hello.

I just started getting this error but can't figure out what I did in the
past day that might be causing this:
"A copy of ApplicationHelper has been removed from the module tree but
is still active!"

Apparently, there are others that have seen this -- gathering from a
google search -- but I can't find any solution.

Has anyone seen this?  Here is what I've done recently:
1. Added ssl plugin
2. Added a couple authorize.net ruby code to my lib/ dir:
http://developer.authorize.net/samplecode/


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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Webservice with Ruby

2008-11-07 Thread Kittu


Right now we are using java based webservices and want to move them to
ruby on rails webservice. I did not find any ActionWebservice package
under gems folder.

I appreciate if anyone can help me to find examples on SOAP based
webservice with ruby.

Ruby version: 1.8.7


Thanks
  Krishna

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: RJS show as 'try...' in AJAX update

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 17:18, Xin Zheng wrote:

>
> Hi guys,
>
> I am trying to display Javascript code after an Ajax call. It is
> executing the JS code, but it's also displaying it. It shows as:
>
> try {
> alert(...);
> } catch ..
> ...
>
> my controller code:
>
> render :update do |page|
>  page.alert message_var
> end
>
> my Javascript code:
>  new Ajax.Updater("div_id", my_controller_url,
> {  asynchronous: true,
>evalScripts:  true,
>method:   'get',
>parameters:   query_string
>  }
>  );
>
> In the prototype documentation, it says AJax.Updater's evalScripts  
> will
> eval anything in 

[Rails] RJS show as 'try...' in AJAX update

2008-11-07 Thread Xin Zheng

Hi guys,

I am trying to display Javascript code after an Ajax call. It is
executing the JS code, but it's also displaying it. It shows as:

try {
alert(...);
} catch ..
...

my controller code:

render :update do |page|
  page.alert message_var
end

my Javascript code:
  new Ajax.Updater("div_id", my_controller_url,
 {  asynchronous: true,
evalScripts:  true,
method:   'get',
parameters:   query_string
  }
  );

In the prototype documentation, it says AJax.Updater's evalScripts will
eval anything in 

[Rails] Re: the page does not load

2008-11-07 Thread Delirium tremens

I think I have to edit the user_ids for the stories, but how can I do
that?

On Nov 7, 2:42 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On 7 Nov 2008, at 16:38, Delirium tremens wrote:
>
>
>
> > I am trying to load an upcoming stories page for a Digg clone, but I
> > am getting an error message.http://pastie.org/309612How to correct
> > the error?
>
> story.user was nil and you tried to do something with it. Why that is  
> only you can say.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Controller Problem

2008-11-07 Thread Davide Spaggiari

I have this action in questions_controller.rb :

def arg
  @questions = Question.find(:all)

  respond_to do |format|
format.html
format.xml  { render :xml => @questions }
  end
end

Why this action doesn't work ?
It is the same as index action, but this one doesn't work.
The error is: "Couldn't find Question with ID=arg"
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Create 50 objects and show only them

2008-11-07 Thread Medwedj Potapow

I solved the problem myself!

The point is: while creating Istored all the object in an array. After 
saving I did:

respond_to do |format|
  format.html { render :action => 'last_created' }
end

An in the view "last_created" I go over the entire array and show all 
the objects in a table.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Ben Knight

Thanks again!

Frederick Cheung wrote:
> On 7 Nov 2008, at 15:09, Ben Knight wrote:
> 
>>
>> PS.  I'm wondering if Rails.cache is better or Memcache. Thanks again.
> 
> That's sort of a non question - Rails.cache can be backed by several
> different stores, one of which is memcache.
> 
> Fred

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: the page does not load

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 16:38, Delirium tremens wrote:

>
> I am trying to load an upcoming stories page for a Digg clone, but I
> am getting an error message. http://pastie.org/309612 How to correct
> the error?

story.user was nil and you tried to do something with it. Why that is  
only you can say.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] the page does not load

2008-11-07 Thread Delirium tremens

I am trying to load an upcoming stories page for a Digg clone, but I
am getting an error message. http://pastie.org/309612 How to correct
the error?
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Which is the best attachment plugin for my situation?

2008-11-07 Thread Benjamin Curtis
Either paperclip or attachment_fu will serve you well.
--
Benjamin Curtis
http://railskits.com/ - Ready-made Rails code
http://catchthebest.com/ - Team-powered recruiting
http://www.bencurtis.com/ - Personal blog


On Wed, Nov 5, 2008 at 1:23 PM, JL Smith <[EMAIL PROTECTED]> wrote:

>
> I'm trying to decide which attachment plugin best suites the needs for
> my project.  I have a model that I want to associate one or many
> attachments to.  The content-type of the attachment will vary as well
> (pdf, jpeg, doc, zip), not just an image type.  Thanks for any help!
>

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



[Rails] strange bug in has_and_belongs_to_many

2008-11-07 Thread Rey9999

Hello everyone.

I have two Classes, linked by a HABTM relationship.

class Building < ActiveRecord::Base
  set_table_name 'gc_edifici_attivita'
  has_and_belongs_to_many :jobs, :join_table =>
'gc_edificio_avvio_commessa', :foreign_key =>
'edificio_attivita_gc_id', :class_name => 'Job'

end


class Job < ActiveRecord::Base
  set_table_name 'gc_avvio_commessa'

  has_and_belongs_to_many :buildings, :join_table
=>'gc_edificio_avvio_commessa', :foreign_key =>
'commessa_id', :class_name => 'Building', :association_foreign_key =>
'edificio_attivita_gc_id'
  end

Ok, table names are in Italian.. that's because I had to use a legacy
database and could not change the tables' names.

Now, for each Job, I have to list all the Buildings related to it. So
it goes like this:

@jobs = Job.all

@jobs.each do |job|
job.buildings [... do something with the buildings...]
end

Everything goes well so far. But sometimes, I have to list only the
Jobs happening on a given Building, yielding:

@jobs = Building.find(params[:building]).jobs
@jobs.each do |job|
job.buildings [... do something with the buildings...]
end

This won't work anymore; Rails keeps telling me there's no such method
as 'buildings' for class 'Job'. it's almost as if collecting the Jobs
from a Building through HABTM, Rails cannot 'see' what methods are in
class Job.

Any ideas about this? Is there a bug in Rails, or is this supposed to
happen?
Thanks in advance to anyone who might help me.

Regards,
Rey
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 bug in include on has_many?

2008-11-07 Thread Jonathan Rochkind

Thanks a lot Chris. Sadly, I've got my work cut out for me, as changing 
the name of the model in this fairly mature application is going to be 
some work. But at least it all makes some sense now.

Is it possible to change the model name without changing the name of the 
_associations_ that point to it in other models?  Or, I guess, to alias 
the association name 'request' to an 'actual' association named 
service_request or whatever. To give me less code that has to be 
changed? Any advice as to the lowest impact way to change a model name 
in a mature application with lots of code that refers to that model, and 
to associations in other models that point to that model?

Odd that I got away with it in Rails 1.x, but oh well, I guess it was 
really incorrect all along.

Jonathan

Chris Bartlett wrote:
> Jonathan is probably right. 'Request' is a reserved word in Rails -
> see http://wiki.rubyonrails.org/rails/pages/ReservedWords
> 
> Try changing the model name to ServiceRequest or similar.
> 
> On Nov 7, 6:43�am, Jonathan Rochkind <[EMAIL PROTECTED]

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 15:09, Ben Knight wrote:

>
> PS.  I'm wondering if Rails.cache is better or Memcache. Thanks again.

That's sort of a non question - Rails.cache can be backed by several  
different stores, one of which is memcache.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Ben Knight

PS.  I'm wondering if Rails.cache is better or Memcache. 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 15:00, Ben Knight wrote:

>
> Thanks, Fred.
>
> Has anyone used Rails.cache.write / read?  I wonder how good of a
> solution that is.
>
I haven't used it, but it is a different beast. It is something that  
is shared across all the processes in your cluster, so it's doing more  
which implies that it will have more overhead then just reading an  
instance variable out of something. It also uses Marshal.dump to dump  
the objects it stores which can introduces some complexities)

Fred
> -- 
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Ben Knight

Thanks, Fred.

Has anyone used Rails.cache.write / read?  I wonder how good of a 
solution that is.

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: one db - many rails projects -> many schema_migrations table

2008-11-07 Thread Jf Rejza

Florian Schaf wrote:
I have the same problem.
Did a find a solution?

JEF

-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: database documentation

2008-11-07 Thread Harold

Along the same lines as Fred suggests, it should be on the model.
We've been using the annotate_models to do it for us.

http://agilewebdevelopment.com/plugins/annotate_models

-H

On Nov 7, 5:17 am, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On 7 Nov 2008, at 01:30, Norm wrote:
>
>
>
> > Fernando wrote:
> >> so far i havent been able to find a way to document my database with
> >> rails.
> >> is this a flaw? a feature? a hidden feature? or they just dont care
> >> about documenting the database?
> > You could just put comments in your migrations.  They are ruby code.
>
> That's not that great, for example a table's structure can be the  
> accretion of multiple migrations.
> The rails way is probably just to keep that sort of stuff in the  
> appropriate model (and since the rails way is not to use things like  
> triggers and what not, the model encapsulates pretty much all the  
> intelligence in the app).
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Sending SMS Messages From Your Rails Application Usng Clickatell GEM

2008-11-07 Thread Walter Lockhart

Hi Group,

I have just read and attempted to implement Luke Redpath's example:

http://www.lukeredpath.co.uk/2007/8/29/sending-sms-messages-from-your-rails-application

Unfortunately, I can't get it to work.

I signed up for a Clickatell Account.

I installed the Clickatell GEM.

The following paragraphs describe my app.

# controllers/sms.rb:
require 'clickatell'

class SMS

  def initialize(config)
@config = config
  end

  def create(recipient, message_text)
api.send_message(recipient, message_text)
  end

  private

def api
  @api ||= Clickatell::API.authenticate(
@config[:api_key],
@config[:username],
@config[:password])
end

end

# config/clickatell.yml:
api_key: 999
username: abcdefg
password: hijklmno

# config/environments/development.rb
CLICKATELL_CONFIG = YAML.load(File.open(File.join(RAILS_ROOT,
'config', 'clickatell.yml')))

# config/routes.rb:
ActionController::Routing::Routes.draw do |map|
  map.resource :sms
end

# app/views/sms/new.html.erb:
<% form_tag '/sms', :method => :post do -%>
  Enter the recipients mobile number:
  <%= text_field_tag "recipient" %>
  Enter your message:
  <%= text_area_tag "message_text" %>
  <%= submit_tag "Send SMS" %>
<% end %>

# controllers/sms_controller.rb:
class SmsController < ApplicationController
def create
  sms = SMS.new(CLICKATELL_CONFIG)
  sms.create(params[:recipient], params[:message_text])
  flash[:notice] = "Message sent succesfully!"
  redirect_to :back
rescue Clickatell::API::Error => e
  flash[:error] = "Clickatell API error: #{e.message}"
  redirect_to :back
end
end

Hopefully, just like its described in the article.

I run the app and browse to: http://localhost:3000/sms/new

I enter the mobile no.: 4478 (I'm in the UK).

I enter the Message and click 'Send SMS'.

The app executes without an error, but no SMS is sent.  My Clickatell
credits are not decremented.

Any ideas on where I'm going wrong?  Has anyone managed to get this to
work using the Clickatell GEM?

Thanks in advance.

Any help would be greatly appreciated.

Kind Regards

Walter

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



[Rails] Validations on array checkbox in Model

2008-11-07 Thread babar
Hi,

I am using array 'sub_id[]' for multiple checkbox,
i want to place validations on all array 'sub_ids[]' checbox in model just
like other validations.



 <% for e in @subjects do -%>
   checked="checked"<%end%>>
  <%= e.name %>
 <% end %>



MODEL

class Book < ActiveRecord::Base
has_and_belongs_to_many :subjects
 validates_presence_of:title
validates_numericality_of:price
validate :at_least_one_checkbox_was_ticked

protected
def at_least_one_checkbox_was_ticked
unless params[:sub_ids[]].nil?
end
  end

  end


I'm using only two models book and subject.

thanx in adv.

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validations on array checkbox in Model

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 12:50, babar wrote:

> Hi,
>
> I am using array 'sub_id[]' for multiple checkbox,
> i want to place validations on all array 'sub_ids[]' checbox in  
> model just like other validations.
>
>
>
>  <% for e in @subjects do -%>
>checked="checked"<%end 
> %>>
>   <%= e.name %>
>  <% end %>
>
>
>
> MODEL
>
> class Book < ActiveRecord::Base
> has_and_belongs_to_many :subjects
>  validates_presence_of:title
> validates_numericality_of:price
> validate :at_least_one_checkbox_was_ticked
>
> protected
> def at_least_one_checkbox_was_ticked
> unless params[:sub_ids[]].nil?
> end
>   end


That's not how you could do it. You don't validate against  
params[:sub_ids], you validate against a property of the model (ie  
subjects.size)

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Validation on array checkbox in Model

2008-11-07 Thread babar
Hi,

I am using array 'sub_id[]' for multiple checkbox,
i want to place validations on all array 'sub_ids[]' checbox in model just
like other validations.



 <% for e in @subjects do -%>
   checked="checked"<%end%>>
  <%= e.name %>
 <% end %>



MODEL

class Book < ActiveRecord::Base
has_and_belongs_to_many :subjects
 validates_presence_of:title
validates_numericality_of:price
validate :at_least_one_checkbox_was_ticked

protected
def at_least_one_checkbox_was_ticked
unless params[:sub_ids[]].nil?
end
  end

  end


I'm using only two models book and subject.

thanx in adv.

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Add message to model validation errors

2008-11-07 Thread Erik Dahlstrand

Hi!

I'm using CAPTCHA plugin (http://github.com/zendesk/captcha/tree).
When CAPTCHA validation fails the error message is added to
flash["error"].

How can I add the CAPTCHA error message to the model validation
messages? Also I would like the CAPTCHA text field to be wrapped in
.

TIA!
/Erik
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Insert key/value pair into hash, then read it out

2008-11-07 Thread Tom Ha

Great, thanks a lot!
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Insert key/value pair into hash, then read it out

2008-11-07 Thread George Bailey


On Nov 7, 2008, at 5:48 AM, Tom Ha wrote:

>
> Thanks, Mikel. We're half way there, I guess:
>
>> No, book is a class, I assume at least.
>>
>> Probably in your models directory you have a book.rb file that has
>>
>> class Book < ActiveRecord::Base
>> 
>> end
>
> Yes, that's the case.
>
>> You probably want a column called number_of_pages in your books table
>>
>> Then you can do:
>> book.number_of_pages = 123
>> book.number_of_pages #=> 123
>
> Not really. Actually, I don't want to store the "number_of_pages" in a
> database, I'd just lik to add it "on the fly" to each "book" to be  
> able
> to display it in the view, for each "book".
>
> Is this possible in my case?



If you add these to the class:

def calc_number_of_pages
   @page_count = (your code to determine page count)
end

def number_of_pages
   @page_count
end


Then you can do:

@books.each do |book|
  book.calc_number_of_pages
end

Then in your view you can have

<%= book.number_of_pages %>

and it will do what you've described.



--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Insert key/value pair into hash, then read it out

2008-11-07 Thread Tom Ha

Thanks, Mikel. We're half way there, I guess:

> No, book is a class, I assume at least.
> 
> Probably in your models directory you have a book.rb file that has
> 
> class Book < ActiveRecord::Base
> 
> end

Yes, that's the case.

> You probably want a column called number_of_pages in your books table
> 
> Then you can do:
> book.number_of_pages = 123
> book.number_of_pages #=> 123

Not really. Actually, I don't want to store the "number_of_pages" in a 
database, I'd just lik to add it "on the fly" to each "book" to be able 
to display it in the view, for each "book".

Is this possible in my case?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: SQL question

2008-11-07 Thread Phillip Koebbe

Damjan Rems wrote:
> 
> In the mean time I have found that this:
> 
> select id from docs where title || body like '%en%'
> 
> works on PG3.3, sqlite3, Oracle 10. But of course not on MS-SQL2005.
> 

Right. SQL Server's string concatenation operator is +. I got tripped up 
on that a number of times when I started working with Postgres. If this 
really must be portable to most/all of the databases supported by Rails, 
you should avoid raw SQL completely. This will be the beginning of many 
frustrations for you. Unfortunately, that does mean that some things you 
could have done faster in raw SQL will now take a bit longer because you 
have to use Ruby constructs, but you will gain the portability.

Peace.
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to overwrite a method?

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 11:15, Scott A S wrote:

>
> Hi,
>
> The following file within rails
> /activeresource/lib/active_resource/formats/xml_format.rb
>
> Has the method
> def extension
>   "xml"
> end
>
> How can I overwrite this so that it returns PHP without editing any  
> core
> file?
>
just reopen that class
class WhateverItIs
   def extension
 "php"
   end
end

> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] How to overwrite a method?

2008-11-07 Thread Scott A S

Hi,

The following file within rails
/activeresource/lib/active_resource/formats/xml_format.rb

Has the method
def extension
   "xml"
end

How can I overwrite this so that it returns PHP without editing any core
file?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Attachment_fu Validation Error

2008-11-07 Thread Andi Geheim

Hi there!

I am trying to get attachment_fu to work. It is so good as done, just
one strange error is still there.

this is my model:



class Motorbike < ActiveRecord::Base

  has_attachment :content_type => :image,
 :storage => :file_system,
 :max_size => 500.kilobytes,
 :resize_to => '800x600>',
 :thumbnails => { :thumb => '100x100>' }

  validates_as_attachment

  validates_presence_of :brand

end



If there is an other validation instead of the attachment_fu the model
pop up this error:

ActiveRecord::RecordInvalid in MotorbikesController#create
Validation failed: Brand can't be blank

If there is only the attachment_fu validation, everything works great.

What could be the reason or is there a good way around?

Greenting Chaos
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.1.2 bug in include on has_many?

2008-11-07 Thread Chris Bartlett

Jonathan is probably right. 'Request' is a reserved word in Rails -
see http://wiki.rubyonrails.org/rails/pages/ReservedWords

Try changing the model name to ServiceRequest or similar.

On Nov 7, 6:43 am, Jonathan Rochkind <[EMAIL PROTECTED]
s.net> wrote:
> Hmm, is it possible that the fact that the model is named "Request" is
> somehow triggering the bug? That's the only thing I can figure out.
>
> Jonathan
>
>
>
> Jonathan Rochkind wrote:
> > Frederick Cheung wrote:
> >> On 6 Nov 2008, at 16:39, Jonathan Rochkind wrote:
>
> >>> [...]
>
> >>> There's no reason this wouldn't be supported in Rails 2.1.2, is there?
>
> >> It should work. :include was rewritten for rails 2.1 though.
> >> service_type has a belongs_to :service_response ?
>
> >> Fred
>
> > It sure does.
>
> > This is annoying me highly. I've pared down my code to a simple
> > reproducible test case. And it's still exhibiting. i can't figure out
> > what I'm doing to trigger the bug, if everyone else is using :has_many,
> > :include without problems. Very frustrating.
>
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Insert key/value pair into hash, then read it out

2008-11-07 Thread Mikel Lindsaar
On Fri, Nov 7, 2008 at 7:28 AM, Tom Ha <[EMAIL PROTECTED]>wrote:

> @books: array of books
>  @books.each do |book|
>  do stuff...
>  do stuff...
>  do stuff...
>  book["number_of_pages"] = 123   #this is supposed to "inject" the
> key/value pair
> end




> -> "inject" the key 'number_of_pages' with the value '123' into the hash
> "book" ("book" IS a hash, right?), for every book in @books


No, book is a class, I assume at least.

Probably in your models directory you have a book.rb file that has

class Book < ActiveRecord::Base

end

-> Then, show in the view: All "Number of pages":  <%= @books.collect
> {|b| [b.number_of_pages] } %>
>
> It doesn't work like this... (-> "undefined method `number_of_pages' for
> #")
>

You probably want a column called number_of_pages in your books table

Then you can do:
book.number_of_pages = 123
book.number_of_pages #=> 123

Hope that helps

Mikel

-- 
http://lindsaar.net/
Rails, RSpec and Life blog

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Insert key/value pair into hash, then read it out

2008-11-07 Thread Tom Ha

... anybody ... ?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: database documentation

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 01:30, Norm wrote:

>
> Fernando wrote:
>> so far i havent been able to find a way to document my database with
>> rails.
>> is this a flaw? a feature? a hidden feature? or they just dont care
>> about documenting the database?
> You could just put comments in your migrations.  They are ruby code.
>
That's not that great, for example a table's structure can be the  
accretion of multiple migrations.
The rails way is probably just to keep that sort of stuff in the  
appropriate model (and since the rails way is not to use things like  
triggers and what not, the model encapsulates pretty much all the  
intelligence in the app).

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: [ANN] ActiveRecord :select with :include gem

2008-11-07 Thread Fernando Perez

Paolo Negri wrote:
> I'm writing to announce the first release of select_with_include gem.
> 
> This gem allows the use of the :select option together with
> the :include in the #find ActiveRecord method.
> 
> In the current ActiveRecord version if a #find has the :include option
> specified the :select will be ignored returning always all the fields
> of every single table; select_with_include modifies this behavior
> providing a limited support of the :select option.
> Depending by the number of the columns in your tables and the depth of
> your associations select_with_include can really improve the
> performance in terms of speed and memory usage of ActiveRecord
> 
> The gem can be installed with the usual
> 
> gem install select_with_include
> 
> more details are provided at
> 
> http://assertbuggy.blogspot.com/2007/05/activerecord-select-with-include.html

Did you stop developing the gem? Is it compatible with Rails 2.x?

Anyone suing it? Are there real benefits?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] New on Ruby on Rails setup problem

2008-11-07 Thread fabiocmc

Hi there I'm new here and I've just installed the Instant Rails
package, and I'm getting this error message: "Either Apache or MySql
cannot run because another program is using it's port".

What should I do?

Thanks,

Fábio Carneiro

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: SQL question

2008-11-07 Thread Damjan Rems

Pau Cor wrote:
> This isn't exactly the same, but it might be good enough for you:
> 
> select id from docs where title like '%en%' or body like '%en%'
> 
> There is an SQL validator here: 
> http://developer.mimer.com/validator/parser200x/index.tml

Of course. Sometimes you just have to break the problem into smaller 
peaces. Althow I will have to do some research about performance (>> 
1 records). It should even be faster if string is found in title.

Thank you also Phillip. There is so much I have to learn about AR.

In the mean time I have found that this:

select id from docs where title || body like '%en%'

works on PG3.3, sqlite3, Oracle 10. But of course not on MS-SQL2005.


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

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



[Rails] recursive problem

2008-11-07 Thread Eqbal Quran

Hi everybody,
I was trying to create a rake task to import geo data by accessing
geonmae API's xml data , I wanna create a list of countries , cities ,
sub cities that r related to each other through nested list , anyways, I
have a problem with the recursion i made , i didn't get it , I'll list
the code hopefully i will get some help from any expert here around ,
Any help will b highly appreciated .

--
require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"
conf = YAML::load(File.open(File.dirname(__FILE__) +
'/../config/database.yml'))
ActiveRecord::Base.establish_connection(conf['development'])


module Geonames

@@langs={}
Language.all.each{|Lan| @@langs[Lan.iso_639_1] = Lan.id}
@@continent = {'AF' => 6255146}#, 'AS' => 6255147, 'EU' =>
6255148, 'NA' => 6255149 , 'OC' => 6255151,'SA' => 6255150,'AN' =>
6255152}

def self.import
   puts "lets start the game"
   self.import_continents
   self.import_countries_and_sub
end


def self.import_continents
  puts '*** add globe to tables'
  self.add_new_tag({:tag_type =>1,:status => 0, :user_id =>
66},{:content => 'Globe', :language =>@@langs['en'], :primary =>
true},{})

  puts '*** add continent  tables'
  @@continent.each_key{|x,y| self.add_new_tag({:tag_type
=>1,:status => 0, :user_id => 66, :sub_type =>0},{:content => x,
:language =>@@langs['en'], :primary =>true}, {:parent_id =>
Region.find_by_word_name('Globe').id} )}
end



def self.import_countries_and_sub

@@continent.each do |cont_name,cont_geo_id|
   puts "importing countiries in #{cont_name} continents"
   @@cont_id = Region.find_by_name(cont_name)
   self.do_nasty_stuff(cont_geo_id, @@cont_id, 1)
end

end



 def self.add_new_tag(tag_options={}, word_options={},
region_options={}, alt={})
# not gonna list all the code since u don't have all the time to
read it :) anyways this function for adding the geo as a tag and save it
with different language and different spelling as non primary words for
this tag

end

def self.do_nasty_stuff(geo_id, prt_id, sub_type)
  # the xml data of that data given by geo id number
  @@baba_xml =
Hpricot.parse(open("http://ws.geonames.org/children?geonameId=#{geo_id}&style=full";))
  p "*** importing xml of #{geo_id}
*"

 (@@baba_xml/:geoname).each do |thing|

lat = CGI.escapeHTML(thing.at(:lat).children.first.to_s)
lng = CGI.escapeHTML(thing.at(:lng).children.first.to_s)

# add the main country
extra_info = {:lat => lat, :lng => lng }

# add the sub alternative names as non primary words
alt_hash = Hash.new
thing.search(:alternatename).each do |alt|
  alt_hash[alt.children.first.to_s] =
@@langs[alt[:lang]]
end

# forget about the parameters here , it has nothing with
the problem
self.add_new_tag({:tag_type =>1,:status => 0, :user_id
=> 66, :sub_type =>sub_type},{:content => name, :language
=>@@langs['en'], :primary =>true}, {:parent_id => prt_id, :data =>
extra_info} ,alt_hash)
# HERE IS WHERE I NEED UR HELP
if  ((sub_type.to_i < 3))
  prt_id = Region.find_by_word_name(name)
  geo_id =
CGI.escapeHTML(thing.at(:geonameid).children.first.to_s)
  p " do nasty stuff #{geo_id} #{prt_id} , #{sub_type}"
  self.do_nasty_stuff(geo_id, prt_id, sub_type + 1)
end

 end

  end


end

--
in do_nasty_stuff -> if  ((sub_type.to_i < 2)) , I don't know why but
the returning data is not accurate , as 4 example , in Africa , the
first loop in working perfectly but then it will list Angola for example
as child of the previous country (algeria) ...


Thnx
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: set whether the mail is read or not

2008-11-07 Thread Thorsten Müller


> when a user read a mail i want to set the
> read_or_not variable true,,,

What kind of mail? Something internal of your application?
Or "real" email, that you send to them? You don't get a reply
for emails, at least not in a very reliable manner.
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Adding methods to an array of AR objects

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 10:14, Max Williams wrote:

>
> I have some methods that i want to be able to call on any collection  
> of
> ActiveRecord objects.  What's the 'right' way to set this up?  I don't
> want to just monkey patch Array as it's specific to an AR array.

If you extend AssociationCollection you'll be able to it on any  
association (eg some_object.customers.foo). There is no proxy object  
for the result of Foo.find though (I have an experimental plugin that  
does do this). You could wrap the result of finds in a proxy (as i  
did) or you could add singleton methods to the results of find
(ie

class << ActiveRecord::Base
   def find_with_extra_methods(*args)
 results = find_without_extra_methods(*args)
 results.extend(SomeModuleOfExtraMethods) if results.is_a? Array
 results
   end

   alias_method_chain :find, extra_methods
end

>
>
> Thanks
> max
> -- 
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Different renders on main page...

2008-11-07 Thread Thorsten Müller

Just as you say. Nothing special about requesting data from lots of
different
or unrelated models for such usage.

In the controller get the data like:

@new_users = User.find(:all, :conditions => *whatever means new*)
@new_news = News.find(:all, :conditions => ...)

In the view it's a matter of taste if you write a different partial
for each box or not. I would most likely do it, or reuse some other
partials for displaying users or new, that are already written.
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validating email

2008-11-07 Thread Sijo Kg

Hi
Thanks for the reply..But when i tried from script/console reslut 
was like

TMail::Address.parse('[EMAIL PROTECTED]@')
=> #
>> TMail::Address.parse('[EMAIL PROTECTED]@@')
=> #

 Why this happens?

Sijo
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails requires RubyGems >= 1.1.1 : problem

2008-11-07 Thread Thomas Balthazar
Hello,
On my local machine (Mac OS X 10.5.5), I get the following error when I try
to run script/server start :
"Rails requires RubyGems >= 1.1.1 (you have 1.0.1). Please `gem update
--system` and try again."

The Rails app was a former 1.2.6 upgraded to 2.1, and it worked fine.
I've run the rake rails:update command.

If I create a new Rails app, it starts with the command script/server start
without complaining.

I've run :
sudo gem update --system
Updating RubyGems
Nothing to update

Some infos :
* gem -v
1.3.1
* which gem
/usr/local/bin/gem
* ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin9.5.1]
* which ruby
/usr/local/bin/ruby
* rails -v
Rails 2.1.2
* which rails
/usr/local/bin/rails
* gem list
*** LOCAL GEMS ***

actionmailer (2.1.2, 2.1.0, 1.3.6)
actionpack (2.1.2, 2.1.0, 1.13.6)
actionwebservice (1.2.6)
 activerecord (2.1.2, 2.1.0, 1.15.6)
activeresource (2.1.2, 2.1.0)
activesupport (2.1.2, 2.1.0, 1.4.4)
capistrano (2.5.0)
cgi_multipart_eof_fix (2.5.0)
daemons (1.0.10)
fastthread (1.0.1)
gem_plugin (0.2.3)
highline (1.4.0)
mongrel (1.1.5)
mysql (2.7)
net-scp (1.0.1)
net-sftp (2.0.1)
net-ssh (2.0.4)
net-ssh-gateway (1.0.0)
rails (2.1.2, 2.1.0, 1.2.6)
rake (0.8.3)
rubygems-update (1.3.1)

Any idea?
Thanks in advance for your help.

Best,
Thomas.

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Adding methods to an array of AR objects

2008-11-07 Thread Max Williams

I have some methods that i want to be able to call on any collection of
ActiveRecord objects.  What's the 'right' way to set this up?  I don't
want to just monkey patch Array as it's specific to an AR array.

Thanks
max
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validating email

2008-11-07 Thread Mikel Lindsaar
On Fri, Nov 7, 2008 at 8:39 PM, Sijo Kg <[EMAIL PROTECTED]>
 wrote:

>
> Hi
>   This is not the required solution Suppose the user enters
> [EMAIL PROTECTED]@@ or [EMAIL PROTECTED]@ what happens?  Since we  cant 
> insists
> that there should be value after @  or @@


Use tmail to validate your email :)
It will raise an exception on basically anything except a correct address.

And I would recommend not using an '@' symbol to symbolize anything in an
email address. It is the key component that separates the local from the
domain part of the email address and you will always run into problems.

You can see how here:

http://www.lindsaar.net/2008/4/14/tip-4-detecting-a-valid-email-address

>> require 'tmail'
=> true
>> TMail::Address.parse('[EMAIL PROTECTED]@@')
TMail::SyntaxError: parse error on token "@"
from parser.y:379:in `on_error'
from (irb):2:in `_racc_yyparse_c'
from parser.y:375:in `scan'
from parser.y:375:in `parse_in'
from racc/parser.rb:152:in `_racc_yyparse_c'
from racc/parser.rb:152:in `__send__'
from racc/parser.rb:152:in `yyparse'
from parser.y:366:in `parse'
from parser.y:344:in `parse'
from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in
`parse'
from (irb):2
>> TMail::Address.parse('[EMAIL PROTECTED]@')
TMail::SyntaxError: parse error on token "@"
from parser.y:379:in `on_error'
from (irb):3:in `_racc_yyparse_c'
from parser.y:375:in `scan'
from parser.y:375:in `parse_in'
from racc/parser.rb:152:in `_racc_yyparse_c'
from racc/parser.rb:152:in `__send__'
from racc/parser.rb:152:in `yyparse'
from parser.y:366:in `parse'
from parser.y:344:in `parse'
from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in
`parse'
from (irb):3
>> TMail::Address.parse('[EMAIL PROTECTED]')
=> #


-- 
http://lindsaar.net/
Rails, RSpec and Life blog

--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Still undefined pagination

2008-11-07 Thread Hammer Ting

Just realized I did managed to install will_paginate already, using the
gem install method. Didn't realize earlier as i kept looking at the
/vendor directory.

At least i can finally continue with the pagination coding. :)
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validating email

2008-11-07 Thread Sijo Kg

Hi
   This is not the required solution Suppose the user enters 
[EMAIL PROTECTED]@@ or [EMAIL PROTECTED]@ what happens?  Since we  cant insists 
that there should be value after @  or @@

Thanks
Sijo
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validating email

2008-11-07 Thread Mohit Sindhwani

Sijo Kg wrote:
> Hi
>   I have a mailid like [EMAIL PROTECTED]@   As part of email validation
>
>  I have to check it [EMAIL PROTECTED] So I did
>
> "[EMAIL PROTECTED]@@".split('@')  So I get ['test','123.com']   But if it
> were [EMAIL PROTECTED]  the expected validation is correct But the lase two @
> signs are not recognized by split So how can check that after 123.com
> still there is @ sign and declare my validation as failed?
>
> Sijo
>   
I can't explain why it doesn't recognize but you could add something to 
the end of the address and split.

irb(main):014:0> a = '[EMAIL PROTECTED]@@'
=> "[EMAIL PROTECTED]@@"
irb(main):015:0> a.split('@')
=> ["test", "123.com"]
irb(main):016:0> a = a + 'trash'
=> "[EMAIL PROTECTED]@@trash"
irb(main):017:0> a.split('@')
=> ["test", "123.com", "", "trash"]
irb(main):018:0>

Hope this helps.

Cheers,
Mohit.
11/7/2008 | 5:29 PM.


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Caching data in memory

2008-11-07 Thread Frederick Cheung


On 6 Nov 2008, at 23:28, Ben Knight wrote:

>
> I need to load some read-only lookup data from the database into  
> memory
> for fast access (i.e. caching). What's the best way to cache data in
> memory in Rails apps?  For example, should I use global, class or
> instance variables?  I realize each controller in my cluster will have
> it's own copy, which is fine.
>
Doesn't need to be anything cleverer than a class variable (or a class  
instance variable).

Fred
> Thanks in advance.
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Re: 3 failures, 4 errors

2008-11-07 Thread Delirium tremens

The 7 problems are solved!

On Nov 7, 7:01 am, Delirium tremens <[EMAIL PROTECTED]> wrote:
> Update!
>
>  I have 2 failures and 4 errors now, but only 2 kinds of problems! The
> first kind is something about user_path and the last is something
> about assert_select.
>
> the first kindhttp://pastie.org/309396
> the last kindhttp://pastie.org/309392
>
> On Nov 7, 6:12 am, Delirium tremens <[EMAIL PROTECTED]> wrote:
>
> > errorhttp://pastie.org/309370
> > failurehttp://pastie.org/309371
> > errorhttp://pastie.org/309372
> > errorhttp://pastie.org/309373
> > errorhttp://pastie.org/309374
> > failurehttp://pastie.org/309376
> > failurehttp://pastie.org/309378
>
> > How to solve these 7 problems?
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Validating email

2008-11-07 Thread Sijo Kg

Hi
  I have a mailid like [EMAIL PROTECTED]@   As part of email validation

 I have to check it [EMAIL PROTECTED] So I did

"[EMAIL PROTECTED]@@".split('@')  So I get ['test','123.com']   But if it
were [EMAIL PROTECTED]  the expected validation is correct But the lase two @
signs are not recognized by split So how can check that after 123.com
still there is @ sign and declare my validation as failed?

Sijo
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: text output in rxml (builder)

2008-11-07 Thread Onno Faber


> What about xml.text! "-122...\n" ?

I'm having an extra problem now, I'm doing this:
xml.Data 'ss:Type' => 'String' do
  xml.text! format_excel_html(block_content)
end

Now it works, but the output is like this:

bla bla bla


The problem I have is the whitespace the builder creates around my 
content. Does anyone know a trick to get rid of this whitespace?

Thanks, Onno
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: 3 failures, 4 errors

2008-11-07 Thread Delirium tremens

Update!

 I have 2 failures and 4 errors now, but only 2 kinds of problems! The
first kind is something about user_path and the last is something
about assert_select.

the first kind http://pastie.org/309396
the last kind http://pastie.org/309392

On Nov 7, 6:12 am, Delirium tremens <[EMAIL PROTECTED]> wrote:
> error http://pastie.org/309370
> failure http://pastie.org/309371
> error http://pastie.org/309372
> error http://pastie.org/309373
> error http://pastie.org/309374
> failure http://pastie.org/309376
> failure http://pastie.org/309378
>
> How to solve these 7 problems?
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] sort array of strings with čšž

2008-11-07 Thread sine serz

hi,

I have problems with sorting array of strings with special characters (č
š ž),


%w"abcčdesšuvzž".sort => "abcdesuvzčšž"

the right order should be č after c, š after s and ž after z.

I write my own sort method:

sort_order = ['a','b','c','č','d','e','f','g','h','i','j','k','l',
'm','n','o','q','p','r','s','š','t','u','v','w','z','ž','x','y']
user_items.sort_by {|u| sort_order.index(u.name.first)}

But it only works, if im sorting by first character.

How can i sort the whole words with right order?

example: %w"audi, bmw 320i, ,bmw 320d, seat, škoda, ...".


thanks

sergej
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Another question about database modelling

2008-11-07 Thread Danilo



On 6 Nov, 18:02, ms <[EMAIL PROTECTED]> wrote:
> Hello,
>
> thanks for reading! :) Ich will describe my problem with the help of
> an example, I think, that's the quickiest way to present my thoughts.
>
> Let's assume, you want to save locations. Locations can be of
> different types: country, federal state, town or even a shop or a
> phone cell. These ways of modelling this came to my mind:
>

Hi,
IMHO the best way is Nested Set, you can find a lot of tutorials
online.
This approach can represent different administrative organization in
the same time.

Danilo
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Handling multiple domain accounts for accessing a single web app.

2008-11-07 Thread Peter De Berdt

On 07 Nov 2008, at 02:39, Tim Uckun wrote:

>> account_location plugin, then use account_domain and use it as a  
>> key in your
>> access management.
>> Different templates, same functionality: either switch the  
>> stylesheet (CSS)
>> or go un-DRY by using different view folders for each domain.
>>
>
> The account_location plugin talks about subdomains.  Do you know if
> it's suitable for different top level domains?

All it does is put some convenience methods around the built-in  
request.domain, request.subdomains and request.port_string methods.  
Sometimes it's better to go and have a look at the actual code of the  
plugin to see what it does (and the code of account_domain is so  
simple even someone who never wrote a line of ruby would understand).

account_domain will return the domain and port without the subdomain  
part, examples:
• www.rubyonrails.org => rubyonrails.org
• www.rubyonrails.org:5000 => rubyonrails.org:5000
• api.rubyonrails.org => rubyonrails.org
• some.demo.app.rubyonrails.org => demo.app.rubyonrails.org

If you want just the domain and nothing else (port number, …), just  
request.domain is what you want.


Best regards

Peter De Berdt


--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: creating empty array of items - should be a quick simple one

2008-11-07 Thread Chas Lemley
I'm new to this but could you do this:

above this put

@items_missing_images = Array.new

and then in your if statement do this

@items_missing_images << item

Chas

On Thu, Nov 6, 2008 at 11:01 PM, Scott Kulik <
[EMAIL PROTECTED]> wrote:

>
> here is some of the code:
>
>@items_all = Item.find(:all)
>
>for item in @items_all do
>  if not FileTest.exist?(item.image_name)
>@items_missing_images += item
>  end
>end
>
> You have a nil object when you didn't expect it!
> You might have expected an instance of Array.
> The error occurred while evaluating nil.+
>
> at @items_missing_images += item
>
> so...how can i declare an empty array of Items?
>
> i tried declaring @items_missing_images = []
>
> but item is not of type array so this won't work.
> --
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: why rails is internationalization framework ?

2008-11-07 Thread Frederick Cheung


On 7 Nov 2008, at 07:00, Thani Ararsu wrote:

>
> what is internationalization framework ?
> why rails is internationalization framework ?
http://www.artweb-design.de/2008/7/18/the-ruby-on-rails-i18n-core-api  
covers rails 2.2's l18n features.

Fred
>
> what are the advance in rails 2.2.0 over rails (< 2.1.1)
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] 3 failures, 4 errors

2008-11-07 Thread Delirium tremens

error http://pastie.org/309370
failure http://pastie.org/309371
error http://pastie.org/309372
error http://pastie.org/309373
error http://pastie.org/309374
failure http://pastie.org/309376
failure http://pastie.org/309378

How to solve these 7 problems?
--~--~-~--~~~---~--~~
You received 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] ruby script/performance/profiler

2008-11-07 Thread Sijo Kg

Hi
I have seen this code  And i would like to know what dies it mean

ruby script/performance/profiler 'Model.new' 10
   Could anybody please tell what this script is doing?
Thanks in advance
Sijo
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---