[Rails] Re: uploading csv

2009-01-02 Thread Rajkumar Surabhi


Ima nw to ruby. plz tell me if there are any sites dealing with that...


raju
Vishwanath Nayak wrote:
> Hi,
> 
> You may want to upload the file initially through AJAX, parse it and 
> display
> the output for the user to validate.
> If the user submits the same, you can upload the same parsed value 
> rather
> than re parsing the whole file all together.
> 
> -NAYAK
> 
> On Tue, Dec 30, 2008 at 6:26 PM, Rajkumar Surabhi <

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

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



[Rails] InstantRails script/runner error

2009-01-02 Thread CiriusMex

Hi folks ^^,

Ok I need some help here. I'm trying to create a script to
automatically send Newsletters every day. The script is ready, but as
I never used ruby script/runner I just wanted to make some test
before. So I created the following script file in my "app" folder
named "newsletter_script.rb" and with the following dumb code:

class NewsletterScript
  printf "\nThat's it!"
end

Now when I'm executing the script command "ruby script/runner /app/
newsletter_script.rb" I got the following error:
C:/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/
commands/runner.rb:47: (eval):1: compile error (SyntaxError)
(eval):1: unknown regexp options - wlttr
(eval):1: syntax error, unexpected tIDENTIFIER, expecting $end
/app/newsletter_script.rb
  ^ from C:/InstantRails-2.0/ruby/lib/ruby/
site_ruby/1.8/rub
ygems/custom_require.rb:27:in `eval'
from C:/InstantRails-2.0/ruby/lib/ruby/gems/1.8/gems/
rails-2.0.2/lib/com
mands/runner.rb:47
from C:/InstantRails-2.0/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_req
uire.rb:27:in `gem_original_require'
from C:/InstantRails-2.0/ruby/lib/ruby/site_ruby/1.8/rubygems/
custom_req
uire.rb:27:in `require'
from script/runner:3

Looked on internet and didn't find any help for this unknow regexp
error (I guess did something wrong but what?!!)...

If anyone as an idea well thanks in advance for the help ;)

PD: If the message is not quite clear just let me know, I'm french and
my english isn't that good :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] How to disable etag?

2009-01-02 Thread swachian

I just use rails2.1.2  which has etag in the http header. The etag
makes something troublesome.
Does anyone know how to disable the tag?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How can I use the same model/pojo as both type ActiveRecord and non-ActiveRecord. Doesn't seem dry to make two identical type objects.

2009-01-02 Thread Florian Aßmann

Hi Rick, hope I got it right:

class AutomobileManufacturer < ActiveRecord::Base
   has_many :automobiles

   def favorite_automobiles
 AutomobileCollection.from_association_collection automobiles
   end
   def all_automobiles
 favorite_automobiles | remote_automobiles
   end
   def remote_automobiles
 AutomobileCollection.from_webservice
   end

end

class AutomobileCollection

   def self.from_association_collection(collection)
 collection = collection.map { |a| AutomobileItem.from_database a }
 new collection
   end
   def self.from_webservice
 # load collection... or take it as argument
 collection = collection.map { |a| AutomobileItem.from_webservice  
a }
 new collection
   end

   # generate a hash to simplify intersect
   def initialize(collection)
 @collection_hash = collection.inject({}) { |hash, item|
   hash.merge item.identifier => item
 }
 @collection = collection
   end

   # this could possibly be done with ruby stdlib 'Delegate'
   def each(&block)
 @collection.each(&block)
   end

   # intersect with another automobile collections
   def |(other)
 new_keys = other.automobiles_hash.keys - @collection_hash.keys
 new_collection = @collection +  
other.automobiles_hash.values_at(*new_keys)

 self.class.new new_collection
   end

   class AutomobileItem

 # two seperate methods because I think the interface for
 # webservice automobile and database automobile wont match.

 def self.from_webservice(automobile)
   instance = new automobile.manufacturer # ...
   instance
 end
 def self.from_database(automobile)
   instance = new automobile.manufacturer # ...
   def instance.favor
 # nop ...
   end
   instance
 end

 def initialize(manufacturer, *further_attributes)
   @attributes_hash = {
 # ...
   }
 end
 # generate an unique but compareable identifier
 def identifier
   "#{ manufacturer } ..."
 end
 # save the record, or maybe not when boxed automobile was loaded  
from db...
 def favor
   Automobile.create @attributes_hash
   # nop
   def self.favor; end
 end
   end

end

To make a subclass of ActiveRecord::Base to something not subclassing  
it requires some voodoo magic. If you really interested in this kind  
of stuff you should gte yourself involved with the rubiunius project. ;)
Otherwise box them in something that would provide the same interface  
for SOAPed objects as for ORMed objects.

This code is fully untested, but I hope you get the idea.

Regards
Florian

Am 02.01.2009 um 20:46 schrieb Rick:

>
> I understand I can just define a class without extending
> ActiveReord::Base, but what if I want to use the model object
> sometimes without having the data persist. For example...
>
> Let's say I have an "AutoManufacturer" object it might have
> name=Mercedes,etc. But AutoManufacturer could contain a collection of
> "Automobile" objects, (class=CLS, model="CLS350, numberOfDoors=4").
> Maybe your db isn't the one storing ALL the Automobile objects, you
> might only want to store 'favorite automobiles' but you still want to
> collect all the Automobile information (class, model, etc) when you
> record a favorite.
>
> So now what if I go to my DB and get my "AutoManufacturer" objects and
> for each AutoManufacturer I query some webservice to return a list of
> Automobiles and I want to then display on a page the AutoManufacturers
> and a collection of the Automobile objects I returned from my
> webservice call. If I have "Automobile" defined as an ActiveRecord
> type when I do something like
>
> automobiles = getCarsFromWebservice()
> automobiles.each do |a|
>car = Automobile.new();
>car.class= a.class
>car.type= a.type
>autoManufacturer.autos << car
> end
>
> every new car created above and added to the autoManufacturer actually
> creates a new car in the db, In this case all I want is fully
> populated list of autos in each autoManufacturer object for use to
> display on the front end, but I don't really want the automobile added
> to the db at this time. (Maybe after they select some, I'll then query
> a webservice and populate a real Automobile that I do want to persist
> in my db.)
>
> Currently I'm having to do something really lame. I'm creating
> basically identical objects - one a model object and one a simple
> pojo. It doesn't seem very dry to do it this way though. What's a
> better approach?
>
> -- 
> Rick
>
> >


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

[Rails] Re: nil object in create_time_zone_conversion_attribute?

2009-01-02 Thread Robert Matei

I'm getting the same error and a bit baffled.

For me it's happening when I've cached an array of ActiveRecord objects 
with Rails.cache and try to read them back. If I'm dealing with an array 
of integers it works fine.

Note that this is only happening on my development machine with whatever 
Rails' default caching mechanism is. In production, with Memcached, it's 
fine, so I just ended up installing Memcached on my development machine 
and it worked fine.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Not working country_select in Rails 2.2.2

2009-01-02 Thread Nurzed Lkham

country_select not working in Rails 2.2.2

How to fix it'

<%= country_select(:employee, :national, ["United States", "Russian
Federation"], {}) %>
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Displaying ruby content in rhtml

2009-01-02 Thread Freddy Andersen

Just an example of both usages

<% if is_admin? do %>
  <%= admin_title %>
<% end %>


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



[Rails] Re: url_for and ampersand escaping?

2009-01-02 Thread Hassan Schroeder

On Fri, Jan 2, 2009 at 5:08 PM, Jonathan Rochkind
 wrote:

> I knew that a URL in xHTML required ampersands to be escaped like that,
> even in an .  I did not know that a URL in standard (non-x)HTML
> required that. Really? Okay.



> But it's confusing in part because an ERB template isn't _only_ used for
> HTML. It can theoretically be used for creating any format, including
> plain text, right? And someone using an ERB template to create (eg)
> plain text is going to get tripped up there.

Interesting point -- I haven't tried generating any text/plain from an
ERB template.

> An ERB template was generating XML. It took the result of a url_for
> call, and put it through an XML-escaping routine, figuring that anything
> that was being put in XML should be put through an XML escaping routine.
>
> So we wound up with XML who's source looked like
> /controller/action?foo=foo&bar=bar
>
> Is this correct or not?

I'd say not :-)

Try eliminating the extra escaping routine and see what happens...

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com

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



[Rails] Re: Very odd NoMethodError/stack overflow....

2009-01-02 Thread Mike C

Thanks. That fixed that problem...but the other problem still exists. :
(

On Jan 2, 5:32 pm, "Jeffrey L. Taylor"  wrote:
> Quoting Mike C :
>
>
>
>
>
> > I'm getting this very weird error and I can't figure out what the
> > problem is. I'm using acts_as_commentable. Basically, I have a partial
> > with this code in it:
>
> > 
> >    
> >            <%= link_to comment.user.login, profile_path(User.find
> > (comment.user_id).profile) %>
> >                    <%= comment.comment %>
> >    
> > 
>
> > and here's the code that calls the partial:
>
> >   <% @comments.each do |comment| %>
> >     <%= render :partial => 'partials/comment', :locals => {:comment =>
> > comment} %>
> >   <% end %>
>
> > profile_path(User.find(comment.user_id).profile) is the hack I've had
> > to do to avoid this problem which is weird. All users have a profile,
> > so they are accessible by user.profile. I get the stack overflow error
> > when I do comment.user.id, but accessing comment.user.login or any
> > other attribute works fine. When I do comment.user.profile I get the
> > NoMethodError. I've checked over and over and all associations are in
> > placenothing seems wrong to me, yet this error won't go away. What
> > could be the problem? :(
>
> I've found model.id problematic.  I now always use model[:id] and have had
> fewer problems, none related to ambiquities around object ID versus record ID,
> etc.
>
> Jeffrey
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Very odd NoMethodError/stack overflow....

2009-01-02 Thread Jeffrey L. Taylor

Quoting Mike C :
> 
> I'm getting this very weird error and I can't figure out what the
> problem is. I'm using acts_as_commentable. Basically, I have a partial
> with this code in it:
> 
> 
>   
>   <%= link_to comment.user.login, profile_path(User.find
> (comment.user_id).profile) %>
>   <%= comment.comment %>
>   
> 
> 
> and here's the code that calls the partial:
> 
>   <% @comments.each do |comment| %>
> <%= render :partial => 'partials/comment', :locals => {:comment =>
> comment} %>
>   <% end %>
> 
> profile_path(User.find(comment.user_id).profile) is the hack I've had
> to do to avoid this problem which is weird. All users have a profile,
> so they are accessible by user.profile. I get the stack overflow error
> when I do comment.user.id, but accessing comment.user.login or any
> other attribute works fine. When I do comment.user.profile I get the
> NoMethodError. I've checked over and over and all associations are in
> placenothing seems wrong to me, yet this error won't go away. What
> could be the problem? :(

I've found model.id problematic.  I now always use model[:id] and have had
fewer problems, none related to ambiquities around object ID versus record ID,
etc.

Jeffrey

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



[Rails] Re: Displaying ruby content in rhtml

2009-01-02 Thread Ethan Gunderson

Shrikant,

<% %> is code that is executed, but not displayed in the browser.
<%= %> is code that will be executed and displayed.

Hope that helps!

Ethan Gunderson

On Fri, Jan 2, 2009 at 6:02 PM, Shrikant Sv
 wrote:
>
> Hi everyone,
>
> I am a newbie to RoR. I installed the Instant Rails package 1.7, and
> with scaffold, I was able to create and connect to a database.
> However, when I embed some code in rhtml(list.rhtml in the tutorial
> there), it does not display in browser. I can see the html part on the
> screen without problem, but the ruby part does not get processed at all.
> When I try a simple rhtml file such as below,
>
> 
> 
> All Recipes
> 
> 
> 
>Addition: <% print "World!" %>
> 
> Online Cookbook - All Recipes
> 
> 
>
> all I can see is
> Addition:
> Online Cookbook.
>
> I think this has something to do with eruby or erb, but do not know how
> to proceed.
>
> Any help would be much appreciated!
>
> Thanks
> Shrikant
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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



[Rails] Re: url_for and ampersand escaping?

2009-01-02 Thread Jonathan Rochkind

Hassan Schroeder wrote:
> On Fri, Jan 2, 2009 at 4:08 PM, Jonathan Rochkind
>  wrote:
>>
>> ...   url_for [helper method] seperates query parameters with
>> & url_for the controller method does
>> not. 

> Why "unpredictable"? HTML requires ampersands to be escaped,
> as part of URLs or otherwise.
> 
> A URL in plain text format, though, should not have ampersands
> escaped.

I knew that a URL in xHTML required ampersands to be escaped like that, 
even in an .  I did not know that a URL in standard (non-x)HTML 
required that. Really? Okay.

But it's confusing in part because an ERB template isn't _only_ used for 
HTML. It can theoretically be used for creating any format, including 
plain text, right? And someone using an ERB template to create (eg) 
plain text is going to get tripped up there.

In my case, I wasn't creating plain text, I was creating XML with an ERB 
template. Which should be a perfectly fine thing to do, right? Sure, you 
can use Builder if you want for XML, but you should be able to use an 
ERB template too, right?  But this definitely isn't the first time I've 
been confused by the proper amount of escaping of an ampersand in a 
complicated data flow.

I'm still not exactly sure if I fixed my bug in the right part of my 
somewhat complicated chain of data flow. I'd appreciate if you have any 
insight, Hassan. Here's what was going on:

An ERB template was generating XML. It took the result of a url_for 
call, and put it through an XML-escaping routine, figuring that anything 
that was being put in XML should be put through an XML escaping routine. 
(Is this where I went wrong? Not sure.)

So we wound up with XML who's source looked like 
/controller/action?foo=foo&bar=bar

Is this correct or not? Not sure. Later in the program execution, this 
XML gets converted to JSON, and the JSON winds up looking like:

some_url: '/controller/action?foo=foo&bar=bar';

This part was right, that is a proper JSON translation of the XML passed 
in, right, it un-escaped the XML properly, put it in JSON.

Then, this JSON gets delivered via JSONP to some javascript (external 
javascript not generated by rails). The javascript gets that value in a 
variable, containing '/controller/action?foo=foo&bar=bar'. So far so 
good, it got the right value from the JSON delivered to it.

Now, if that had been in HTML source for an , I guess the 
browser would have 'un-escaped' that before making the HTTP request. But 
it wasn't in HTML source, it was in a javascript variable. And when I 
passed this variable to my javascript routine to load the URL 
(AJAX-style), it ended up submitting a GET to the HTTP server that 
looked like this:

GET /controller/action?foo=foo&bar=bar

That wound up being caught by a mongrel-fronted Rails app, which did NOT 
turn that into query parameters foo => foo, bar => bar properly, it did 
weird things with that GET request.



So. At what point did that code go wrong? At the moment, I've fixed my 
XML-generating ERB to _not_ escape urls generated by url_for. But I'm 
not sure that's right, it doesn't feel right. Or is it my javascript 
code that took a js variable containing 
'/controller/action?foo=foo&bar=bar' and made a GET of that literal 
string, instead of un-escaping it first, that went wrong? Or something 
else?

I'm very confused.  And, since ERB can be used to generate all kinds of 
formats, it still seems to me that the documentation should mention this 
feature, which would have gotten me to my present state of confusion 
several hours earlier---ah, but when I go look at the most recent rdoc 
ActionView url_for, I see that it was there all along, my fault for 
missing it: "When called from a view, url_for returns an HTML escaped 
url. If you need an unescaped url, pass :escape => false in the 
options." So good on the rdoc after all. Still somewhat confused as to 
whether I should be "double escaping" it in the XML or not.

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

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



[Rails] Re: url_for and ampersand escaping?

2009-01-02 Thread Hassan Schroeder

On Fri, Jan 2, 2009 at 4:08 PM, Jonathan Rochkind
 wrote:
>
> ...   url_for on both servers seperates query parameters with
> & (url_for the helper method; url_for the controller method does
> not. I did not know this. Kinda confusing and unpredictable--and
> undocumented).

Why "unpredictable"? HTML requires ampersands to be escaped,
as part of URLs or otherwise.

A URL in plain text format, though, should not have ampersands
escaped.

It would be confusing if the two `url_for`s worked differently :-)

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

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



[Rails] Re: Displaying ruby content in rhtml

2009-01-02 Thread Frederick Cheung


On 3 Jan 2009, at 00:02, Shrikant Sv wrote:

>
> Hi everyone,
>
> I am a newbie to RoR. I installed the Instant Rails package 1.7, and
> with scaffold, I was able to create and connect to a database.
> However, when I embed some code in rhtml(list.rhtml in the tutorial
> there), it does not display in browser. I can see the html part on the
> screen without problem, but the ruby part does not get processed at  
> all.
> When I try a simple rhtml file such as below,
>
<% puts ... %> or <% print ...%> achieves very little (at best it will  
output to your server's log file).
You need to be using <%= which inserts the result of evaluating it's  
contents, ie <%= Time.now %>

Fred
> 
> 
> All Recipes
> 
> 
> 
>Addition: <% print "World!" %>
> 
> Online Cookbook - All Recipes
> 
> 
>
> all I can see is
> Addition:
> Online Cookbook.
>
> I think this has something to do with eruby or erb, but do not know  
> how
> to proceed.
>
> Any help would be much appreciated!
>
> Thanks
> Shrikant
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Re: url_for and ampersand escaping?

2009-01-02 Thread Jonathan Rochkind

Oh boy, this was a crazy one. It wasn't url_for that was behaving 
differently. url_for on both servers seperates query parameters with 
& (url_for the helper method; url_for the controller method does 
not. I did not know this. Kinda confusing and unpredictable--and 
undocumented).

But okay. I was then passing it through REXML in order to 'escape' it 
for eventual inclusion in some XML:

xml_escaped = REXML::Text.new( generated_url ).to_s

The difference between my two servers was ruby version, not Rails 
version. REXML is included with stock ruby (I didn't realize that 
either).

REXML::Text that comes with ruby 1.8.5 will not 'double escape' & to 
& .

I guess I'd consider that a bug, indeed. It probably should be double 
escaping something like that, if you pass it in escaped.

REXML::Text that comes with ruby 1.8.6, on the other hand, WILL double 
escape that text passed in escaped.

Wooh, what a mess.

Jonathan

Jonathan Rochkind wrote:
> I have two different servers, with two different test rails apps, both
> of which claim to be running Rails 2.1.2.
> 
> On one of them, url_for in a view environment generates & in between
> query parameters, instead of just &.  On the other, it generates just &.
> 
> Huh? I can't figure out why this is one way in one app that claims to be
> Rails 2.1.2, and another in another.
> 
> In neither one does url_for called in a controller context (rather than
> a helper context) use "&" to separate query parameters, it just uses
> "&".
> 
> It's driving me crazy. Anyone have any idea what might be going on?
> 
> Jonathan

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

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



[Rails] Re: url_for and ampersand escaping?

2009-01-02 Thread Conrad Taylor
On Fri, Jan 2, 2009 at 3:44 PM, Jonathan Rochkind <
rails-mailing-l...@andreas-s.net> wrote:

>
> I have two different servers, with two different test rails apps, both
> of which claim to be running Rails 2.1.2.
>
> On one of them, url_for in a view environment generates & in between
> query parameters, instead of just &.  On the other, it generates just &.
>
> Huh? I can't figure out why this is one way in one app that claims to be
> Rails 2.1.2, and another in another.
>
> In neither one does url_for called in a controller context (rather than
> a helper context) use "&" to separate query parameters, it just uses
> "&".
>
> It's driving me crazy. Anyone have any idea what might be going on?
>

Hi, can you post the relevant code or snippet of it?

-Conrad

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



[Rails] Simple relations are failing

2009-01-02 Thread Chris Olsen

Can anyone see why the league_organizers relation is failing.

class League < ActiveRecord::Base
  has_many :league_admins
  has_many :league_organizers, :through => :league_admins, :class_name
=> "User"

class LeagueAdmin < ActiveRecord::Base
  belongs_to :league
  belongs_to :user

I am getting the following error message:

ActiveRecord::HasManyThroughSourceAssociationNotFoundError: Could not
find the source association(s) :league_admins in model LeagueAdmin.  Try
'has_many :league_organizers, :through => :league_admins, :source =>
'.  Is it one of :league or :user?
  from
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/reflection.rb:199:in
`check_validity!'
  from
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/associations/has_many_through_association.rb:5:in
`initialize'
  from
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/associations.rb:1128:in
`new'
  from
/Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/associations.rb:1128:in
`league_organizers'
  from (irb):2


I tried adding the source option with and without the class_name but it
still fails.  As I mentioned it is a simple relation.  Has something
changed in the last while to cause this?

I am currently using Rails 2.2.2

Thanks for the help.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Displaying ruby content in rhtml

2009-01-02 Thread Shrikant Sv

Hi everyone,

I am a newbie to RoR. I installed the Instant Rails package 1.7, and
with scaffold, I was able to create and connect to a database.
However, when I embed some code in rhtml(list.rhtml in the tutorial
there), it does not display in browser. I can see the html part on the
screen without problem, but the ruby part does not get processed at all.
When I try a simple rhtml file such as below,



All Recipes



Addition: <% print "World!" %>

Online Cookbook - All Recipes



all I can see is
Addition:
Online Cookbook.

I think this has something to do with eruby or erb, but do not know how
to proceed.

Any help would be much appreciated!

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

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



[Rails] url_for and ampersand escaping?

2009-01-02 Thread Jonathan Rochkind

I have two different servers, with two different test rails apps, both
of which claim to be running Rails 2.1.2.

On one of them, url_for in a view environment generates & in between
query parameters, instead of just &.  On the other, it generates just &.

Huh? I can't figure out why this is one way in one app that claims to be
Rails 2.1.2, and another in another.

In neither one does url_for called in a controller context (rather than
a helper context) use "&" to separate query parameters, it just uses
"&".

It's driving me crazy. Anyone have any idea what might be going on?

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

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



[Rails] best way to store this data in the database

2009-01-02 Thread Scott Kulik

i have bunch of item properties that need to be stored in the database.
the options for the properties are:

-unknown
-yes
-no

what do you think is the best way to store this data?

should i use a tinyint and only store 0, 1, 2 for the respective options
or just use a varchar(10) and store the name of the result?

what is the usual standard?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: migration for beginner

2009-01-02 Thread Kaushik katari
script/generate migration add_inactivated_at_to_certain_table
inactivated_at:date


On Fri, Jan 2, 2009 at 3:04 PM, Anita Anita <
rails-mailing-l...@andreas-s.net> wrote:

>
> I haven't used migration for quite a while and I forgot how to do it.
> I need to add a column to a certain table.
> I want to use: ruby script/generate migration inactivated_at
> but if I don't write the name of the table somewhere how will it know?
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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



[Rails] Re: Very odd NoMethodError/stack overflow....

2009-01-02 Thread Mike C

class Comment < ActiveRecord::Base
  belongs_to :commentable, :polymorphic => true

  # NOTE: install the acts_as_votable plugin if you
  # want user to vote on the quality of comments.
  #acts_as_voteable

  # NOTE: Comments belong to a user
  belongs_to :user

end

class Story < ActiveRecord::Base
  acts_as_commentable
  acts_as_taggable_on :tags
  has_many :cores
  belongs_to :user

  validates_presence_of :title
  validates_presence_of :description
  validates_presence_of :rules
  validates_length_of :title, :within => 3..50
end

class User < ActiveRecord::Base
.
  has_many :stories
  has_many :cores
  has_many :comments
  has_one :profile
..
end
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] migration for beginner

2009-01-02 Thread Anita Anita

I haven't used migration for quite a while and I forgot how to do it.
I need to add a column to a certain table.
I want to use: ruby script/generate migration inactivated_at
but if I don't write the name of the table somewhere how will it know?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Very odd NoMethodError/stack overflow....

2009-01-02 Thread Frederick Cheung

>
> profile_path(User.find(comment.user_id).profile) is the hack I've had
> to do to avoid this problem which is weird. All users have a profile,
> so they are accessible by user.profile. I get the stack overflow error
> when I do comment.user.id, but accessing comment.user.login or any
> other attribute works fine. When I do comment.user.profile I get the
> NoMethodError. I've checked over and over and all associations are in
> placenothing seems wrong to me, yet this error won't go away. What
> could be the problem? :(

You could start by showing the models that seem to be causing the  
problem :-)

Fred
> >


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



[Rails] .htaccess ReWrite

2009-01-02 Thread Sean McGilvray

Hello everyone,
I have the following old way of getting users to their sites

www.domain.com/?username

I want all request coming in to this old way to go to the new way

www.domain.com/profile/username

Domain name is the same.

Is there a way to do this within Rails Routes or does someone know how
to write this in .htaccess?

Thank you,

Sean McGilvray

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



[Rails] Very odd NoMethodError/stack overflow....

2009-01-02 Thread Mike C

I'm getting this very weird error and I can't figure out what the
problem is. I'm using acts_as_commentable. Basically, I have a partial
with this code in it:



<%= link_to comment.user.login, profile_path(User.find
(comment.user_id).profile) %>
<%= comment.comment %>



and here's the code that calls the partial:

  <% @comments.each do |comment| %>
<%= render :partial => 'partials/comment', :locals => {:comment =>
comment} %>
  <% end %>

profile_path(User.find(comment.user_id).profile) is the hack I've had
to do to avoid this problem which is weird. All users have a profile,
so they are accessible by user.profile. I get the stack overflow error
when I do comment.user.id, but accessing comment.user.login or any
other attribute works fine. When I do comment.user.profile I get the
NoMethodError. I've checked over and over and all associations are in
placenothing seems wrong to me, yet this error won't go away. What
could be the problem? :(
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Multiple versions of a site (different languages)

2009-01-02 Thread Hassan Schroeder

On Fri, Jan 2, 2009 at 12:53 PM, Gaspard Bucher  wrote:

> We do not store language preferences in a session but use a prefix on
> urls "/en/..." or "/fr/..." so that cached content is served correctly
> for each language choice.

Was caching the only reason for taking that approach, or were there
other considerations?

Just curious :-)
-- 
Hassan Schroeder  hassan.schroe...@gmail.com

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



[Rails] Re: Gems between two different machines

2009-01-02 Thread Freddy Andersen

Are you using Rails 2 ? Then you should add the gems into you
application ..

rake gems # List the gems that this
rails application depends on
rake gems:build   # Build any native
extensions for unpacked gems
rake gems:install # Installs all required gems
for this application.
rake gems:refresh_specs   # Regenerate gem
specifications in correct format.
rake gems:unpack  # Unpacks the specified gem
into vendor/gems.
rake gems:unpack:dependencies # Unpacks the specified gems
and its dependencies into vendor/gems
rake rails:freeze:gems# Lock this application to
the current gems (by unpacking them into vendor/rails)
rake rails:unfreeze   # Unlock this application
from freeze of gems or edge and return to a fluid use of system gems


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



[Rails] Re: eager loading is letting me down

2009-01-02 Thread Rob Biedenharn

You probably could have said:

  def total_points
self.referrals.to_a.sum(&:point_value)
  end

And then #sum is from Enumerable (as extended by ActiveSupport) rather  
than ActiveRecord::Calculations::ClassMethods (note the use of .to_a  
in there to get a real array rather than an association proxy)

-Rob

On Jan 2, 2009, at 4:07 PM, Taylor Strait wrote:

>
> Fixed.  The short version of the story is that rails' .sum helper hits
> the DB N+1 times.  Writing a custom sum method solves this problem.   
> In
> my case, the top method only hits the DB twice whereas the second  
> method
> hits the DB N+2 times.
>
>  # 2 queries
>  def total_points
>sum = 0
>self.referrals.each {|ref| sum += ref.point_value}
>sum
>  end
>
>  # N+2 queries
>  def total_points
>self.referrals.sum :point_value
>  end
>
> So :include DOES work as long as you are careful to manipulate the
> collection in ruby and not use another ActiveRecord method to do
> summation.
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >

Rob Biedenharn  http://agileconsultingllc.com
r...@agileconsultingllc.com
+1 513-295-4739
Skype:  rob.biedenharn



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



[Rails] Gems between two different machines

2009-01-02 Thread jschank

Hello,

I usually develop on a desktop machine, but I also have a laptop. I
want to be able to ensure that the gems I've installed on one machine
are available on the other.

$ gem env
seems to tell me where the gems actually live. But I also seem to have
a local ~/.gem directory. (and a .gemrc)

So my questions are these...

1) what are the local directories for?
2) Can I just copy the entire gem directory (from gem env) between two
machines, and expect that to work?

Some possible flies in the ointment...
* I'm using Mac OS X Leopard
* The machines are different architectures (One is a G5, and one is an
intel - but both are OS X)

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



[Rails] Re: eager loading is letting me down

2009-01-02 Thread Taylor Strait

Fixed.  The short version of the story is that rails' .sum helper hits 
the DB N+1 times.  Writing a custom sum method solves this problem.  In 
my case, the top method only hits the DB twice whereas the second method 
hits the DB N+2 times.

  # 2 queries
  def total_points
sum = 0
self.referrals.each {|ref| sum += ref.point_value}
sum
  end

  # N+2 queries
  def total_points
self.referrals.sum :point_value
  end

So :include DOES work as long as you are careful to manipulate the 
collection in ruby and not use another ActiveRecord method to do 
summation.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Multiple versions of a site (different languages)

2009-01-02 Thread Gaspard Bucher

You might want to have a look at the data model we use in zena (http://
zenadmin.org/en/documentation/list333.html), the translated texts are
stored in the "versions" table. The table also stores current
publications along with redactions and old texts.

We do not store language preferences in a session but use a prefix on
urls "/en/..." or "/fr/..." so that cached content is served correctly
for each language choice.

Gaspard

On 2 jan, 21:42, JDS no spam  wrote:
> If you're going to have mulitple languages for a page then you'd best
> do a little bit of database normalisation otherwise you'll end up with
> pageBodyFrench, pageBodyItalian, pageBodyGreek, pageBodySwahili etc
>
> You have a model called Language
>
> iso_language_code (seehttp://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
> language_name
>
> Then you have your Page
> page_name_etc
>
> Then you have a many to many model PageLanguageBodyText
>
> language_id
> page_id
> body_text
>
> Then
>
> Class Language << ActiveRecord::Base
> has_many :page_language_body_texts
> has_and_belongs_to_many :pages, :through=>:page_language_body_text
> end
>
> Class Page << ActiveRecord::Base
> has_many :page_language_body_texts
> has_and_belongs_to_many :languages, :through=>:page_language_body_text
> end
>
> If the linking table had only the foreign keys required for joining
> the other two tables then there would be no need for a model, you'd
> just create the migration. But in this case you do have extra
> information so you have to have a model to access that information
> hence
>
> Class PageLanguageBodyText << ActiveRecord::Base
> belongs_to :page
> belongs_to :language
> end
>
> You'd need to tidy up the names a bit.
>
> You'd then have to modify your CMS to allow you to edit the page body
> text inside the form for your page, even though it's now been split
> out to its own model.
>
> Cheers
>
> John Small
>
> On Jan 2, 2:24 pm, bingo bob  wrote:
>
> > I've got a nice little site running which I rather like. All's running
> > tickety boo (the site is English language). It has a rudimentary CMS
> > with it, basically I have a page model such that Page.name and Page.body
> > exist. I simply allow the user to enter the page name and body and I
> > throw the content onto various pages around the site. As I say works
> > well.
>
> > Next feature - I'd like to do the site in French, German and Spanish as
> > well.
>
> > So.. my plan is this...
>
> > Just update the page model to include Page.name Page.body AND
> > Page.bodyFrench, Page.bodyGerman, Page.bodySpanish.
>
> > I'd then update my admin views to show text areas for all the new
> > languages and allow the user to update them all, that'd work fine I
> > think.
>
> > How do I implement this though from a browser perspective?
>
> > I'd like to put a challenge on the front page of the asking for which
> > language the user wants the site. Maybe flags int he time honoured sense
> > or whatever.
>
> > Thing is though, How do I store this information so that my app knows
> > which page to display for this user. I;ve heard of Sessions? but haven't
> > used them yet, is that how to do it, any tips or code fragment to get me
> > started would be grately apprecaited. wer wer
>
> > cheers,
>
> > bb
> > --
> > Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] eager loading is letting me down

2009-01-02 Thread Taylor Strait

Class User has_many Referrals.  Referrals have an instance variable
'point_value.'  So on my users/index action I want to list the user
info, total referrals, and then total points.  However, I am getting the
notorious N+1 problem when running this action.

USERS CONTROLLER
  def index
@users = User.find(:all, :include => :referrals)
  end

INDEX VIEW
<% for user in @users %>
  
<%= h user.email %>
Referrals: <%= user.referrals.size %>
Points: <%= user.total_points %>

USER.RB MODEL
has_many  :referrals,
:foreign_key => "referer_id"

  def total_points
self.referrals.sum :point_value
  end

The index action nails me with a nasty N+2 queries (i have six user
records in the test db):

Processing UsersController#index (for 127.0.0.1 at 2009-01-02 15:49:16)
[GET]
  User Load (4.3ms)   SELECT * FROM "users"
  Referral Load (1.4ms)   SELECT "referrals".* FROM "referrals" WHERE
("referrals".referer_id IN (1,2,3,4,6,7))
Rendering template within layouts/users
Rendering users/index
  SQL (0.3ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 1)
  SQL (0.3ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 2)
  SQL (0.3ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 3)
  SQL (0.2ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 4)
  SQL (0.3ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 6)
  SQL (0.3ms)   SELECT sum("referrals".point_value) AS sum_point_value
FROM "referrals" WHERE ("referrals".referer_id = 7)

Is this a failing of the rails .sum method to look inside the collection
or am I doing something wrong?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Testing a POST request with correct param

2009-01-02 Thread Vahagn Hayrapetyan

... and I'm looking forward to the day I'm able to give back, as well.
/ V.


Patrick Doyle wrote:
> On Fri, Jan 2, 2009 at 2:53 PM, Vahagn Hayrapetyan <
> rails-mailing-l...@andreas-s.net> wrote:
> 
>>puts "OPTIONS: " + options[:user] #method undefined!
>>etc etc
>>.
> 
> 
> Yup.  I'm not sure why you would get a #method undefined! error.  I got 
> all
> sorts "you have tried to call nil.something" errors, which pointed in 
> the
> direction of realizing that options[:foo][:bar] was not set.
> 
> I'm glad I could help.  I have received so much help from the folks on 
> this
> list that it's a pleasure to be able to give some back.
> 
> 
> --wpd

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

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



[Rails] Re: Multiple versions of a site (different languages)

2009-01-02 Thread JDS no spam

If you're going to have mulitple languages for a page then you'd best
do a little bit of database normalisation otherwise you'll end up with
pageBodyFrench, pageBodyItalian, pageBodyGreek, pageBodySwahili etc

You have a model called Language

iso_language_code (see http://en.wikipedia.org/wiki/List_of_ISO_639-1_codes)
language_name

Then you have your Page
page_name_etc

Then you have a many to many model PageLanguageBodyText

language_id
page_id
body_text

Then

Class Language << ActiveRecord::Base
has_many :page_language_body_texts
has_and_belongs_to_many :pages, :through=>:page_language_body_text
end

Class Page << ActiveRecord::Base
has_many :page_language_body_texts
has_and_belongs_to_many :languages, :through=>:page_language_body_text
end

If the linking table had only the foreign keys required for joining
the other two tables then there would be no need for a model, you'd
just create the migration. But in this case you do have extra
information so you have to have a model to access that information
hence

Class PageLanguageBodyText << ActiveRecord::Base
belongs_to :page
belongs_to :language
end

You'd need to tidy up the names a bit.

You'd then have to modify your CMS to allow you to edit the page body
text inside the form for your page, even though it's now been split
out to its own model.

Cheers


John Small


On Jan 2, 2:24 pm, bingo bob  wrote:
> I've got a nice little site running which I rather like. All's running
> tickety boo (the site is English language). It has a rudimentary CMS
> with it, basically I have a page model such that Page.name and Page.body
> exist. I simply allow the user to enter the page name and body and I
> throw the content onto various pages around the site. As I say works
> well.
>
> Next feature - I'd like to do the site in French, German and Spanish as
> well.
>
> So.. my plan is this...
>
> Just update the page model to include Page.name Page.body AND
> Page.bodyFrench, Page.bodyGerman, Page.bodySpanish.
>
> I'd then update my admin views to show text areas for all the new
> languages and allow the user to update them all, that'd work fine I
> think.
>
> How do I implement this though from a browser perspective?
>
> I'd like to put a challenge on the front page of the asking for which
> language the user wants the site. Maybe flags int he time honoured sense
> or whatever.
>
> Thing is though, How do I store this information so that my app knows
> which page to display for this user. I;ve heard of Sessions? but haven't
> used them yet, is that how to do it, any tips or code fragment to get me
> started would be grately apprecaited. wer wer
>
> cheers,
>
> bb
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validating non-model forms - a predicament

2009-01-02 Thread Patrick L.

Andrew Porter wrote:
> Patrick L. wrote:
>> But when the model is saved, the :card and :expiration_date fields are
>> not validated because they're not part of the model (they are accessed
>> using params[:cc][:card] and params[:cc][:expiration_date]).
> Add them as attributes to the model and then create validation rules as
> normal -
> 
> attr_accessible :expiration_date
> 
> validates_presence_of :expiration_date

Thank you both. I implemented Andrew's solution, and it seems to work. 
Thing is, it doesn't wrap the expiration_date input field in the error 
div (in other words, it doesn't turn red).

How should I fix 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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Testing a POST request with correct param

2009-01-02 Thread Patrick Doyle
On Fri, Jan 2, 2009 at 2:53 PM, Vahagn Hayrapetyan <
rails-mailing-l...@andreas-s.net> wrote:

>
> Hi guys and thanks a lot.
>
> post 'account/forgot', :user => {:email => 'j...@example.com'}
>
> is the deal. Patrick, if you could figure this out by putting print
> statements in your controller you're a better Rails coder than me :-)
> Did you mean:
>
>  def forgot
>puts "OPTIONS: " + options[:user] #method undefined!
>etc etc
>.


Yup.  I'm not sure why you would get a #method undefined! error.  I got all
sorts "you have tried to call nil.something" errors, which pointed in the
direction of realizing that options[:foo][:bar] was not set.

I'm glad I could help.  I have received so much help from the folks on this
list that it's a pleasure to be able to give some back.


--wpd

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



[Rails] Re: Testing a POST request with correct param

2009-01-02 Thread Vahagn Hayrapetyan

Hi guys and thanks a lot.

post 'account/forgot', :user => {:email => 'j...@example.com'}

is the deal. Patrick, if you could figure this out by putting print 
statements in your controller you're a better Rails coder than me :-) 
Did you mean:

 def forgot
puts "OPTIONS: " + options[:user] #method undefined!
etc etc
.
.
.
 end

?

@Phlip: The thing is, this is an integration test. And because this is 
an integration test (it is meant to mimic a real-life user's interaction 
with the app) I would mean it is OK to have GET and POST inside one 
test. (In real life, I first GET the "forgot password" view by clicking 
a link. Then, I POST my email to that view, etc. I could split these two 
actions into two separate tests and then combine them under a third test 
by calling the first one, then the second one. But, the flow would be 
exactly the same as if the two were inside a single test! This is why I 
think it is not necessary to make the test more atomic than it is - as 
long as it covers one distinct "scenario" of user-app interaction).

What I do when I need to see the errors I get (those who result in 
failures and errors in my test) is use this statement which I find very 
productive:

assert_response :success, "Errors on model: #any assert statement can be 
used
#{assigns(:my_model).errors.full_messages.to_sentence}"

That way, the errors appear in the terminal window that I run my 
commands from.

Hope this helps!

Cheers, Vahagn
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] How can I use the same model/pojo as both type ActiveRecord and non-ActiveRecord. Doesn't seem dry to make two identical type objects.

2009-01-02 Thread Rick

I understand I can just define a class without extending
ActiveReord::Base, but what if I want to use the model object
sometimes without having the data persist. For example...

Let's say I have an "AutoManufacturer" object it might have
name=Mercedes,etc. But AutoManufacturer could contain a collection of
"Automobile" objects, (class=CLS, model="CLS350, numberOfDoors=4").
Maybe your db isn't the one storing ALL the Automobile objects, you
might only want to store 'favorite automobiles' but you still want to
collect all the Automobile information (class, model, etc) when you
record a favorite.

So now what if I go to my DB and get my "AutoManufacturer" objects and
for each AutoManufacturer I query some webservice to return a list of
Automobiles and I want to then display on a page the AutoManufacturers
and a collection of the Automobile objects I returned from my
webservice call. If I have "Automobile" defined as an ActiveRecord
type when I do something like

automobiles = getCarsFromWebservice()
automobiles.each do |a|
car = Automobile.new();
car.class= a.class
car.type= a.type
autoManufacturer.autos << car
end

every new car created above and added to the autoManufacturer actually
creates a new car in the db, In this case all I want is fully
populated list of autos in each autoManufacturer object for use to
display on the front end, but I don't really want the automobile added
to the db at this time. (Maybe after they select some, I'll then query
a webservice and populate a real Automobile that I do want to persist
in my db.)

Currently I'm having to do something really lame. I'm creating
basically identical objects - one a model object and one a simple
pojo. It doesn't seem very dry to do it this way though. What's a
better approach?

-- 
Rick

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



[Rails] Re: Which test framework do you use?

2009-01-02 Thread Phlip

Yehuda Katz wrote:
> In the interest of collecting some demographic information on the
> community, Matt (Aimonetti, Rails evangelist) put together a poll of
> testing framework usage.
> 
> Please vote at http://twtpoll.com/zhh2fm. Thanks!

Assert{ 2.0 } makes test/unit competitive with any of those literate systems.

[Plug!] Here's what the latest (unreleased) version can do. This is an XPath 
test using Java and some Brand-X framework:

assertThat(
 document,
 hasTextAtXPath("//d...@id='info']//p[id='name']",
   containingString("Bob Jones")));

Here's the equivalent, with the XPath converted into a lite Ruby DSL:

   assert_xhtml document

   assert do
 xpath :div, :info do
   xpath :p, :name, ?. => 'Bob Jones'
 end
   end

Among other benefits, it handles escapes and naughty characters in the string 
payloads correctly. And if the inner xpath fails, its diagnostic only contains 
the ... - not the entire containing document!

-- 
   Phlip


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



[Rails] Re: Multiple versions of a site (different languages)

2009-01-02 Thread Hassan Schroeder

On Fri, Jan 2, 2009 at 6:24 AM, bingo bob
 wrote:

> So.. my plan is this...
>
> Just update the page model to include Page.name Page.body AND
> Page.bodyFrench, Page.bodyGerman, Page.bodySpanish.

I think most people who've done something like this would agree that
it's preferable to add a 'language' or 'locale' field to the DB, and keep a
single Page.body column.

> I'd like to put a challenge on the front page of the asking for which
> language the user wants the site. Maybe flags int he time honoured sense
> or whatever.

No, not flags -- what flag would you use for English? Spanish?
What language would you be referring to with the Swiss flag?

There isn't remotely a mapping of languages <--> countries. Use
the language name directly.

> Thing is though, How do I store this information so that my app knows
> which page to display for this user. I;ve heard of Sessions? but haven't
> used them yet, is that how to do it, any tips or code fragment to get me
> started would be grately apprecaited. wer wer

Yes, you would want to store the user preference in the session.  I'm
sure a quick google on "rails session" will turn up lots of examples.

And of course reading the ActionController::SessionManagement
doc is a good idea :-)

HTH,
-- 
Hassan Schroeder  hassan.schroe...@gmail.com

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



[Rails] Re: self-referential joins with :through raises TypeError

2009-01-02 Thread Taylor Strait

The SQL generated by user1.referer is

SELECT "users".* FROM "users" INNER JOIN referrals ON users.id = 
referrals.referer_id WHERE (("referrals".referer_id = 1))

But it should be using WHERE referrals.referee_id = 1 instead of 
referer_id = 1.  I've tinkered with various permutations but cannot make 
it query for users.id = referer_id WHERE referee_id = x.  Any thoughts?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Which test framework do you use?

2009-01-02 Thread Yehuda Katz

In the interest of collecting some demographic information on the
community, Matt (Aimonetti, Rails evangelist) put together a poll of
testing framework usage.

Please vote at http://twtpoll.com/zhh2fm. Thanks!
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Installing Gems

2009-01-02 Thread Abhishek Pratap

Thanks .. got the hook of it now..

Works fine..

The ENV variable is RUBYOPT.


Cheers,
-Abhi

On Jan 2, 12:12 pm, Frederick Cheung 
wrote:
> On 2 Jan 2009, at 16:57, Abhishek Pratap wrote:
>
>
>
> > Hi Fred
>
> > Thanks for a quick reply. However I am unable to follow up. May be
> > becoz I am platform ignorant till now.
>
> > So you want me to pass the ruby -I/export/wherever/its/put/those/
> > files  but where exactly ?
>
> I don't know where those files got installed :-)
> once you've worked out what the -I should be you can use RUBY_OPT
> environment variable to have it added automatically if my memory is
> correct.
>
> Fred
>
>
>
> > Thanks again for your patience.
> > -Abhi
>
> > On Jan 2, 11:43 am, Frederick Cheung 
> > wrote:
> >> On 2 Jan 2009, at 16:07, Abhishek Pratap wrote:
>
> >>> Hi All
>
> >>> Getting stuck at the first step with gems. I guess a tough start but
> >>> hoping for a easy future.
>
> >>> So here I am.
>
> >>> I did install Gems in the separate /export directory of my Red Hat
> >>> system.
>
> >> You might need to tell ruby to look in that folder eg by passing
> >> ruby -
> >> I/export/wherever/its/put/those/files
>
> >> Fred
>
> >>> ruby setup.rb --prefix=/export --destdir=/export
>
> >>> Now trying to install rails and its dependencies I see this error.
> >>> Possibly becoz I am not installing it in the central area as I our
> >>> admin policies dont allow it do.
>
> >>> gem install rails
> >>> /export/bin/gem:8:in `require': no such file to load -- rubygems
> >>> (LoadError)
> >>>   from /export/bin/gem:8
>
> >>> Thanks and excuse me if this sounds too silly :)
> >>> -Abhi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rendering partials from outside of Rails

2009-01-02 Thread Jeff

I'm using render :file, but as far as I can tell, Rails still tacks
RAILS_ROOT/app/views to the beginning of the given filename. Is there
a way to disable this? Ideally, I'd be rendering the partial from
outside the Rails root entirely.

On Jan 2, 3:42 am, Andrius Chamentauskas  wrote:
> render :file => ...
>
> On Jan 2, 12:32 am, Jeff  wrote:
>
> > I have a client Rails project, and I'd like to create a folder outside
> > of the Rails app completely. The client could create vanilla HTML
> > files and drop them into the folder. I'd then like to render those
> > HTML files as partials against the main site template. I want to keep
> > the client as far from the actual Rails app as possible. Is there a
> > way for me to render partials from outside the Rails root? Or at least
> > outside views?
>
> > Thanks,
> > Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: self-referential joins with :through raises TypeError

2009-01-02 Thread Taylor Strait

Taylor Strait wrote:
> Frederick Cheung wrote:
>> On 2 Jan 2009, at 17:36, Taylor Strait wrote:
>>> Most of this works.  User.referrals returns all the referral objects.
>>> Referral.referer and Referral.referee both return the appropriate
>>> objects.  But the User.referer/referee methods both raise the same
>>> error:
>>>
>> 
>> The class_name option should really be a string (ie :class_name =>
>> 'User')
>>

Actually I spoke too soon.  User.referer always returns nil, even if 
there is a referral record with appropriate referee_id and referer_id. 
Also, if I do user1.referer = user2 a NoMethodError is raised:

NoMethodError: undefined method `update_attributes' for 
#

User.referees does correctly return an array of user objects, though.

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

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



[Rails] Re: self-referential joins with :through raises TypeError

2009-01-02 Thread Taylor Strait

Frederick Cheung wrote:
> On 2 Jan 2009, at 17:36, Taylor Strait wrote:
>> Most of this works.  User.referrals returns all the referral objects.
>> Referral.referer and Referral.referee both return the appropriate
>> objects.  But the User.referer/referee methods both raise the same
>> error:
>>
> 
> The class_name option should really be a string (ie :class_name =>
> 'User')
> 
> Fred

Thanks that solved the issue.

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

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



[Rails] Re: self-referential joins with :through raises TypeError

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 17:36, Taylor Strait wrote:
>
> class Referral < ActiveRecord::Base
>  belongs_to  :referer,
>  :class_name => :user,
>  :foreign_key => "referer_id"
>
>  belongs_to :referee,
>  :class_name => :user,
>  :foreign_key => "referee_id"
>
> Most of this works.  User.referrals returns all the referral objects.
> Referral.referer and Referral.referee both return the appropriate
> objects.  But the User.referer/referee methods both raise the same
> error:
>

The class_name option should really be a string (ie :class_name =>  
'User')

Fred

>>> user.referer
> TypeError: can't convert Symbol into String
>
> I would like User.referer to return the single user object that is  
> their
> referer.  And User.referees would return an array of user objects that
> were refered.  What am I doing wrong here?
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] self-referential joins with :through raises TypeError

2009-01-02 Thread Taylor Strait

I have a simple referral system composed of Users and Referrals.

The users table has an id value, of course.  The referrals table has
referer_id and referee_id.  The relationships are set up as follows:

class User < ActiveRecord::Base
  has_many  :referrals,
:foreign_key => "referer_id"

  has_one :referer,
  :through => :referrals,
  :source => :referer

  has_many  :referees,
:through => :referrals,
:source => :referee

class Referral < ActiveRecord::Base
  belongs_to  :referer,
  :class_name => :user,
  :foreign_key => "referer_id"

  belongs_to :referee,
  :class_name => :user,
  :foreign_key => "referee_id"

Most of this works.  User.referrals returns all the referral objects.
Referral.referer and Referral.referee both return the appropriate
objects.  But the User.referer/referee methods both raise the same
error:

>> user.referer
TypeError: can't convert Symbol into String

I would like User.referer to return the single user object that is their
referer.  And User.referees would return an array of user objects that
were refered.  What am I doing wrong here?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Passenger and multi-site application

2009-01-02 Thread Gaspard Bucher

Hi list !

I am trying to test zena (http://zenadmin.org) with passenger
(http://www.modrails.com/). The basic setting is "point apache to the
'/zena/public' directory. This is fine for a single site application
but zena is a little different:

Cached content => '/zena/sites/some.host/public'

Other requests => '/zena/public'

Does anyone know how to configure this ?

Many thanks for any help...


Gaspard

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



[Rails] Re: Specifying Active Support Version in environment.rb

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 16:50, John wrote:

>
>
> Hello.
>
> I am getting this error...
>
> C:/dev/ccx_aucxtion_ccx/config/boot.rb:20:Warning:
> Gem::SourceIndex#search support for String patterns is deprecated
> c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:149:in `activate': can't
> activate activesupport (= 1.4.4, runtime), already activated active
> support-2.2.2 (Gem::Exception)
>
> Is there a way to specify the Active Support version in
> environment.rb?  I see there is a way to specify the Rails version...
>
A particular version of rails is tied to a particular version of  
activesupport. The error message you've got means that something  
required a newer version of activesupport before rails loaded its  
version.

Fred

> RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION
>
> Please let me know.
> Thanks,
> John
>
>
> >


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



[Rails] Re: Installing Gems

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 16:57, Abhishek Pratap wrote:

>
> Hi Fred
>
> Thanks for a quick reply. However I am unable to follow up. May be
> becoz I am platform ignorant till now.
>
> So you want me to pass the ruby -I/export/wherever/its/put/those/
> files  but where exactly ?

I don't know where those files got installed :-)
once you've worked out what the -I should be you can use RUBY_OPT  
environment variable to have it added automatically if my memory is  
correct.

Fred

>
>
> Thanks again for your patience.
> -Abhi
>
> On Jan 2, 11:43 am, Frederick Cheung 
> wrote:
>> On 2 Jan 2009, at 16:07, Abhishek Pratap wrote:
>>
>>
>>
>>> Hi All
>>
>>> Getting stuck at the first step with gems. I guess a tough start but
>>> hoping for a easy future.
>>
>>> So here I am.
>>
>>> I did install Gems in the separate /export directory of my Red Hat
>>> system.
>>
>> You might need to tell ruby to look in that folder eg by passing  
>> ruby -
>> I/export/wherever/its/put/those/files
>>
>> Fred
>>
>>> ruby setup.rb --prefix=/export --destdir=/export
>>
>>> Now trying to install rails and its dependencies I see this error.
>>> Possibly becoz I am not installing it in the central area as I our
>>> admin policies dont allow it do.
>>
>>> gem install rails
>>> /export/bin/gem:8:in `require': no such file to load -- rubygems
>>> (LoadError)
>>>   from /export/bin/gem:8
>>
>>> Thanks and excuse me if this sounds too silly :)
>>> -Abhi
>
> >


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



[Rails] Lazy evaluation and scoping

2009-01-02 Thread David Trasbo

Take a look at the #should_require_login_for inside this pastie (it's a
Shoulda macro): http://pastie.org/350658

#should_require_login_for takes an action name and a Proc. The method is
meant to be used like this in my functional tests:

should_require_login_for
  :new=> Proc.new { get :new },
  :create => Proc.new { post :create },
  ...

What this is basically supposed to do is:

1) Loop through each action.
2) Create a Shoulda #context
3) #setup a test by calling the Proc containing "get :new" or something.
4) Assert a redirection to the login page inside the #should block.

So this should test if an action requires login or not. But my problem
is, that I'm getting this error:

NoMethodError: undefined method `get' for PagesControllerTest:Class
./test/functional/pages_controller_test.rb:7

Notice that the error is appearing in the PagesControllerTest and NOT
inside the Shoulda macro. Using a lambda instead of a Proc simply
"postpones" the error message to the Shoulda macro, but it's still the
same message.

My question is: How do I get access to the #get, #post, #put, and
#delete methods in my Proc or lambda? Any help appreciated. :)
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Specifying Active Support Version in environment.rb

2009-01-02 Thread John


Hello.

I am getting this error...

C:/dev/ccx_aucxtion_ccx/config/boot.rb:20:Warning:
Gem::SourceIndex#search support for String patterns is deprecated
c:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:149:in `activate': can't
activate activesupport (= 1.4.4, runtime), already activated active
support-2.2.2 (Gem::Exception)

Is there a way to specify the Active Support version in
environment.rb?  I see there is a way to specify the Rails version...

RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION

Please let me know.
Thanks,
John


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



[Rails] Re: Installing Gems

2009-01-02 Thread Abhishek Pratap

Hi Fred

Thanks for a quick reply. However I am unable to follow up. May be
becoz I am platform ignorant till now.

So you want me to pass the ruby -I/export/wherever/its/put/those/
files  but where exactly ?

Thanks again for your patience.
-Abhi

On Jan 2, 11:43 am, Frederick Cheung 
wrote:
> On 2 Jan 2009, at 16:07, Abhishek Pratap wrote:
>
>
>
> > Hi All
>
> > Getting stuck at the first step with gems. I guess a tough start but
> > hoping for a easy future.
>
> > So here I am.
>
> > I did install Gems in the separate /export directory of my Red Hat
> > system.
>
> You might need to tell ruby to look in that folder eg by passing ruby -
> I/export/wherever/its/put/those/files
>
> Fred
>
> > ruby setup.rb --prefix=/export --destdir=/export
>
> > Now trying to install rails and its dependencies I see this error.
> > Possibly becoz I am not installing it in the central area as I our
> > admin policies dont allow it do.
>
> > gem install rails
> > /export/bin/gem:8:in `require': no such file to load -- rubygems
> > (LoadError)
> >from /export/bin/gem:8
>
> > Thanks and excuse me if this sounds too silly :)
> > -Abhi

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



[Rails] Re: HTML question...

2009-01-02 Thread Robby Russell

Hmm, I'd advocate that you use images in this place so that people
know it's not something that you can interact with. From a usability
standpoint, if you provide a checkbox that looks like they can
interact with, they might try. Keep it simple and obvious to the
end-user.

On Fri, Jan 2, 2009 at 6:48 AM, Patrick Doyle  wrote:
> if you are offended by HTML questions on this list, please feel free to
> flame me off list.
>
> I would like to display a boolean value in my #index view as a checkbox that
> is checked when true and blank when not true.  Is there some markup that can
> do this?  Is it "legal" to embed an  tag outside the
> context of a form?  Even if it's "legal", is it considered bad practice?
>
> I've poked around a little looking to see what others have done, and I could
> embed a checkmark image in my page, or I could embed the proper Unicode code
> for a checkmark, and hope that the browser has a font installed with that
> character, but it seems to me that the browser must already know how to
> display a checkmark, and in the principle of DRY, I should be able to reuse
> it :-)
>
> --wpd
>
>
> >
>



-- 
Robby Russell
Chief Evangelist, Partner

PLANET ARGON, LLC
design // development // hosting w/Ruby on Rails

http://www.planetargon.com/
http://www.robbyonrails.com/
aim: planetargon

+1 503 445 2457
+1 877 55 ARGON [toll free]
+1 815 642 4068 [fax]

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



[Rails] Re: backgroundrb stops suddenly

2009-01-02 Thread John Yerhot

You might want to try the BackgrounDRb mail list also

http://rubyforge.org/mailman/listinfo/backgroundrb-devel

On Jan 2, 6:18 am, Madhankumar Nagaraj  wrote:
> > Your MySQL session is timing-out after the default 8 hours.
>
> > Either increase the timeout by adding the following
> > line to the [mysqld] section of the /etc/my.cnf file:
>
> >    set-variable = wait_timeout=<#seconds>
>
> > or you can instead insert a call to
>
> >    ActiveRecord::Base.verify_active_connections!
>
> > ahead of any database queries.
>
> > The verify_active_connections! method is called by
> > Rails before every request, but your backgroundrb
> > process will not be getting this constant hammering
> > to keep its database connection alive.
>
> Dear Mark,
>
> first i want to thank for ur response,
>
> i am not making the mysql to wait, every 15 minutes i am getting the
> files uploaded. it works well for 1 week (avg) then it stops suddenly..
>
> ur
> Madhan
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Installing Gems

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 16:07, Abhishek Pratap wrote:

>
> Hi All
>
> Getting stuck at the first step with gems. I guess a tough start but
> hoping for a easy future.
>
> So here I am.
>
> I did install Gems in the separate /export directory of my Red Hat
> system.
>
You might need to tell ruby to look in that folder eg by passing ruby - 
I/export/wherever/its/put/those/files

Fred


> ruby setup.rb --prefix=/export --destdir=/export
>
> Now trying to install rails and its dependencies I see this error.
> Possibly becoz I am not installing it in the central area as I our
> admin policies dont allow it do.
>
> gem install rails
> /export/bin/gem:8:in `require': no such file to load -- rubygems
> (LoadError)
>from /export/bin/gem:8
>
> Thanks and excuse me if this sounds too silly :)
> -Abhi
>
> >


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



[Rails] Installing Gems

2009-01-02 Thread Abhishek Pratap

Hi All

Getting stuck at the first step with gems. I guess a tough start but
hoping for a easy future.

So here I am.

I did install Gems in the separate /export directory of my Red Hat
system.

ruby setup.rb --prefix=/export --destdir=/export

Now trying to install rails and its dependencies I see this error.
Possibly becoz I am not installing it in the central area as I our
admin policies dont allow it do.

gem install rails
/export/bin/gem:8:in `require': no such file to load -- rubygems
(LoadError)
from /export/bin/gem:8

Thanks and excuse me if this sounds too silly :)
-Abhi

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



[Rails] Re: Page caching + authentication/flash messages = chaos?

2009-01-02 Thread Olimpiu Metiu

> Does this mean that flash messages and authentication is an impossible
> combination? Is there any way to work around this?

I am using Cacheable Flash for the Rails Magazine web site and it
works rather well (you can see it in action on login).

The trick is to page cache only pages for anonymous users (using an
apache or nginx rewrite rule to detect specific cookies/authenticated
users).

Including Prototype or other Javascript libraries is not a huge deal
as these can be cached on the client (so the transfer hit is incurred
only on the first request).  On the other hand it's overkill to
include them solely for accessing cookies or dealing with cacheable
flash.

Best regards,
Olimpiu


On Jan 1, 1:02 pm, David Trasbo 
wrote:
> Fernando Perez wrote:
> >> But nothing actually solves the problem without giving new ones. So I
> >> guess I have to use fragment caching?
> > We use fragment caching on our VoD website:http://www.digiprof.fr, you
> > cannot do page caching if once the user is authenticated, he gets a
> > custom page.
>
> > PS: yeah Prototype is huge, we are currently considering other lighter
> > options, such as mootools.
>
> It would have been kind of frustrating to have 5000 lines of Javascript
> hanging around just to make one thing little thing work: Cacheable
> Flash. So I don't want to do that.
>
> I'll try fragment caching, then. Thanks! :)
> --
> Posted viahttp://www.ruby-forum.com/.

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



[Rails] I need help with self referential habtm

2009-01-02 Thread Felipe Vergara
Hello!

I need some help with self referential habtm associations:

I have a table inscripted and an inscripted may have a dependant, that works
ok with this
has_and_belongs_to_many :all_friends,
:class_name => "Inscrito",
:join_table => "related_inscritos",
:foreign_key => "related_inscrito_id",
:association_foreign_key => "main_inscrito_id"

i have related_inscritos table to save the association.
But now I need to add a type of relation for each association, does anyone
know how to do this??

Please any help will be very useful!!

Thanks
-- 
Felipe Vergara Contesse
Ingeniería Civil Industrial UC

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



[Rails] Re: Condition LIKE with or for autocomplete

2009-01-02 Thread Felipe Vergara
I made a concatenation of nombre apellido and then made the search that
worked great.
Thank for your help

-- 
Felipe Vergara Contesse
Ingeniería Civil Industrial UC

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



[Rails] Re: HTML question...

2009-01-02 Thread Patrick Doyle
>
> I was able to get formless inputs to pass validation (as XHTML 1.0
> strict or 1.1) at w3.org by putting them inside block elements like
> div or table.
>
> > I've poked around a little looking to see what others have done, and I
> could
> > embed a checkmark image in my page, or I could embed the proper Unicode
> code
> > for a checkmark, and hope that the browser has a font installed with that
> > character, but it seems to me that the browser must already know how to
> > display a checkmark, and in the principle of DRY, I should be able to
> reuse
> > it :-)
>
> DRY doesn't really apply here. I suppose you could apply DRY by
> writing a helper function to generate a link to the correct image
> based on the boolean value. But reusing standard elements in ways they
> weren't really designed to be used... just muddles the semantics.
>
>  -Michael
>
Thanks Michael, Philp, & Fred.  I should have thought of just trying it and
running it through the validator before asking.  Next time, I'll try that
first.

FWIW, when I mentioned "DRY" I was referring to reusing the code in the
browser that displays a checkmark, not to any code that I might have written
in my application.  It was supposed to be a joke, but I guess it died.
Sigh.

Thanks again folks.  I appreciate the tips and opinions.  Please keep them
coming.

--wpd

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



[Rails] Re: Need help DRYing this code

2009-01-02 Thread Bill Devaul

Andrius Chamentauskas wrote:
> 1. You could create a partial with code between for and end, not
> including them. Then u can render that partial using render :partial
> => 'something', :collection => @projects.
> 2. dom_id(project) is same as "project_#{project.id}"
> 3. Try content_tag_for(:li, project, ...) instead of  
> You can read more about all of these methods in rails documentation
> page.
> 
> On Jan 1, 11:33�pm, Bill Devaul 

Many thanks!  My Rails skills are improving by the day.

Here is what I'm using now:


drop task name
Projects
<% for project in @projects %>
  <%= render :partial => "drop_belongs_to_list", :locals => { :drop_item 
=> project } %>
<% end %>


Contexts
<% for context in @contexts %>
  <%= render :partial => "drop_belongs_to_list", :locals => { :drop_item 
=> context } %>
<% end %>



and the partial is:

<%= content_tag :li, (link_to (h drop_item.name), (drop_item)), :class 
=> drop_item.class.to_s.downcase, :id=> dom_id(drop_item) %>

<%= drop_receiving_element(
dom_id(drop_item), # The id of the receiving element
:accept   => "task_name",  # The CSS class of the dropped element
#The action to call (update the database and then update the project 
name field for that task via RJS)
#Not RESTful yet
:url  => { :controller => :tasks, :action => :update, 
"task[#{drop_item.class.to_s.downcase}_id]" => drop_item.id.to_s }
); %>

Far more readable in the main view.  If I could only make the 
drop_receiving_element RESTful, I'd be all set!

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

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



[Rails] Re: HTML question...

2009-01-02 Thread Michael Libby

On Fri, Jan 2, 2009 at 8:48 AM, Patrick Doyle  wrote:
> if you are offended by HTML questions on this list, please feel free to
> flame me off list.
>
> I would like to display a boolean value in my #index view as a checkbox that
> is checked when true and blank when not true.  Is there some markup that can
> do this?  Is it "legal" to embed an  tag outside the
> context of a form?  Even if it's "legal", is it considered bad practice?

I was able to get formless inputs to pass validation (as XHTML 1.0
strict or 1.1) at w3.org by putting them inside block elements like
div or table.

> I've poked around a little looking to see what others have done, and I could
> embed a checkmark image in my page, or I could embed the proper Unicode code
> for a checkmark, and hope that the browser has a font installed with that
> character, but it seems to me that the browser must already know how to
> display a checkmark, and in the principle of DRY, I should be able to reuse
> it :-)

While it may not be invalid HTML, I would personally want more control
over the display of this element. I'd much prefer an image or some
other indicator (+ or - characters, for instance). Also the checkbox
control is going to potentially allow the user to select/deselect the
checkbox, whereas an image will not. And what if you later decide
you'd rather have happy/sad face icons? ;)

DRY doesn't really apply here. I suppose you could apply DRY by
writing a helper function to generate a link to the correct image
based on the boolean value. But reusing standard elements in ways they
weren't really designed to be used... just muddles the semantics.

 -Michael

-- 
Michael C. Libby
www.mikelibby.com

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



[Rails] Re: HTML question...

2009-01-02 Thread Phlip

Frederick Cheung wrote:

>> I would like to display a boolean value in my #index view as a  
>> checkbox that is checked when true and blank when not true.  Is  
>> there some markup that can do this?  Is it "legal" to embed an  
>>  tag outside the context of a form?  Even if  
>> it's "legal", is it considered bad practice?
>>
> w3c validator doesn't seem to mind.

Under what DOCTYPEs?

(BTW I am building a webpage for a new project - non Rails - with generated 
source. The very first time I ran it thru http://validator.w3.org/ , it passed 
without even a warning. Beat that, Rails!!)

-- 
   Phlip


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



[Rails] Re: HTML question...

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 14:48, Patrick Doyle wrote:

> if you are offended by HTML questions on this list, please feel free  
> to flame me off list.
>
> I would like to display a boolean value in my #index view as a  
> checkbox that is checked when true and blank when not true.  Is  
> there some markup that can do this?  Is it "legal" to embed an  
>  tag outside the context of a form?  Even if  
> it's "legal", is it considered bad practice?
>
w3c validator doesn't seem to mind.

Fred
> I've poked around a little looking to see what others have done, and  
> I could embed a checkmark image in my page, or I could embed the  
> proper Unicode code for a checkmark, and hope that the browser has a  
> font installed with that character, but it seems to me that the  
> browser must already know how to display a checkmark, and in the  
> principle of DRY, I should be able to reuse it :-)
>
> --wpd
>
>
> >


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



[Rails] Re: Validating non-model forms - a predicament

2009-01-02 Thread Phlip

Patrick L. wrote:
> Hey folks,
> I have encountered what's beginning to look like a classic problem with
> Rails: validating non-model forms. Under what circumstances do you need
> to use non-model components in a model-backed form? I need to for credit
> card processing: I want to save information like the customer's phone
> number but I don't want to save their credit card number for security
> reasons.

Add attr_accessor :cc_number to your model, then validate it.

Then call .save(false) when saving the model object internally, to bypass all 
your validations.

Everything will work as if you had a column with that name, except 
find_by_cc_number, or loading the number (natch).

Also f.text_field will work, so Card.new(params[:card]) will work.

-- 
   Phlip


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



[Rails] HTML question...

2009-01-02 Thread Patrick Doyle
if you are offended by HTML questions on this list, please feel free to
flame me off list.

I would like to display a boolean value in my #index view as a checkbox that
is checked when true and blank when not true.  Is there some markup that can
do this?  Is it "legal" to embed an  tag outside the
context of a form?  Even if it's "legal", is it considered bad practice?

I've poked around a little looking to see what others have done, and I could
embed a checkmark image in my page, or I could embed the proper Unicode code
for a checkmark, and hope that the browser has a font installed with that
character, but it seems to me that the browser must already know how to
display a checkmark, and in the principle of DRY, I should be able to reuse
it :-)

--wpd

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



[Rails] Multiple versions of a site (different languages)

2009-01-02 Thread bingo bob

I've got a nice little site running which I rather like. All's running
tickety boo (the site is English language). It has a rudimentary CMS
with it, basically I have a page model such that Page.name and Page.body
exist. I simply allow the user to enter the page name and body and I
throw the content onto various pages around the site. As I say works
well.

Next feature - I'd like to do the site in French, German and Spanish as
well.

So.. my plan is this...

Just update the page model to include Page.name Page.body AND
Page.bodyFrench, Page.bodyGerman, Page.bodySpanish.

I'd then update my admin views to show text areas for all the new
languages and allow the user to update them all, that'd work fine I
think.

How do I implement this though from a browser perspective?

I'd like to put a challenge on the front page of the asking for which
language the user wants the site. Maybe flags int he time honoured sense
or whatever.

Thing is though, How do I store this information so that my app knows
which page to display for this user. I;ve heard of Sessions? but haven't
used them yet, is that how to do it, any tips or code fragment to get me
started would be grately apprecaited. wer wer

cheers,

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

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



[Rails] Re: collection_select and select_tag help

2009-01-02 Thread Scott Kulik


>> I have created the following select box which works fine except for  
>> the
>> fact if you edit the item it defaults back to N/A instead of selecting
>> the correct location.
>>
>> select_tag("item[location_id]", 'N/A' +
>> options_for_select(@locations.collect{|location| [location.name,
>> location.id]}))
>>
> The (optional) last argument to options_for_select is the value to be
> preselected (ie something like item.location_id)
> 
> Fred

ah didn't see that that.  Thanks!  i got it working.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: alias_method

2009-01-02 Thread Frederick Cheung



On Jan 2, 11:58 am, Sijo Kg  wrote:
> Hi
>     Could anybody please explain what it is and how it used I have code
> like I did not understand what it means
>

http://www.ruby-doc.org/core/classes/Module.html#M001676

Fred
> alias_method :set_layout_options, :layout_options=
>
> Sijo
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Ansuz CMS

2009-01-02 Thread knewter

The instructions on the site cover the fckeditor folder creation, I
actually don't like it existing in the project because when I deploy I
symlink it, but that's clearly the kind of thing other people using
the project can tell me (add the folder, modify my deploy script to
remove it and sym it to shared).  Anyway, thanks for trying it out :)

-Josh

On Jan 1, 12:38 pm, Martin  wrote:
> Hi Josh,
>
> > I'd actually never ran rake gems before, so I hadn't seen that.  I get
> > the same thing on my machine, but rake gems:install successfully
> > installed the ones I needed and it runs fine.  I'll look into why that
> > happens.
>
> thanks for your help and the hint in your other posting.
>
> > If you ignore that, does it work for you?
>
> No, I stumbled across some problems with the fckeditor ("unknown error
> creating folder" etc) and a file not found error after creating a new
> page. But I haven't searched too deep. I came across the mentioned
> (might-be) gem problem. So I stopped my search for the reason. But now
> I'll dig in deeper ;-)
>
> Thanks,
> Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: backgroundrb stops suddenly

2009-01-02 Thread Madhankumar Nagaraj

> Your MySQL session is timing-out after the default 8 hours.
> 
> Either increase the timeout by adding the following
> line to the [mysqld] section of the /etc/my.cnf file:
> 
>set-variable = wait_timeout=<#seconds>
> 
> or you can instead insert a call to
> 
>ActiveRecord::Base.verify_active_connections!
> 
> ahead of any database queries.
> 
> The verify_active_connections! method is called by
> Rails before every request, but your backgroundrb
> process will not be getting this constant hammering
> to keep its database connection alive.
> 

Dear Mark,

first i want to thank for ur response,

i am not making the mysql to wait, every 15 minutes i am getting the 
files uploaded. it works well for 1 week (avg) then it stops suddenly..


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

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



[Rails] alias_method

2009-01-02 Thread Sijo Kg

Hi
Could anybody please explain what it is and how it used I have code
like I did not understand what it means

alias_method :set_layout_options, :layout_options=

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



[Rails] Re: automatically load subdirectories under app/models

2009-01-02 Thread Sijo Kg

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

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



[Rails] Re: backgroundrb stops suddenly

2009-01-02 Thread Mark Reginald James

Madhankumar Nagaraj wrote:
> hi,
> i have used backgroundrb to update the database with the files having
> some useful data, where i am getting files periodically uploaded.
> it works well, but suddenly it stops the worker and stopped the
> updation.
> when i checked the backgroundrb.log file
> it shows
> Mysql::Error: MySQL server has gone away: (Query used for updation)
> LIMIT 1 - (ActiveRecord::StatementInvalid)
> but, the query is working fine in mysql.
> 
> i have created one worker to do the updation with job_key.
> when i checked the job_key value for the particular worker is shows nil.
> since the worker was stopped.
> 
> what would be the problem, how can i make the updation works
> continuously.

Your MySQL session is timing-out after the default 8 hours.

Either increase the timeout by adding the following
line to the [mysqld] section of the /etc/my.cnf file:

   set-variable = wait_timeout=<#seconds>

or you can instead insert a call to

   ActiveRecord::Base.verify_active_connections!

ahead of any database queries.

The verify_active_connections! method is called by
Rails before every request, but your backgroundrb
process will not be getting this constant hammering
to keep its database connection alive.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Re: Rendering partials from outside of Rails

2009-01-02 Thread Andrius Chamentauskas

render :file => ...

On Jan 2, 12:32 am, Jeff  wrote:
> I have a client Rails project, and I'd like to create a folder outside
> of the Rails app completely. The client could create vanilla HTML
> files and drop them into the folder. I'd then like to render those
> HTML files as partials against the main site template. I want to keep
> the client as far from the actual Rails app as possible. Is there a
> way for me to render partials from outside the Rails root? Or at least
> outside views?
>
> Thanks,
> Jeff
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Need help DRYing this code

2009-01-02 Thread Andrius Chamentauskas

1. You could create a partial with code between for and end, not
including them. Then u can render that partial using render :partial
=> 'something', :collection => @projects.
2. dom_id(project) is same as "project_#{project.id}"
3. Try content_tag_for(:li, project, ...) instead of 
wrote:
> I am new to this and need some help DRYing this view code:
>
> 
> drop task name
> Projects
> <% for project in @projects %>
>     <% project_id = "project_#{project.id}" %>
>     
>         <%=h project.name %>
>     
>
>     <% #TODO need to DRY up the drop_receiving_element, perhaps with a
> helper%>
>
>     <%= drop_receiving_element(
>         project_id,                           # The id of the receiving
> element
>         :accept   => "task_name",             # The CSS class of the
> dropped element
>         #The action to call (update the database and then update the
> project name field for that task via RJS)
>         :url      => { :controller => :tasks, :action => :update,
> 'task[project_id]'=> project.id.to_s }
>         #TODO there is probably a better way to refer to the task's
> project_id so that we can avoid the extra line in the update action of
> the task controller
>     ); %>
> <% end %>
> 
>
> Contexts
> <% for context in @contexts %>
>     <% context_id = "context_#{context.id}" %>
>     
>         <%=h context.name %>
>     
>     <%= drop_receiving_element(
>         context_id,                           # The id of the receiving
> element
>         :accept   => "task_name",             # The CSS class of the
> dropped elememt
>         #The action to call (update the database and then update the
> project name field for that task via RJS)
>         :url      => { :controller => :tasks, :action => :update,
> 'task[context_id]'=> context.id.to_s }
>         #TODO there is probably a better way to refer to the task's
> context_id so that we can avoid the extra line in the update action of
> the task controller
>     ); %>
> <% end %>
> 
> 
>
> What is the best way to do this?
>
> Thanks,
> Bill
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: automatically load subdirectories under app/models

2009-01-02 Thread Peter De Berdt

On 02 Jan 2009, at 09:42, Sijo Kg wrote:

>   Could you please tell here the difference between
> config.load_paths += Dir["#{RAILS_ROOT}/app/models/**/**"]

models and all subdirectories (even within a subdirectory)

> and
>
> config.load_paths += Dir["#{RAILS_ROOT}/app/models/**"]

models and subdirectories in models


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



[Rails] Re: Why are JS requests using layouts?

2009-01-02 Thread Mark Reginald James

Ben Johnson wrote:
> If I specify a layout in a controller:
> 
> class MyController < ApplicationController
> layout "some_layout"
> end
> 
> Any JS request will use the some_layout. I thought certain requests
> types were exempt from layouts? When I remove the layout call everything
> works perfect, the problem is that it uses the application layout.
> 
> Any ideas why this is or how I can fix this?

Is this with a recent version of Rails?
At one time you had to do

layout proc {|controller| 'some_layout' unless controller.request.xhr?}

But if you're doing proper RJS renders, I don't think it's now necessary.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Re: Validating non-model forms - a predicament

2009-01-02 Thread Andrew Porter

Patrick L. wrote:
> But when the model is saved, the :card and :expiration_date fields are
> not validated because they're not part of the model (they are accessed
> using params[:cc][:card] and params[:cc][:expiration_date]).
Add them as attributes to the model and then create validation rules as 
normal -

attr_accessible :expiration_date

validates_presence_of :expiration_date


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



[Rails] interact on user-level possibly?

2009-01-02 Thread Remco Swoany

Hi,


In our commerce-funnnel (step 1 > 5) we have drop from 100%(1) to 2%(5).

Clickstream:

Adwords
Visitor search for product (step1)
Visitor compare suppliers (step2)
Visitor makes decision (step3)
Visitor fills in form (step4)
Visitor goes to paymentgateway (step5)

First i want to reduce the % between step3 and step4, the idea is
through an dymanic pop-up when the visitor 'needs' some advice in making
the decision. The visitor gets dymanic a pop-up box with an chat
function with our agents.

Someone ideas in case of setup/plugins/gems?

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

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



[Rails] Re: link_to_remote can't replace specified element?

2009-01-02 Thread Mark Reginald James

JHuizingh wrote:
> I'm having an issue with the design of my views that I can't seem to
> wrap my head around.  I have a page where I am showing a collection of
> objects in a list.  The way that I designed it, it looked something
> like this:
> 
> main view:
> 
> here is the list
> 
> <%= render(:partial => "items/item", :collection => @items %>
> 
> 
> 
> collection item's view:
> 
>  
>  ...  INFO ABOUT item
> 
> 
> 
> This works great, creating a  that is full of 's.  I hit a
> snag when I start trying to update individual  items with ajax
> calls.  The :update option for  link_to_remote() and related functions
> doesn't give me an option to replace the dom element that it refers to
> as far as I can tell.  It lets me specify a dom id that I can change
> the innerHTML of, insert the returned html with in it at the beginning
> or the end, before or after the element, but it doesn't seem to allow
> me to REPLACE the element.
> 
> So a call like this:
> 
> remote_function(:url => credential_search_instance_path
> (credential_search_instance),
>  :method => :put,
>  :update => dom_id(item)
>)
> 
> Will replace the html inside of the  element, so it would update
> the page to look like this:
> 
>  
>  
>  ...  INFO ABOUT item
> 
> 
> 
> 
> I ended up getting around the issue by checking if it is an xhr
> request in my item view like this;
> <% if ! request.xhr? then %>
>  
> <% end %>
>  ...  INFO ABOUT item
> <% if ! request.xhr? then %>
> 
> <% end %>
> 
> That solution works, but it seems very inelegant and adds a lot of
> noise to the view.  Is it really true that I can't replace the dom
> element?  Am I missing something?  Is there a better way to design my

The best solution would be to move the li tags to a layout:

render :partial => "items/item", :collection => @items, :layout => 'li'

Where _li.html.erb contains

<%= yield %>

However this is broken in 2.2.2 (it instead renders a collection
of the collection). I've created a ticket:
http://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/1688

So until this works, the other options are:

1. Replace the collection with a loop, either using the
layout option, or putting the li tags in the main view,

2. Create a second level of partial, or

3. Remove the :update option and use outer-HTML replace RJS calls.

-- 
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com

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



[Rails] Validating non-model forms - a predicament

2009-01-02 Thread Patrick L.

Hey folks,
I have encountered what's beginning to look like a classic problem with
Rails: validating non-model forms. Under what circumstances do you need
to use non-model components in a model-backed form? I need to for credit
card processing: I want to save information like the customer's phone
number but I don't want to save their credit card number for security
reasons. Apparently, this situation also comes up when setting up basic
search forms for your website as well
(http://railscasts.com/episodes/37-simple-search-form); unfortunately,
Ryan didn't address it.

Essentially we're looking at this situation in the checkout view:

<% form_for(@checkout, :url => "/checkout") do |f| %>
<%= f.text_field :first_name %>
<%= f.text_field :last_name %>
<%= text_field(:cc, :card) %>
<%= text_field(:cc, :expiration_date) %>
<% end %>

But when the model is saved, the :card and :expiration_date fields are
not validated because they're not part of the model (they are accessed
using params[:cc][:card] and params[:cc][:expiration_date]).

All this code works - I just need to validate my credit card stuff! How
do I do this? I know I'm not the first guy to run into this problem.

Thank you for any suggestions!
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: collection_select and select_tag help

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 08:04, Scott Kulik wrote:

>
> I have created the following select box which works fine except for  
> the
> fact if you edit the item it defaults back to N/A instead of selecting
> the correct location.
>
> select_tag("item[location_id]", 'N/A' +
> options_for_select(@locations.collect{|location| [location.name,
> location.id]}))
>
The (optional) last argument to options_for_select is the value to be  
preselected (ie something like item.location_id)

Fred
> Ideally, I want to do something like this (which selects the correct
> value on edit):
>
> f.collection_select(:locations, @locations, :id, :name) %>
>
> but how can I add an extra blank option at the top like I did with
> select_tag?
>
> thanks!
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Re: how to apply a patch to core rails using git?

2009-01-02 Thread Frederick Cheung


On 2 Jan 2009, at 04:47, Ram wrote:

>
> There is a patch for using the :selected option with collection_select
> here - 
> http://rails.lighthouseapp.com/projects/8994/tickets/1037-selected-option-is-ignored-for-collection_select
>  
> .
>
> Can someone tell me how to apply it? I have git 1.6.0.1 on leopard.

Checkout rails from github and switch the relevant branch
Download the patch file
cd to where you have checked rails
git am path/to/file

Fred
>
> >


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



[Rails] regarding checkbox

2009-01-02 Thread napster

hi guys

 i have a table with fields as  type(id is default) and i am using
checkbox here whenever user check any of these
 items(high,low,medium) it should store in db.tell me how to do in
rails 2.0?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Searching for an entry in a one to one relationship

2009-01-02 Thread samsinite
Use the Patient and PersonName relationship I.e. :
@person = PersonName.find_by_last_name
Then a simple @person.patient will return the patient class object since rails 
knows the relationship.  I would just include the first_name and last_name 
fields in the patient table. Having a seperate datafield to hold that little of 
info seems silly.  You could use methods within the patient class to seperate 
the first_name and last_name data instead.
Sent from my Verizon Wireless BlackBerry

-Original Message-
From: Lance Klusener 

Date: Fri, 2 Jan 2009 00:18:37 
To: 
Subject: [Rails] Searching for an entry in a one to one relationship



1] I had a "Patient" model which is in a one to one relationship with
the "PersonName" model

class Patient < ActiveRecord::Base
  has_one :person_name
end

class PersonName < ActiveRecord::Base
  belongs_to :patient
end

2] "person_name" has the "last_name" and "first_name" as 2 of the fields

3] I am trying to find the Patient on the basis of his last_name , how
do i go about doing this , any example's will be HIGHLY appreciated.

The way i entered the data in was first create a PersonName

@personName = PersonName.new ( :last_name => "jack" , :first_name =>
"daniels")
@patient.person_name = @personName

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



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



[Rails] Re: automatically load subdirectories under app/models

2009-01-02 Thread Sijo Kg

Hi
   Could you please tell here the difference between
config.load_paths += Dir["#{RAILS_ROOT}/app/models/**/**"]
and

config.load_paths += Dir["#{RAILS_ROOT}/app/models/**"]

Note **

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



[Rails] Re: How to render more than one partial?

2009-01-02 Thread Zhao Yi

pepe wrote:
> Hello.
> 
> I don't see anything wrong with this code. Do you want to do something
> different than this? I guess I am not understanding the problem?
> 
> On Dec 31 2008, 6:07�am, Zhao Yi 

I mean in this way, I have to split the  tag. Take this partial for 
an example:

...
  
  


The other part of the  is in the view page. Have you tried this? I 
got a display problem.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: collection_select not remembering selected value

2009-01-02 Thread emarthinsen

Ah ha, I figured it out. In my migration, I had accidentally specified
that the product_id column should be a string, instead of an integer.
Once I changed the type, everything worked great.

Regards,
Eric


On Jan 2, 3:06 am, emarthinsen  wrote:
> One more thing. I debugged my app and when I inspect my @order object,
> the product field is being correctly set. I debugged a little deeper
> and it looks like at some point, Rails is trying to decide to set a
> particular option to selected by evaluating something like the
> following (assuming product id 7 was selected):
>
> "7" == 7
>
> It looks like, for the purpose of setting my model's attributes, the
> product id is being turned into an integer, but for selecting a value
> in collection_select, it is keeping it a string. Very confusing.
>
> -Eric
>
> On Jan 2, 2:56 am, emarthinsen  wrote:
>
> > Hello-
>
> > I have a form that I'm using form_for on to bind the form to my order
> > object. Within the form, I want to select a product (each order has
> > one product, which makes this easy). In my order and product models,
> > an order belongs_to a product. I didn't specify that a product
> > has_many orders (although I did test that the problem still exists
> > even if I do specify that). Here's the code I'm using to generate the
> > select list:
>
> > @packages = Package.find(:all, :order => 'name') #this is in my
> > controller
>
> > <%= f.collection_select :product, @products, :id, :name, { :prompt =>
> > '--select one--'} %>
>
> > The call to collection_select creates the list of options just fine,
> > but if my order has a value set for product, it doesn't get set as the
> > selected value.
>
> > I've tried a slew of other variations on the call to collection_select
> > (e.g., using :product_id instead of :product) and all seem to fail.
>
> > Does anyone know what I might be doing wrong?
>
> > Regards,
> > Eric
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] An error of Missing template

2009-01-02 Thread Zhao Yi

I use observe_form to monitor a form, whenever a field changed in this
form, an (Missing template builder/update_make_view_info.js.erb...)
error will be thrown. I don't want to use js format. I want to use
html.erb format. How can I avoid it and why it looks for
update_make_view_info.js.erb? This is my action code:

def update_make_view_info
...
render :patial=>'project_version'
end
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] backgroundrb stops suddenly

2009-01-02 Thread Madhankumar Nagaraj

hi,
i have used backgroundrb to update the database with the files having
some useful data, where i am getting files periodically uploaded.
it works well, but suddenly it stops the worker and stopped the
updation.
when i checked the backgroundrb.log file
it shows
Mysql::Error: MySQL server has gone away: (Query used for updation)
LIMIT 1 - (ActiveRecord::StatementInvalid)
but, the query is working fine in mysql.

i have created one worker to do the updation with job_key.
when i checked the job_key value for the particular worker is shows nil.
since the worker was stopped.

what would be the problem, how can i make the updation works
continuously.

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

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



[Rails] How to get which field changed in observe_form helper

2009-01-02 Thread Zhao Yi

I use observe_form to monitor all the fields in a form. But how can I
get which field changed?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: collection_select not remembering selected value

2009-01-02 Thread emarthinsen

One more thing. I debugged my app and when I inspect my @order object,
the product field is being correctly set. I debugged a little deeper
and it looks like at some point, Rails is trying to decide to set a
particular option to selected by evaluating something like the
following (assuming product id 7 was selected):

"7" == 7

It looks like, for the purpose of setting my model's attributes, the
product id is being turned into an integer, but for selecting a value
in collection_select, it is keeping it a string. Very confusing.

-Eric


On Jan 2, 2:56 am, emarthinsen  wrote:
> Hello-
>
> I have a form that I'm using form_for on to bind the form to my order
> object. Within the form, I want to select a product (each order has
> one product, which makes this easy). In my order and product models,
> an order belongs_to a product. I didn't specify that a product
> has_many orders (although I did test that the problem still exists
> even if I do specify that). Here's the code I'm using to generate the
> select list:
>
> @packages = Package.find(:all, :order => 'name') #this is in my
> controller
>
> <%= f.collection_select :product, @products, :id, :name, { :prompt =>
> '--select one--'} %>
>
> The call to collection_select creates the list of options just fine,
> but if my order has a value set for product, it doesn't get set as the
> selected value.
>
> I've tried a slew of other variations on the call to collection_select
> (e.g., using :product_id instead of :product) and all seem to fail.
>
> Does anyone know what I might be doing wrong?
>
> Regards,
> Eric
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] collection_select and select_tag help

2009-01-02 Thread Scott Kulik

I have created the following select box which works fine except for the
fact if you edit the item it defaults back to N/A instead of selecting
the correct location.

select_tag("item[location_id]", 'N/A' +
options_for_select(@locations.collect{|location| [location.name,
location.id]}))

Ideally, I want to do something like this (which selects the correct
value on edit):

f.collection_select(:locations, @locations, :id, :name) %>

but how can I add an extra blank option at the top like I did with
select_tag?

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

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