[Rails] Re: Difference between include and joins in find?

2008-11-18 Thread Frederick Cheung


On 18 Nov 2008, at 23:41, boblu wrote:

>
> yes, the compannies table does not have a columns called
> ref_company_id.
> It is the table which is referreced by the sections table that has a
> ref_company_id as a foreign key.
> Can you explain why that error comes out? 'cause I cannot find any
> clue about it.

It's very weird - in particular it's weird that it goes t0_r0, t0_r16:
the number after the r is generated by an each_with_index loop - it  
should skip over the numbers 1-15.
Weird stuff might happen if you had overwritten the column_names or  
columns methods on your ActiveRecord class but I would have expected  
that to cause problems elsewhere too.

Fred
>
>
> And thank you for mentioning your blog post, and I now know why I feel
> my app is much faster using join than  using include.
> Thank you.
>
> On Nov 18, 7:37 pm, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>> Well to answer the question in the subject line, I wrote this a  
>> little
>> while 
>> back:http://www.spacevatican.org/2008/6/22/the-difference-between-include- 
>> ...
>> A key thing to note is that include in 2.1 and include in 2.0.2 are
>> different (but the 2.1 code will fall back to the 2.0.2 code if
>> necessary).
>> Does the companies table not have columns called ref_company_id ?
>>
>> Fred
> >


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



[Rails] Dynamic input form view, based on model? Is there a helper or plugin for this?

2008-11-18 Thread Greg Hauptmann

Hi,

Is there an existing helper or plugin that let's one define a dynamic
input form page based on a model?

For example I am going to have a tableless model to collect the input
parameters required for a report to be run.  Given I have the model
(albeit based on a "ActiveRecord::Base Without Table"), is there a
helper or plugin that would let me say "render an input form for this
model, using validations defined in model"?

thanks

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



[Rails] Re: model.save not committing to DB with no errors.

2008-11-18 Thread Joshua Kolden



On Nov 18, 10:34 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Nov 19, 6:28 am, Joshua Kolden <[EMAIL PROTECTED]> wrote:> On Nov 18, 
> 7:48 pm, Philip Hallstrom <[EMAIL PROTECTED]> wrote:
>
> > > Any before_filters in place on this model?  What does your  
> > > development.log say?  Do you see the INSERT query?
>
> > no before_filters (no filters of any kind).  If I follow the
> > development.log while I'm doing an interactive console like above I
> > can see there is no output at all to the log when I do a save.  If I
> > immediately try a different model and save it, no problem, and I see
> > some output in the dev log.  It is very bazar.  I keep thinking I must
> > be using a keyword in the model somewhere, but I can't find any. Maybe
> > I've broken my installation.
>
> Well if there's something odd with that model you'll have to show it
> before people can tell you what's wrong. Tip of the day: methods/
> associations called transaction are a bad thing.
>
> Fred


Haha, how did you know?  I just figured it out and was on my way back
here to post the solution.  I have a model for financial transactions
called you guess it 'transaction'.  It's been working fine for
weeks, but I just added a polymorphic association from it to my
Allocation model.  It appears this was the culprit:

class Allocation < ActiveRecord::Base
  has_one :transaction, :as => :item

Thank you very much!!

j



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



[Rails] Re: model.save not committing to DB with no errors.

2008-11-18 Thread Joshua Kolden



On Nov 18, 10:34 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Nov 19, 6:28 am, Joshua Kolden <[EMAIL PROTECTED]> wrote:> On Nov 18, 
> 7:48 pm, Philip Hallstrom <[EMAIL PROTECTED]> wrote:
>
> > > Any before_filters in place on this model?  What does your  
> > > development.log say?  Do you see the INSERT query?
>
> > no before_filters (no filters of any kind).  If I follow the
> > development.log while I'm doing an interactive console like above I
> > can see there is no output at all to the log when I do a save.  If I
> > immediately try a different model and save it, no problem, and I see
> > some output in the dev log.  It is very bazar.  I keep thinking I must
> > be using a keyword in the model somewhere, but I can't find any. Maybe
> > I've broken my installation.
>
> Well if there's something odd with that model you'll have to show it
> before people can tell you what's wrong. Tip of the day: methods/
> associations called transaction are a bad thing.
>
> Fred
>

Haha how did you know?  I had just found that out and came back here
to post the solution.  It turns out I have a model for financial
transactions called you guessed it 'transaction'.  Seemed to be
working fine everywhere for a while then I created a polymeric
association to the allocation model and I guess this line in the
allocation model screwed it up.

class Allocation < ActiveRecord::Base
has_one :transaction, :as => :item
...

Thanks,
j


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



[Rails] Re: model.save not committing to DB with no errors.

2008-11-18 Thread Frederick Cheung



On Nov 19, 6:28 am, Joshua Kolden <[EMAIL PROTECTED]> wrote:
> On Nov 18, 7:48 pm, Philip Hallstrom <[EMAIL PROTECTED]> wrote:
>
>
>
> > Any before_filters in place on this model?  What does your  
> > development.log say?  Do you see the INSERT query?
>
> no before_filters (no filters of any kind).  If I follow the
> development.log while I'm doing an interactive console like above I
> can see there is no output at all to the log when I do a save.  If I
> immediately try a different model and save it, no problem, and I see
> some output in the dev log.  It is very bazar.  I keep thinking I must
> be using a keyword in the model somewhere, but I can't find any. Maybe
> I've broken my installation.
>
Well if there's something odd with that model you'll have to show it
before people can tell you what's wrong. Tip of the day: methods/
associations called transaction are a bad thing.

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



[Rails] [JOBS] Excellent Job Opportunity: Lead Engineering (Ruby On Rails), New Delhi

2008-11-18 Thread Jitendra Singh

Hi All,

We are looking for motivated Ruby on Rails/Java technology
professionals with 3+ years of relevant experience and a strong
background in computer science, in particular Internet technologies.
The role would involve both hands-on development as well as mentoring
the existing team.

Position: Lead Engineering
Location: Okhla Phase 1, New Delhi

Skills:
• Evidence of strong technical skills in one or more of the following
areas is required:
J2EE (EJB, JSP, Servlets)/ PHP
Ruby on Rails (Preferred)
• Proficiency in a leading database system • Experience in OO design
and modeling (UML) • Experience working on open source projects •
Experience of leading teams of 4-5 professionals • Excellent
Communication Skills • Strong Analytical skills

About us: Qualtech is an ISO and Microsoft certified Company. It is a
Project Management and Software Development Company. Promoted by group
of IIT graduates, the company has an excellent track record of
providing software solutions to top names in national and
international market. We have positioned ourselves as Domain and
Technology agnostic Business Application Software Services Company.
And with that positioning, we have implemented several successful
projects across the spectrum of Microsoft (.net) and J2EE
technologies. We provide a very good work environment to our people
with immense opportunities for growth and development as per
individual's career aspirations. We are 100+ People strong company.

You can also visit us at www.qualtech-consultants.com

If you or someone you know would be interested in discussing
opportunities available, please e-mail me a copy of current resume (in
Word format) as well as a contact number and best time to speak.

Please feel free to email/ Call me if you have any queries.

Best Regards,
Jitendra Singh
Work: 011-41601994, ext-295
Direct: 011-46527938
Cell: 09891463198
Email: [EMAIL PROTECTED]
F-16, 3rd Floor
Okhla Phase - I
New Delhi - 110020
www.qualtech-consultants.com

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



[Rails] ordering with eager loading

2008-11-18 Thread Felipe Gallois
I'm trying to order my results by what I got with eager loading.

there is a bit of code about what i want

@study_class = StudyClass.find(:all, :include => :teacher)

it is associated with an id, and i want to order my result by the teachers'
name, which is just inside the teacher table that is loaded there.

is it possible or will i have to reorder it with ruby code?

thanks!

-- 
gallois
aka Felipe Gallois
blog: www.gallois.com.br/blog
fanglib homepage: www.gallois.com.br/fanglib

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



[Rails] Re: model.save not committing to DB with no errors.

2008-11-18 Thread Joshua Kolden



On Nov 18, 7:48 pm, Philip Hallstrom <[EMAIL PROTECTED]> wrote:

>
> Any before_filters in place on this model?  What does your  
> development.log say?  Do you see the INSERT query?

no before_filters (no filters of any kind).  If I follow the
development.log while I'm doing an interactive console like above I
can see there is no output at all to the log when I do a save.  If I
immediately try a different model and save it, no problem, and I see
some output in the dev log.  It is very bazar.  I keep thinking I must
be using a keyword in the model somewhere, but I can't find any. Maybe
I've broken my installation.

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



[Rails] HABTM Validation

2008-11-18 Thread ghost rider

Hi
I have a many-to-many relationship between users and groups
set up in my application, using a join table (users_groups).
 i have wrote validation in both a table,

at the time of showing error message
its add one extra validation message
as "Groups is invalid"

how to avoid this message

with regards
shiva
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Edit is not working properly for radio_button

2008-11-18 Thread Raji Mani

Hi,

I m trying to edit contact info.. all other data other than radio button
are getting reflected in edit page .. But the same works fine while
creating new contact i.e it allows only one email id to be set as
primary but the same not working in edit.. it allows user 2 select  both
radio buttons
the view code is as follows
.
.
.

 Email Addresses
  <% i= 0 %>
   <% for email in @contact.emails %>
   <% fields_for "contact[email_attributes][]", email do |e| %>
   Email <%= i=i+1 %> 
<%= e.select ('email_type',%w{Business Personal},
:include_blank => false) %>
   <%= e.text_field :email,:size=>"35",:maxlength=>"80" %>
   <%= e.radio_button('isprimary', "1") %>

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



[Rails] Re: IE7 not calling formatted action properly.

2008-11-18 Thread Brian Ploetz

Alex Wayne wrote:
> Thats good news.  Obviously, HTTP clients cant yet be trusted to provide 
> proper headers.  So relying on them is problematic.  I personally like 
> the typed urls because it makes it super easy to grab things in a 
> variety of formats without any complicated header trickery.  I can do it 
> right in my browser.

Right. It just means that I have to go through all of my views and 
refactor my plain old link_to calls to look like:

link_to 'Foo', formatted_foo_url(@foo, "html")

Which is more than a pain in the arseyour filter works well until I 
can get around to doing this I suppose.

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

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



[Rails] Re: rss feed is not detected in firefox ?

2008-11-18 Thread Thani Ararsu

Duilio Ruggiero wrote:
>
> what version?
> 

this my "index.xml.builder" file content
#---
xml.instruct! :xml
xml.rss "version" => "2.0", "xmlns:dc" => 
"http://purl.org/dc/elements/1.1/"; do
 xml.channel do
   xml.title   "Rss Feeds"
   xml.link  url_for(:controller => 'feed')
   xml.description "My Feed Lists"
   xml.language('en-us')

   @feeds.each do |feed|
 xml.item do
   xml.title   feed.title
   xml.linkurl_for(feed)
   xml.author  feed.created_by
   xml.pubDate feed.created_at
   xml.description feed.description
   xml.guidurl_for(feed)
 end
   end
 end
end
#-
in my controller

  def index
@feeds = Post.find(:all,:order=>'id desc' ,:limit=>100)
respond_to do |format|
  format.xml {render :layout=>false}
end
  end

> 
> An rss feed IS only XML (if you don't apply a style sheet)
> There is a built-in style sheet for displaying feeds (that don't have a 
> style sheet specified) in
> IE, Safari and the last version of Firefox (probably you are using an 
> old version)
> 
> Duilio Ruggiero

my firefox version is 3.0.1

how to set new stylesheet ?

or any other idea?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: IE7 not calling formatted action properly.

2008-11-18 Thread Alex Wayne

Brian Ploetz wrote:
> This seems to be promoting URLs that are not "cool" 
> (http://www.w3.org/Provider/Style/URI) by requiring the format (.html, 
> .xml, etc) as an extension. That kind of stinks..

Thats good news.  Obviously, HTTP clients cant yet be trusted to provide 
proper headers.  So relying on them is problematic.  I personally like 
the typed urls because it makes it super easy to grab things in a 
variety of formats without any complicated header trickery.  I can do it 
right in my browser.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: IE7 not calling formatted action properly.

2008-11-18 Thread Brian Ploetz

Alex Wayne wrote:
> Once again, IE has caused me hours of pain, when all other browsers 
> performed flawlessly.  Grumble... humbug... grrr...

I just ran into this same issue, and found your post and solution 
through some Googling. Thanks. I notice that Rails 2.2 explicitly turns 
off the HTTP accept header by default now:


The HTTP Accept header is disabled by default now. You should prefer the 
use of formatted URLs (such as /customers/1.xml) to indicate the format 
that you want. If you need the Accept headers, you can turn them back on 
with config.action_controller.user_accept_header = true.


See:
http://rails.lighthouseapp.com/projects/8994/tickets/1053-removed-http-header-accept-by-default

This seems to be promoting URLs that are not "cool" 
(http://www.w3.org/Provider/Style/URI) by requiring the format (.html, 
.xml, etc) as an extension. That kind of stinks..
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Extra Characters in Find?

2008-11-18 Thread Philip Hallstrom

> I'm trying to submit a query through active record, and when I watch
> the development log to see what is getting passed in, I see something
> like this:
>
> SELECT * FROM "my_model" WHERE (some_name LIKE E'%search%')
>
> Is the "E" character supposed to be there?  I am not getting results
> returned and I don't know where that is coming from.  Any ideas?

Are you using PostgreSQL? If so...

http://www.postgresql.org/docs/current/static/sql-syntax-lexical.html

PostgreSQL also accepts "escape" string constants, which are an  
extension to the SQL standard. An escape string constant is specified  
by writing the letter E (upper or lower case) just before the opening  
single quote, e.g. E'foo'. (When continuing an escape string constant  
across lines, write E only before the first opening quote.) Within an  
escape string, a backslash character (\) begins a C-like backslash  
escape sequence, in which the combination of backslash and following  
character(s) represents a special byte value. \b is a backspace, \f is  
a form feed, \n is a newline, \r is a carriage return, \t is a tab.  
Also supported are \digits, where digits represents an octal byte  
value, and \xhexdigits, where hexdigits represents a hexadecimal byte  
value. (It is your responsibility that the byte sequences you create  
are valid characters in the server character set encoding.) Any other  
character following a backslash is taken literally. Thus, to include a  
backslash character, write two backslashes (\\). Also, a single quote  
can be included in an escape string by writing \', in addition to the  
normal way of ''. 

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



[Rails] Re: model.save not committing to DB with no errors.

2008-11-18 Thread Philip Hallstrom


On Nov 18, 2008, at 6:04 PM, Joshua Kolden wrote:

>
> I need some help to debug an issue that just came up, and I've never
> seen before.  I have a model, let's call it Allocation, and it has
> worked in the past (is working now on the live server).  It's fairly
> simple with user_id, size, start (date), expire (date),
> storage_billing_id, timestamps.  I started noticing in my development
> branch a couple of days ago that it won't save.  As I investigate
> further I see no errors when I attempt to save it just fails and
> return nil.
>
> in the console I tried:
>
>>> a = Allocation.new
> ...
> # ...assigned all the attributes manually
>
>>> a.save
> => nil
>>> a.valid?
> => true
>>> a.frozen?
> => false
>>> a.save!
> nil
>>> a.errors.full_messages
> => []
>
> I've removed some columns and added a column to this model recently,
> I've tampered with my os x rails installation recently, and I've done
> a lot of development around this class recently, but which of these
> issues is most likely the cause I don't know.  Any help debugging this
> would be GREATLY appreciated.

Any before_filters in place on this model?  What does your  
development.log say?  Do you see the INSERT query?

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



[Rails] Extra Characters in Find?

2008-11-18 Thread pete

Hi-

I'm trying to submit a query through active record, and when I watch
the development log to see what is getting passed in, I see something
like this:

SELECT * FROM "my_model" WHERE (some_name LIKE E'%search%')

Is the "E" character supposed to be there?  I am not getting results
returned and I don't know where that is coming from.  Any ideas?

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



[Rails] Re: Difference between include and joins in find?

2008-11-18 Thread boblu

Harold
 to me

As far as I know, the reason for :include is mainly for eager loading.
If you know you will be querying the sections table for the companies
you are finding, doing an :include will retrieve those sections in one
query, ie, one trip to the DB. If you don't pass in the :include
option to the initial find, doing the_company.all-sections would go to
the database to retrieve the associated records and then build the
section object.

I usually use :joins when I want to narrow down the search even
further, for instance, to companies who have sections, persons who
also have users, etc.

For example:
Company.find(:all, :include => :all-sections, :conditions => '...')
Would fetch all companies meeting those conditions, along with the
associated "all-section"s. Therefore it doesn't make sense to force it
to :select any specific columns, especially not columns on only one of
the tables - it defeats the purpose of the :include.

On the other hand:
Company.find(:all, :joins => :all-sections, :conditions =>
'..', :select => 'company.*')
works fine, however, :select => 'company.*' is redundant, and if you
will need the returned companies' sections, you will make a trip to
the DB that may have been avoided by using :include.



On Nov 18, 6:41 pm, boblu <[EMAIL PROTECTED]> wrote:
> yes, the compannies table does not have a columns called
> ref_company_id.
> It is the table which is referreced by the sections table that has a
> ref_company_id as a foreign key.
> Can you explain why that error comes out? 'cause I cannot find any
> clue about it.
>
> And thank you for mentioning your blog post, and I now know why I feel
> my app is much faster using join than  using include.
> Thank you.
>
> On Nov 18, 7:37 pm, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>
> > Well to answer the question in the subject line, I wrote this a little
> > while 
> > back:http://www.spacevatican.org/2008/6/22/the-difference-between-include-...
> > A key thing to note is that include in 2.1 and include in 2.0.2 are
> > different (but the 2.1 code will fall back to the 2.0.2 code if
> > necessary).
> > Does the companies table not have columns called ref_company_id ?
>
> > Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] model.save not committing to DB with no errors.

2008-11-18 Thread Joshua Kolden

I need some help to debug an issue that just came up, and I've never
seen before.  I have a model, let's call it Allocation, and it has
worked in the past (is working now on the live server).  It's fairly
simple with user_id, size, start (date), expire (date),
storage_billing_id, timestamps.  I started noticing in my development
branch a couple of days ago that it won't save.  As I investigate
further I see no errors when I attempt to save it just fails and
return nil.

in the console I tried:

>> a = Allocation.new
...
# ...assigned all the attributes manually

>> a.save
=> nil
>> a.valid?
=> true
>> a.frozen?
=> false
>> a.save!
nil
>> a.errors.full_messages
=> []

I've removed some columns and added a column to this model recently,
I've tampered with my os x rails installation recently, and I've done
a lot of development around this class recently, but which of these
issues is most likely the cause I don't know.  Any help debugging this
would be GREATLY appreciated.

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



[Rails] Rails on Plesk (missing libraries and gems)

2008-11-18 Thread John Lane

Hello, my ISP (PlusNet) is switching their hosting platform to Plesk
which has RoR but there is little support provided by the ISP.

I've been trying to install an application and have hit the buffers
because there are various items missing (currently I'm stuck wanting for
net/https for ActiveMerchant). Gem is not installed on Plesk and I have
limited access (no shell logon) to do stuff.

What I would like to do is identify my applications dependencies and
somehow freeze them into the vendor tree. Is this possible ?

By this I mean freeze not only rails but any other gems my application
relies upon. Also things that aren't gems (I don't think net/https) is a
gem (I think it was libopenssl-ruby on my Ubuntu dev platform).

Any help would be appreciated. I would like to get a real application
running on this Plesk platform.

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

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



[Rails] Re: Installing Rails - Problem with zlib

2008-11-18 Thread Christopher Adams

Frederick Cheung wrote:
> Christopher Adams wrote:
>> The result is this:
>>
>>
>> I understood that zlib was built into Ruby 1.8.7. Apparently not. So, I
> It is in that it is in the core ruby repository. It isn't in that the
> packages distributions like centos or debian create often carve ruby
> up into ruby itself and separate out bits of ruby that depend on other
> libraries (like zlib, openssl, readline etc...)
> 
>> Instlling ruby-zlib
>>
>> checking for deflateReset() in -lz... no
>> checking for deflateReset() in -llibz... no
>> checking for deflateReset() in -lzlib... no
>> *** extconf.rb failed ***
>> Could not create Makefile due to some reason, probably lack of
>> necessary libraries and/or headers.  Check the mkmf.log file for more
>> details.  You may need configuration options.
> 
> The ruby-zlib library didn't get installed as you might have guessed.
> While you almost certainly have the zlib libraries on your system, you
> may not have the associated headers etc... a lot of distros have a
> separate zlib-dev package or something along those lines. Get that,
> install ruby-zlib and you should be on your way (you might have to
> repeat the process with readline and/or openssl.
> 
> Fred

Fred,

Thank you for your reply. That is just what the doctor ordered. I am 
moving foreard again.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Difference between include and joins in find?

2008-11-18 Thread boblu

yes, the compannies table does not have a columns called
ref_company_id.
It is the table which is referreced by the sections table that has a
ref_company_id as a foreign key.
Can you explain why that error comes out? 'cause I cannot find any
clue about it.

And thank you for mentioning your blog post, and I now know why I feel
my app is much faster using join than  using include.
Thank you.

On Nov 18, 7:37 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> Well to answer the question in the subject line, I wrote this a little
> while 
> back:http://www.spacevatican.org/2008/6/22/the-difference-between-include-...
> A key thing to note is that include in 2.1 and include in 2.0.2 are
> different (but the 2.1 code will fall back to the 2.0.2 code if
> necessary).
> Does the companies table not have columns called ref_company_id ?
>
> Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What is the preferred "lightbox" plugin?

2008-11-18 Thread Philip Hallstrom

> I need to do an overlay with something that supports ajax/remote
> html.  There's lots of options and quite a few rails plugins.  Some
> seem out of date however.
>
> Any suggestions on which one is "best" where "best" is defined as easy
> to implement, works in all browsers, supports ajax or remote html.

Thanks to those that replied... I should have clarified no-jquery.  I  
love jquery, but the site uses a lot of Prototype and I'd rather not  
double up on JS libraries.

I found one and got it working.  Seems to do the right thing :)

http://code.google.com/p/rb-lightbox-plugin/

Not too much of a pain to implement either.  centers, works in IE/ 
Firefox.

There do seem to be a lot more jquery based ones.  Will have to go  
that route right off the bat next time :)

-philip

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



[Rails] Re: How to read the logs?

2008-11-18 Thread Bobnation

I can vouch for this. I haven't been reading logs for long, but I'm
getting better the more I do it ... which is bad, because it means I'm
making a lot of mistakes. I digress however.

It does look like you are missing the RedCloth gem on your production
server.

On Nov 18, 2:42 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> [EMAIL PROTECTED] wrote:
> > Can anyone tell me where I can learn how to read and decipher the
> > logs? I've done a few google searches and nothing comes up.
>
> > Specifically, I just uploaded my first app to a production server and
> > it doesn't work and I got the following even though it works perfectly
> > fine on my development machine:
>
> I'm not sure there's any substitute for just good old fashioned
> experience. In this case there's a missing RedCloth library - I'd
> guess you're missing the redcloth gem on your server.
>
> Fred
>
>
>
> > ctionView::TemplateError (uninitialized constant
> > Err::Acts::Textiled::ClassMethods::RedCloth) on line #26 of viewer/
> > show.html.erb:
> > 23:
> > 24: <% else %>
> > 25:
> > 26:     <%= @page.body %>
> > 27:
> > 28: <% end %>
> >    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
> > active_support/dependencies.rb:276:in `load_missing_constant'
> >    /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
> > active_support/dependencies.rb:468:in `const_missing'
> >    /home/admin/book/vendor/plugins/acts_as_textiled/lib/
> > acts_as_textiled.rb:24:in `body'
> >    /home/admin/book/app/views/viewer/show.html.erb:26:in
> > `_run_erb_47app47views47viewer47show46html46erb'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What is the preferred "lightbox" plugin?

2008-11-18 Thread Freddy Andersen

If you are willing to use JQuery then http://handlino.com/blog/2008/02/26/57/
is a good plugin. I'm on 2.1 and 2.2 for the projects where I'm using
this plugin.

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



[Rails] Re: Ruby on Rails Tutorial on IEEE Software Magazine

2008-11-18 Thread Bill Walton

Hi Alan,

Alan Kelon Oliveira de Moraes wrote:

> The November/December 2008 issue of IEEE Software 
> has nice a tutorial on Ruby on Rails. IEEE Software is one 
> the most prestigious magazines on Software Engineering. 

Thanks for letting us know.  That's some pretty serious validation! ;-)

Best regards,
Bill

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



[Rails] Re: What is the preferred "lightbox" plugin?

2008-11-18 Thread Bill Walton

Hi Philip,

Philip Hallstrom wrote:
>
> I need to do an overlay with something that supports ajax/remote
> html.  There's lots of options and quite a few rails plugins.  Some
> seem out of date however.
>
> Any suggestions on which one is "best" where "best" is defined as easy
> to implement, works in all browsers, supports ajax or remote html.

I'm in the same boat.  I've been in touch with Craig Ambrose and let him
know there were some 'problems' with Redbox.  I'm hopeful he'll whip out
something real quick ;-).  Seriously though...  I've got Redbox working
except for the automatic positioning.  There seems to be some code missing.
I specifically queried Craig about that.  In the meantime, I've been working
today on getting the positioning working.  If you're intersted, I could send
you what I come up with.  I'll warn you, though... JS is _not_ one of my
strengths ;-)

Best regards,
Bill


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



[Rails] Undefined method "add_reference"

2008-11-18 Thread Alex Sonar

Greetings,

I try to add a foreign key in one of my rails migrations in the
following way:

def self.up
 add_reference :categories, :items
end

This, strangely, leads to the following error during the migration:

-- add_reference(:categories, :items)
rake aborted!
undefined method `add_reference' for #


In the same way fails the code:

def self.up
  change_table :categories do |t|
  t.references :items
  end
end


I recently upgraded to Rails 2.1.2, if this is relevant to my case. Does
anyone have any pointers on how to solve this problem?

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

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



[Rails] Testing and fixture management against two databases

2008-11-18 Thread Wes Gamble

I have some models in my app. that connect to a different database than
the rest of my app.

How do I set things up so that when I run my tests, I can associate the
appropriate fixtures with the appropriate database.  For example, I'll
want most of the fixtures to get loaded into the "test" database, but
I'll want to load the few that connect to the other DB into another
database (that has a connection name in database.yml).

How is that done?

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

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



[Rails] How to read the logs?

2008-11-18 Thread rails...@gmail.com

Can anyone tell me where I can learn how to read and decipher the
logs? I've done a few google searches and nothing comes up.

Specifically, I just uploaded my first app to a production server and
it doesn't work and I got the following even though it works perfectly
fine on my development machine:

ctionView::TemplateError (uninitialized constant
Err::Acts::Textiled::ClassMethods::RedCloth) on line #26 of viewer/
show.html.erb:
23:
24: <% else %>
25:
26: <%= @page.body %>
27:
28: <% end %>
   /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/dependencies.rb:276:in `load_missing_constant'
   /usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
active_support/dependencies.rb:468:in `const_missing'
   /home/admin/book/vendor/plugins/acts_as_textiled/lib/
acts_as_textiled.rb:24:in `body'
   /home/admin/book/app/views/viewer/show.html.erb:26:in
`_run_erb_47app47views47viewer47show46html46erb'

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



[Rails] What is the preferred "lightbox" plugin?

2008-11-18 Thread Philip Hallstrom

Hi all -

I need to do an overlay with something that supports ajax/remote  
html.  There's lots of options and quite a few rails plugins.  Some  
seem out of date however.

Any suggestions on which one is "best" where "best" is defined as easy  
to implement, works in all browsers, supports ajax or remote html.

Thanks!

-philip

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



[Rails] Re: How to read the logs?

2008-11-18 Thread Frederick Cheung



[EMAIL PROTECTED] wrote:
> Can anyone tell me where I can learn how to read and decipher the
> logs? I've done a few google searches and nothing comes up.
>
> Specifically, I just uploaded my first app to a production server and
> it doesn't work and I got the following even though it works perfectly
> fine on my development machine:

I'm not sure there's any substitute for just good old fashioned
experience. In this case there's a missing RedCloth library - I'd
guess you're missing the redcloth gem on your server.

Fred
>
> ctionView::TemplateError (uninitialized constant
> Err::Acts::Textiled::ClassMethods::RedCloth) on line #26 of viewer/
> show.html.erb:
> 23:
> 24: <% else %>
> 25:
> 26: <%= @page.body %>
> 27:
> 28: <% end %>
>/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
> active_support/dependencies.rb:276:in `load_missing_constant'
>/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/
> active_support/dependencies.rb:468:in `const_missing'
>/home/admin/book/vendor/plugins/acts_as_textiled/lib/
> acts_as_textiled.rb:24:in `body'
>/home/admin/book/app/views/viewer/show.html.erb:26:in
> `_run_erb_47app47views47viewer47show46html46erb'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: how to make an image grow and make everything else dark until you click close

2008-11-18 Thread dino d.

Thanks, works great!

Dino

On Nov 18, 1:34 pm, Jodi Showers <[EMAIL PROTECTED]> wrote:
> Hey Dino -
> On 18-Nov-08, at 1:29 PM, dino d. wrote:
>
>
>
> > Anyone know an easy way to do this?  I have some web links in my app
> > with pictures, and I'd like to implement that effect that I've seen a
> > lot where when the user clicks on the image, it sort of grows and the
> > rest of the page becomes dark until the user clicks close (or clicks
> > the picture).  Is there an easy rails plugin for this?
>
> > thanks,
> > dino
>
> The effect is called a lightbox.
>
> we use lightbox2 at HomeStars
>
> http://huddletogether.com/projects/lightbox2/
>
> Jodi
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Searching multiple tables

2008-11-18 Thread Jean-Marc (M2i3.com)

Hi Jables,

There are no magic solution for what you're trying to do.

What you can do is search each model and use a 4th model as the search
result using that search result model to paginate and display your
page.

This way you should be able to sort in different fashion as made the
query much more efficient.

One question I have for you is how do you trigger the search?

Regards,

Jean-Marc
http://m2i3.com


On Nov 9, 9:29 pm, Jables <[EMAIL PROTECTED]> wrote:
> Hey,
>   I have three tables/models - stories, pictures, videos.  I want to
> be able to search all of these at once to find entries within a date
> range.  Currently I am searching each one and pushing the results onto
> an array which I paginate and display.  This doesn't work correctly
> because it doesn't sort correctly and seems like a poor solution.
>
> Additionally it would be helpful to be able to sort a date range and
> if that fails to find the 10 most recently added entries.  This seems
> like a simple find but I'm not sure exactly how to do it.
>
> Thanks for any help.
> JB
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Validations Question

2008-11-18 Thread Frederick Cheung



On Nov 18, 7:27 pm, Jables <[EMAIL PROTECTED]> wrote:
> I have a script that is run by a cron job.  It is constantly trying to
> put the same records into the database plus a few unique ones so to
> solve this I put a validates_uniqueness_of :title on the model.  This
> has the desired effect but the script exits with error on a invalid
> validation (identical title).  I want it to keep going to the next
> record.  How is this accomplished?
>
if you are using save! (which raises exceptions upon things like that)
either rescue the appropriate exception or use save (without the
exclamation mark) which returns true/false rather than raising
exceptions.

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



[Rails] Re: Creating a Query and then a select box based off query results

2008-11-18 Thread Christie Clark
Thanks, this pretty helpful. I am going through this step by step.  Had no idea 
even how to begin this or even what to call it when try to find a solution

--- On Tue, 11/18/08, Thorsten Müller <[EMAIL PROTECTED]> wrote:
From: Thorsten Müller <[EMAIL PROTECTED]>
Subject: [Rails] Re: Creating a Query and then a select box based off query 
results
To: "Ruby on Rails: Talk" 
Date: Tuesday, November 18, 2008, 6:22 AM

Roughly you will change the view when the user selects a server.
Use the onchange (not onclick) event of the select box
to trigger the next view.
Obviously that should be an Ajax call, since there is no
need to update the whole page.

something similar, a category select with subcategories:

the view with the main category select:

Kies een categorie
  <%= options_from_collection_for_select(@categories,
"id",
"title", (@product.category ? @product.category.category_id : 0))
%>
  

the action to get the sub categories:

  def sub_category
@product = Product.find(params[:id])
@categories = Category.find(:all, :order => "title
ASC", :conditions => "category_id = #{params[:category_id]} AND
published=1")
respond_to do |format|
  format.js
end
  end

the ajax response used by this action:

page.replace(:category_sub, :partial => 'depot/products/
sub_category_select', :locals => {:categories => @categories,
:product
=> @product})

and the partial used by the ajax response:


  <%= options_from_collection_for_select(categories, "id",
"title",
product.category_id) %>






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



[Rails] Ruby on Rails Tutorial on IEEE Software Magazine

2008-11-18 Thread Alan Kelon Oliveira de Moraes
Hello!

The November/December 2008 issue of IEEE Software has nice a tutorial on
Ruby on Rails. IEEE Software is one the most prestigious magazines on
Software Engineering.

Tutorial: 
http://www.di.ufpb.br/~alan/ror-ieeesw.pdf
Source code: 
http://www.di.ufpb.br/~alan/s6vis_code.zip

ABSTRACT: Ruby on Rails is a powerful Web application development framework
based on the dynamic object-oriented programming language Ruby. With several
popular Web sites based on it, its prominence is rapidly rising. Ruby on
Rails fully supports Web 2.0 and Web services and enables extremely rapid
development. It incorporates several important features of "programming in
the large" and is well suited for quickly developing even large, complex
applications. A small Web application that also uses Ajax and Web services
provides an introduction to Ruby on Rails.
Citation: Viswa Viswanathan, "Rapid Web Application Development: A Ruby on
Rails Tutorial," IEEE Software, vol. 25, no. 6, pp. 98-106, Nov/Dec, 2008.
http://www2.computer.org/portal/web/csdl/doi/10.1109/MS.2008.156

Best regards
-- 
Alan Kelon Oliveira de Moraes
Departamento de Informática - UFPB
"Vem, vamos embora, que esperar não é saber.
Quem sabe faz a hora, não espera acontecer." (Geraldo Vandré)

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



[Rails] Re: Installing Rails - Problem with zlib

2008-11-18 Thread Frederick Cheung



Christopher Adams wrote:
> This is installed on CentOS 5.2.
>
> I have installed Ruby 1.8.7
>
> I downloaded and expanded Gem Manager 1.3.1 and Rails 2.1.2
>
> I tried to install Rails using this:
>
> gem install rails --include-dependencies
>
> The result is this:
>
>
> I understood that zlib was built into Ruby 1.8.7. Apparently not. So, I
It is in that it is in the core ruby repository. It isn't in that the
packages distributions like centos or debian create often carve ruby
up into ruby itself and separate out bits of ruby that depend on other
libraries (like zlib, openssl, readline etc...)

> read about it and it was suggested that I manually build zlib. So, I
> downloaded ruby-zlib-0.6.0. Per the instructions, I ran this command:
>
> ruby extconf.rb && make && make install
>
> This is the result:
>
> /usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require': no such file to load -- zlib (LoadError)
>
> Instlling ruby-zlib
>
> checking for deflateReset() in -lz... no
> checking for deflateReset() in -llibz... no
> checking for deflateReset() in -lzlib... no
> *** extconf.rb failed ***
> Could not create Makefile due to some reason, probably lack of
> necessary libraries and/or headers.  Check the mkmf.log file for more
> details.  You may need configuration options.

The ruby-zlib library didn't get installed as you might have guessed.
While you almost certainly have the zlib libraries on your system, you
may not have the associated headers etc... a lot of distros have a
separate zlib-dev package or something along those lines. Get that,
install ruby-zlib and you should be on your way (you might have to
repeat the process with readline and/or openssl.

Fred
>
> Can anyone provide some insight as to what I need to do to get Rails
> installed?

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



[Rails] Validations Question

2008-11-18 Thread Jables

I have a script that is run by a cron job.  It is constantly trying to
put the same records into the database plus a few unique ones so to
solve this I put a validates_uniqueness_of :title on the model.  This
has the desired effect but the script exits with error on a invalid
validation (identical title).  I want it to keep going to the next
record.  How is this accomplished?

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



[Rails] Installing Rails - Problem with zlib

2008-11-18 Thread Christopher Adams

This is installed on CentOS 5.2.

I have installed Ruby 1.8.7

I downloaded and expanded Gem Manager 1.3.1 and Rails 2.1.2

I tried to install Rails using this:

gem install rails --include-dependencies

The result is this:


I understood that zlib was built into Ruby 1.8.7. Apparently not. So, I
read about it and it was suggested that I manually build zlib. So, I
downloaded ruby-zlib-0.6.0. Per the instructions, I ran this command:

ruby extconf.rb && make && make install

This is the result:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require': no such file to load -- zlib (LoadError)

Instlling ruby-zlib

checking for deflateReset() in -lz... no
checking for deflateReset() in -llibz... no
checking for deflateReset() in -lzlib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Can anyone provide some insight as to what I need to do to get Rails
installed?

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

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



[Rails] Re: how to make an image grow and make everything else dark until you click close

2008-11-18 Thread Jodi Showers

Hey Dino -
On 18-Nov-08, at 1:29 PM, dino d. wrote:

>
> Anyone know an easy way to do this?  I have some web links in my app
> with pictures, and I'd like to implement that effect that I've seen a
> lot where when the user clicks on the image, it sort of grows and the
> rest of the page becomes dark until the user clicks close (or clicks
> the picture).  Is there an easy rails plugin for this?
>
> thanks,
> dino

The effect is called a lightbox.

we use lightbox2 at HomeStars

http://huddletogether.com/projects/lightbox2/

Jodi

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



[Rails] how to make an image grow and make everything else dark until you click close

2008-11-18 Thread dino d.

Anyone know an easy way to do this?  I have some web links in my app
with pictures, and I'd like to implement that effect that I've seen a
lot where when the user clicks on the image, it sort of grows and the
rest of the page becomes dark until the user clicks close (or clicks
the picture).  Is there an easy rails plugin for this?

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



[Rails] Re: Best Practice for Timeliness?

2008-11-18 Thread Philip Hallstrom

> Hey, I want to highlight rows in an index view based on their
> timeliness. That is, is a record late, due soon, etc. Is it a better
> practice to put the business logic in the helper or model?

Both.  Add methods to your model such as is_late?, due_soon?, etc  
(returning true/false).  Then in your helper method use those methods  
to determine what style to apply to the row.

-philip

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



[Rails] how to give back the hand to AR error handling ?

2008-11-18 Thread nico Itkin

In controller I use to raise some specific error as follows :

include CustomErrors

rescue_from NoGuestFound,NoHostFound,NoInvitation,WrongPass do |e|
  flash[:message] = e.message
  redirect_to :action => :index
end

def lambda
  ...
  @guest.is_invited_by?(@host) or raise CustomError1.new 'context
message'
  ...
end


I find this way of doing pretty OK, but for AR model validation I'd like
to give back the end to the Active Record standard validation process. I
can't find good doc on how to do so and how AR validation works
exactly...

if anybody has a better way to deal with error handling or if you could
give me some smart links, would appreciate !
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: STI updating the :type attribute of an STI instance

2008-11-18 Thread nico Itkin

Frederick Cheung wrote:
> On Nov 18, 5:25�pm, nico Itkin <[EMAIL PROTECTED]>
> wrote:
>> Frederick Cheung wrote:
>>
>> I had found update_attribute_with_validation_skipping which updates the
>> protected attribute , but becomes is really what i need !! thanks a lot
>> !
> 
> You don;t need to dig that deep even for updating the attribute - just
> foo.type = 'Blah' would do it.
> Mass protection just means that it's ignored if you do
> update_attributes, create, new or things like that.
> 
> Fred

Realize that later, get mad cause update_attribute was not working

thanks for the explanation

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

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



[Rails] Re: run migrations upon boot

2008-11-18 Thread Andy

Dear Clemens,

I tried similar thing, but doesn't go well because web server doesn't
run without DB tables.
How did you handle this issue?

Andy

On 11月13日, 午後10:55, Clemens <[EMAIL PROTECTED]> wrote:
> > > My question:
> > > is it "acceptable" to run migrations upon boot OR by invoking them
> > > from within an admin page?
>
> > If you ran them from the admin page then at the very least you would
> > need to call reset_column_information on all your model classes (in
> > all instances of your application)
>
> > Fred
>
> Dear Fred,
> does this also apply to calling migrations upon boot, or woud that be
> "safe"?
>
> if (ActiveRecord::Migrator.new(:up, 'db/
> migrate').pending_migrations.length > 0)
>   ActiveRecord::Migration.verbose = false
>   ActiveRecord::Migrator.migrate("db/migrate/", nil)
> end
>
> Thx
> Clemens
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: customize logger messages in Rails2?

2008-11-18 Thread cpr

I needed to blot out hugh binary data in the log so here's what I use
in 2.1. I have a hard time believing that there's not a simpler way to
blot out huge binary data but I've been unable to find it. I recall
trying to use filter_parameter_logging from the controllers, but it
didn't work for me at the time (likely my issue, not Rails). Anyhow
this code shows one way to muck with the logger, maybe it'll help.
It's in my environment.rb. Bananas not included.

module ActiveSupport
  class BufferedLogger
def add(severity, message = nil, progname = nil, &block)
  return if @level > severity
  message = (message || (block && block.call) || progname).to_s
  message.to_str.gsub!(/(\s|\()x'([0-9a-fA-F]*)'(,|\s|\))/,'\1x
\'BINARY_DATA\'\3')

  level = {
0 => "D",
1 => "I",
2 => "W",
3 => "E",
4 => "F"
  }[severity] || "U"

  message = "[%s: %s #%d] %s" % [level,
 Time.now.strftime("%m%d %H:%M:
%S"),
 $$,
 message]


  message = "#{message}\n" unless message[-1] == ?\n
  buffer << message
  auto_flush
  message
end
  end
end


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



[Rails] Re: STI updating the :type attribute of an STI instance

2008-11-18 Thread Frederick Cheung



On Nov 18, 5:25 pm, nico Itkin <[EMAIL PROTECTED]>
wrote:
> Frederick Cheung wrote:
>
> I had found update_attribute_with_validation_skipping which updates the
> protected attribute , but becomes is really what i need !! thanks a lot
> !

You don;t need to dig that deep even for updating the attribute - just
foo.type = 'Blah' would do it.
Mass protection just means that it's ignored if you do
update_attributes, create, new or things like that.

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



[Rails] Re: STI updating the :type attribute of an STI instance

2008-11-18 Thread nico Itkin

Frederick Cheung wrote:
> On Nov 18, 4:35�pm, nico Itkin <[EMAIL PROTECTED]>
> wrote:
>> => #
>> g.update_attributes!(:type=>'Host')
>> => true>> g
>>
>> => #
>>
>> #It seems that this "type" attribute is protected is there a way to
>> by-pass this ?
> Yup (and if you check your logs you'd probably see a warning about not
> being able to mass assign a protected attribute)
> 
> There's two things you can play with: Directly setting the type
> attribute or playing with the becomes method.
> 
> Fred

I had found update_attribute_with_validation_skipping which updates the 
protected attribute , but becomes is really what i need !! thanks a lot 
!
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: undefined method `to_query'

2008-11-18 Thread Ian

Yes.  Upgrading fixed it.  Thanks!

On Nov 18, 9:47 am, Mark Thomas <[EMAIL PROTECTED]> wrote:
> > >> Object.new.methods.include?('to_query')
> > => false
> > >> exit
>
> You won't see it from IRB, because Rails extends Object with the
> methods. Try it from within 'script/console" -- it works for me in
> Rails 2.0.2 (not sure about 1.2.3--that's fairly outdated).
>
> -- Mark.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] STI updating the :type attribute of an STI instance

2008-11-18 Thread nico Itkin

Hi !

i've different users subclasses organised thanks to STI under a user
mother class, problem is that i can't find a way to exchange a user form
a certain type to an other , any light ???

class User < ActiveRecord::Base

end

class Guest < User
  has_and_belongs_to_many :hosts,
:join_table => 'invitations'
end

class Host < User
  has_and_belongs_to_many :guests,
:join_table => 'invitations'
end


#i'd like to change a Guest user to make him become Host :
>> g = Guest.first
=> #
g.update_attributes!(:type=>'Host')
=> true
>> g
=> #


#It seems that this "type" attribute is protected is there a way to
by-pass this ?

you can find the pastie of the above code here :
http://pastie.org/317885
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Akismet Rails Plugin

2008-11-18 Thread Schalk Neethling

Hi all,

I am trying to get Akismet installed on a RoR app. When trying to 
install Rakismet using:
script/plugin install git://github.com/jfrench/rakismet

I always get, plugin not found.

Does anyone know where I can get this from or an alternate plugin?

Thanks,
Schalk

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



[Rails] Embedded SQL request

2008-11-18 Thread Vincent Pérès

Hello,

I'm trying to create a Rails like embedded request like that (it is
working, I'm selecting projects ordered by number of contributors) :

SELECT projects.id AS id,
   project_topic,
   (SELECT count(*) FROM project_users WHERE projects.id =
project_users.project_id) AS contributors
FROM projects
ORDER BY contributors DESC

I didn't find any resource to create it in a Rails way :
Projects.find(..., :order => 'contributors') and do a sub-request
somewhere.

Is there anyone who could give me some links or help?

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

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



[Rails] Re: Akismet Rails Plugin

2008-11-18 Thread Frederick Cheung



On Nov 18, 4:12 pm, Schalk Neethling <[EMAIL PROTECTED]> wrote:
> Hi all,
>
> I am trying to get Akismet installed on a RoR app. When trying to
> install Rakismet using:
> script/plugin install git://github.com/jfrench/rakismet
>
> I always get, plugin not found.

tried just now and it worked fine. Do you have rails 2.1 or higher?
(previous version didn't do plugins from git)

Fred
>
> Does anyone know where I can get this from or an alternate plugin?
>
> Thanks,
> Schalk
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: STI updating the :type attribute of an STI instance

2008-11-18 Thread Frederick Cheung



On Nov 18, 4:35 pm, nico Itkin <[EMAIL PROTECTED]>
wrote:
> => #
> g.update_attributes!(:type=>'Host')
> => true>> g
>
> => #
>
> #It seems that this "type" attribute is protected is there a way to
> by-pass this ?
Yup (and if you check your logs you'd probably see a warning about not
being able to mass assign a protected attribute)

There's two things you can play with: Directly setting the type
attribute or playing with the becomes method.

Fred

>
> you can find the pastie of the above code here :http://pastie.org/317885
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Code changes are ignored due to code minor ver. were cached

2008-11-18 Thread Jeff

On Nov 18, 10:03 am, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On Nov 18, 3:04 pm, Zhoran Tvalve <[EMAIL PROTECTED]>
> wrote:
>
> > Hi there!
> > I study Ruby on Rails and met a problem.
>
> > I placed a class definition code for class which is NOT a Model into
> > separate file, assume MyToolClass.rb
>
> > Then I started working on controller code and required 'MyToolClass'
>
> use require_dependency instead of require.
>
> Fred

But if the file name follows conventions (so a class named MyToolClass
would go in a file named app/models/my_tool_class.rb or lib/
my_tool_class.rb), then no require or require_dependency should be
needed and code changes will be automatically reloaded in development
mode.

If you're not following naming conventions, then do as Fred
suggests :-)

Jeff

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



[Rails] Re: Is it real in RoR?

2008-11-18 Thread Jeff

On Nov 18, 8:00 am, Alexey <[EMAIL PROTECTED]> wrote:
> I've a table dic: id, type_id, info
>
> I'd like to store any information inside, it can be, for instance,
> categories with type_id = 1 and classifications with type_id = 2
>
> I'd like to make 2 different models such as
>
> class Category < ActiveRecord::Base
>   set_table_name "dic"
> end
>
> class Сlassification < ActiveRecord::Base
>   set_table_name "dic"
> end
>
> and add conditions to it: type_id = 1 to first, type_id  = 2 to
> second.
>
> In this way i can use Category.find(:all) and don't care about
> classification - they won't be found.
> On the other hand, in Сlassification.find(:all) categories won't be
> found.
>
> Can I add it with RoR?

I'd suggest you use named scopes instead, allowing you to stick with
Rails conventions and benefits.

class Dic < ActiceRecord::Base
 set_table_name 'dic'

 named_scope :categories, :conditions => { :type_id => 1 }
 named_scope :classifications, :conditions => { :type_id => 2 }

end

# Example usage

Dic.categories.all # => returns all categories
Dic.classifications.all # => returns all classifications

Jeff

purpleworkshops.com

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



[Rails] Re: How to get results from database SQL query

2008-11-18 Thread Frederick Cheung



On Nov 18, 3:23 pm, Yan Oleg <[EMAIL PROTECTED]> wrote:
> I need to get results from SQL query to database.
>
> I have an SQL statement, e.g.: SELECT MAX(my_field) max_my_field FROM
> my_table WHERE id=5
>
> I want to get the result, what is the max value. I have to get only one
> record with a number, or null if no records found. Please provide Ruby
> code to do this? (to store results in variable)

Checkout the maximum method (http://api.rubyonrails.com/classes/
ActiveRecord/Calculations/ClassMethods.html#M001659)

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



[Rails] Is it real in RoR?

2008-11-18 Thread Alexey

I've a table dic: id, type_id, info

I'd like to store any information inside, it can be, for instance,
categories with type_id = 1 and classifications with type_id = 2

I'd like to make 2 different models such as

class Category < ActiveRecord::Base
  set_table_name "dic"
end

class Сlassification < ActiveRecord::Base
  set_table_name "dic"
end

and add conditions to it: type_id = 1 to first, type_id  = 2 to
second.

In this way i can use Category.find(:all) and don't care about
classification - they won't be found.
On the other hand, in Сlassification.find(:all) categories won't be
found.

Can I add it with RoR?

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



[Rails] Re: Testing controllers for DB changes?

2008-11-18 Thread Pradeep Gatram

Fred is correct. A small suggestion to your code. Instead of

foo = Foo.find(foo.id)

simply use
foo.reload

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



[Rails] Re: Code changes are ignored due to code minor ver. were cached

2008-11-18 Thread Frederick Cheung



On Nov 18, 3:04 pm, Zhoran Tvalve <[EMAIL PROTECTED]>
wrote:
> Hi there!
> I study Ruby on Rails and met a problem.
>
> I placed a class definition code for class which is NOT a Model into
> separate file, assume MyToolClass.rb
>
> Then I started working on controller code and required 'MyToolClass'
>

use require_dependency instead of require.

Fred

> While working on controller code I also corrected some code in
> MyToolClass.rb, but it seemed, that changes in MyTooolClass.rb were
> ignored by Rails until I had restarted Mongrel.
>
> Q#1: Please write to me how can I tell Rails to reread source files
> those were changed after last use.
>
> Q#:2 Where to place files like MyToolclass.rb, which are nither Model,
> nor Controller?
>
> Thank you for your attention.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Session Corruption?

2008-11-18 Thread Frederick Cheung



On Nov 18, 2:55 pm, Nik B <[EMAIL PROTECTED]> wrote:
> That's the issue with (perhaps poor) design -  it's a temporary object
> never stored on the server. It's attributes are defined merely with
> attr_accessor's. At the end of the checkout process the virtual
> attributes are stored on Authorize.NET, and the actual record
> attributes are just an id and a customer_address_id which is used to
> retrieve it on Authorize.
>
in that case I'd store a hash of those attributes in the session
> Seems like perhaps it has something to do with the attributes_cache...
> but I can't find much information on how the attributes cache works.
>
Unlikely. attributes_cache is just to do with caching attributes that
are expensive to create (mostly datetimes)

Fred

> On Nov 18, 9:49 am, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>
> > On 18 Nov 2008, at 14:38, Nik B wrote:
>
> > > I didn't think I was storing soap objects... here is the object that
> > > is the last think I store and retrieve from the session:
>
> > Well the backtrace certain showed the soap serialization stuff getting  
> > called. if you're storing an activerecord objects you'll save yourself  
> > trouble by just storing its attributes (or just its id if its already  
> > saved).
>
> > Fred
>
> > > --- !ruby/object:ShippingAddress
> > > address: 123 MAIN ST
> > > attributes:
> > >  customer_address_id:
> > >  preview:
> > >  user_id:
> > >  label:
> > > attributes_cache: {}
>
> > > city: ANYTOWN
> > > country: US
> > > first_name: Firstname
> > > last_name: Lastname
> > > new_record: true
> > > phone_number: 555-555-
> > > residential: true
> > > state: NC
> > > zip: 5-
>
> > > On Nov 17, 7:27 pm, Frederick Cheung <[EMAIL PROTECTED]>
> > > wrote:
> > >> You're storing soap objects in your session ? I'm guessing wildly but
> > >> I'd guess that what's in the session references a class that was
> > >> unloaded between the two requests, so the unmarshaling code fails
> > >> horribly (if turning config.cache_classes on makes the problem go  
> > >> away
> > >> then that would be a strong indication that something of that nature
> > >> is the problem). One way around this would be to only store primitive
> > >> types like arrays and hashes in the session.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] How do I create an autocomplete text field that allows for multiple words/tags

2008-11-18 Thread Gishu Pillai

http://stackoverflow.com/questions/250408/how-do-i-implement-text-fields-with-autocomplete-for-habtm-fields

I have described the problem in details in the above post. What I'd
like is for the autocomplete field to allow the user to enter multiple
'tags' or 'categories' separated by commas. e.g. "Ruby, Rails,
autocomplete"
Currently I have auto-complete working for Comma separated tags...
However selecting tag#2 from the dropdown replaces all content in the
text field.. only the last selected tag is shown.
Any ideas?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: undefined method `to_query'

2008-11-18 Thread Mark Thomas

> >> Object.new.methods.include?('to_query')
> => false
> >> exit

You won't see it from IRB, because Rails extends Object with the
methods. Try it from within 'script/console" -- it works for me in
Rails 2.0.2 (not sure about 1.2.3--that's fairly outdated).

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



[Rails] undefined method `to_query'

2008-11-18 Thread Ian

I'm trying to use a gem to access an API but I'm getting the message
=>  undefined method `to_query'

I go into the terminal and run...

>> p RAILS_GEM_VERSION
"1.2.3"
=> nil
>> Object.new.methods.include?('to_query')
=> false
>> exit

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



[Rails] How to get results from database SQL query

2008-11-18 Thread Yan Oleg

I need to get results from SQL query to database.

I have an SQL statement, e.g.: SELECT MAX(my_field) max_my_field FROM
my_table WHERE id=5

I want to get the result, what is the max value. I have to get only one
record with a number, or null if no records found. Please provide Ruby
code to do this? (to store results in variable)
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: any_instance with rspec

2008-11-18 Thread Francis Fish

If you look at Ryan's cast number 71 he uses any_instance to stub out 
valid? on active record - this allows you to make sure, for example, to 
just go to the behaviour of the controller and use stuff like 
assigns[:fred].value == 'whatever'.

I'm really struggling with overriding new and returning a prebuilt 
object because I can't check the low-level assign on a multi-model 
controller.

Yeah, ok, I can say

assigns[:claim].should == @new_claim

But I wanted to check the fields in the claim and the address that 
belongs to it are all being hit.

Can't face learning mocha - no time right now.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Code changes are ignored due to code minor ver. were cached

2008-11-18 Thread Zhoran Tvalve

Hi there!
I study Ruby on Rails and met a problem.

I placed a class definition code for class which is NOT a Model into
separate file, assume MyToolClass.rb

Then I started working on controller code and required 'MyToolClass'

While working on controller code I also corrected some code in
MyToolClass.rb, but it seemed, that changes in MyTooolClass.rb were
ignored by Rails until I had restarted Mongrel.

Q#1: Please write to me how can I tell Rails to reread source files
those were changed after last use.

Q#:2 Where to place files like MyToolclass.rb, which are nither Model,
nor Controller?


Thank you for your attention.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Session Corruption?

2008-11-18 Thread Frederick Cheung


On 18 Nov 2008, at 14:38, Nik B wrote:

>
> I didn't think I was storing soap objects... here is the object that
> is the last think I store and retrieve from the session:
>
Well the backtrace certain showed the soap serialization stuff getting  
called. if you're storing an activerecord objects you'll save yourself  
trouble by just storing its attributes (or just its id if its already  
saved).

Fred

> --- !ruby/object:ShippingAddress
> address: 123 MAIN ST
> attributes:
>  customer_address_id:
>  preview:
>  user_id:
>  label:
> attributes_cache: {}
>
> city: ANYTOWN
> country: US
> first_name: Firstname
> last_name: Lastname
> new_record: true
> phone_number: 555-555-
> residential: true
> state: NC
> zip: 5-
>
> On Nov 17, 7:27 pm, Frederick Cheung <[EMAIL PROTECTED]>
> wrote:
>> You're storing soap objects in your session ? I'm guessing wildly but
>> I'd guess that what's in the session references a class that was
>> unloaded between the two requests, so the unmarshaling code fails
>> horribly (if turning config.cache_classes on makes the problem go  
>> away
>> then that would be a strong indication that something of that nature
>> is the problem). One way around this would be to only store primitive
>> types like arrays and hashes in the session.
>
> >


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



[Rails] Re: Session Corruption?

2008-11-18 Thread Nik B

That's the issue with (perhaps poor) design -  it's a temporary object
never stored on the server. It's attributes are defined merely with
attr_accessor's. At the end of the checkout process the virtual
attributes are stored on Authorize.NET, and the actual record
attributes are just an id and a customer_address_id which is used to
retrieve it on Authorize.

Seems like perhaps it has something to do with the attributes_cache...
but I can't find much information on how the attributes cache works.

On Nov 18, 9:49 am, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> On 18 Nov 2008, at 14:38, Nik B wrote:
>
>
>
> > I didn't think I was storing soap objects... here is the object that
> > is the last think I store and retrieve from the session:
>
> Well the backtrace certain showed the soap serialization stuff getting  
> called. if you're storing an activerecord objects you'll save yourself  
> trouble by just storing its attributes (or just its id if its already  
> saved).
>
> Fred
>
> > --- !ruby/object:ShippingAddress
> > address: 123 MAIN ST
> > attributes:
> >  customer_address_id:
> >  preview:
> >  user_id:
> >  label:
> > attributes_cache: {}
>
> > city: ANYTOWN
> > country: US
> > first_name: Firstname
> > last_name: Lastname
> > new_record: true
> > phone_number: 555-555-
> > residential: true
> > state: NC
> > zip: 5-
>
> > On Nov 17, 7:27 pm, Frederick Cheung <[EMAIL PROTECTED]>
> > wrote:
> >> You're storing soap objects in your session ? I'm guessing wildly but
> >> I'd guess that what's in the session references a class that was
> >> unloaded between the two requests, so the unmarshaling code fails
> >> horribly (if turning config.cache_classes on makes the problem go  
> >> away
> >> then that would be a strong indication that something of that nature
> >> is the problem). One way around this would be to only store primitive
> >> types like arrays and hashes in the session.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Session Corruption?

2008-11-18 Thread Nik B

I didn't think I was storing soap objects... here is the object that
is the last think I store and retrieve from the session:

--- !ruby/object:ShippingAddress
address: 123 MAIN ST
attributes:
  customer_address_id:
  preview:
  user_id:
  label:
attributes_cache: {}

city: ANYTOWN
country: US
first_name: Firstname
last_name: Lastname
new_record: true
phone_number: 555-555-
residential: true
state: NC
zip: 5-

On Nov 17, 7:27 pm, Frederick Cheung <[EMAIL PROTECTED]>
wrote:
> You're storing soap objects in your session ? I'm guessing wildly but  
> I'd guess that what's in the session references a class that was  
> unloaded between the two requests, so the unmarshaling code fails  
> horribly (if turning config.cache_classes on makes the problem go away  
> then that would be a strong indication that something of that nature  
> is the problem). One way around this would be to only store primitive  
> types like arrays and hashes in the session.

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



[Rails] Re: how to use has_many and belongs_to ?

2008-11-18 Thread Frederick Cheung


On 18 Nov 2008, at 12:51, BoBKilla wrote:

>
> Hello there,
> im kind of a newbie with ruby on rails and i have a question about
> has_many and belongs_to because i saw tutorials where they use it but
> i don't see how it works ? What if you don't use it ?
> In fact i don't see if it is actually usefull...
>
Well associations are pretty fundamental to Active Record. You don't  
have to use them but you'd just be creating a lot of work for yourself  
and missing out on a lot of the handy bits in rails.
http://guides.rails.info/association_basics.html is probably not a bad  
place to start.

Fred
> Please give me some light =)
>
> >


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



[Rails] Re: how to use has_many and belongs_to ?

2008-11-18 Thread Ar Chron

has_many / belongs_to is how you tell Rails that models are related...

Start reading here:

http://api.rubyonrails.org/

Look at the ActiveRecord::Base entry to begin your instruction 
Grasshopper...
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] how to use has_many and belongs_to ?

2008-11-18 Thread BoBKilla

Hello there,
im kind of a newbie with ruby on rails and i have a question about
has_many and belongs_to because i saw tutorials where they use it but
i don't see how it works ? What if you don't use it ?
In fact i don't see if it is actually usefull...

Please give me some light =)

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



[Rails] Re: rss feed is not detected in firefox ?

2008-11-18 Thread Duilio Ruggiero

Thani Ararsu wrote:
> my rails version is 2.2.0
> i have created a rss feed
> It is working fine in IE
> but in fire fox

what version?

> only xml content is showned
> like
> 
> "This XML file does not appear to have any style information associated
> with it. The document tree is shown below."
> 
> 
> any idea ?

An rss feed IS only XML (if you don't apply a style sheet)
There is a built-in style sheet for displaying feeds (that don't have a 
style sheet specified) in
IE, Safari and the last version of Firefox (probably you are using an 
old version)

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

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



[Rails] Re: classic_pagination error in rails-2.2

2008-11-18 Thread Frederick Cheung

The Inflector is now ActiveSupport::Inflector. A reminder, if you  
needed one, that classic pagination is unmaintained.

Fred
On 18 Nov 2008, at 13:09, Thani Ararsu wrote:

>
> uninitialized constant ActionController::Pagination::Inflector
>
> C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/ 
> active_support/dependencies.rb:428:in
> `load_missing_constant'
> C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/ 
> active_support/dependencies.rb:77:in
> `const_missing'
> vendor/plugins/classic_pagination/lib/pagination.rb:100:in
> `validate_options!'
> vendor/plugins/classic_pagination/lib/pagination.rb:132:in `paginate'
> app/controllers/info_controller.rb:117:in `photo'
> -e:2:in `load'
> -e:2
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Scoping option_groups_from_collection_for_select

2008-11-18 Thread Ed

How can I scope the options returned by
option_groups_from_collection_for_select?

Method calls look like this:  option_groups_from_collection_for_select
(collection, group_method, group_label_method, option_key_method,
option_value_method, selected_key = nil)

But say I want to limit the results returned by the option_key and
option_value methods to some particular scope?

For instance, using the sample code in rdoc:

  class Continent < ActiveRecord::Base
has_many :countries
# attribs: id, name
  end
  class Country < ActiveRecord::Base
belongs_to :continent
# attribs: id, name, continent_id
  end

I could get all countries grouped by continent with this:
  option_groups_from_collection_for_select
(@continents, :countries, :name, :id, :name, 3)

But say I had another class called Ally:

  class Alliance < ActiveRecord::Base
has_many :countries   #reciprocal belongs_to added to country
#attribs: id, name
  end

How could I scope the OGFCFS call so that it only listed countries
belonging to a particular alliance?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] rss feed is not detected in firefox ?

2008-11-18 Thread Thani Ararsu

my rails version is 2.2.0
i have created a rss feed
It is working fine in IE
but in fire fox
only xml content is showned
like

"This XML file does not appear to have any style information associated
with it. The document tree is shown below."


any idea ?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] classic_pagination error in rails-2.2

2008-11-18 Thread Thani Ararsu

uninitialized constant ActionController::Pagination::Inflector

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:428:in
`load_missing_constant'
C:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.0/lib/active_support/dependencies.rb:77:in
`const_missing'
vendor/plugins/classic_pagination/lib/pagination.rb:100:in
`validate_options!'
vendor/plugins/classic_pagination/lib/pagination.rb:132:in `paginate'
app/controllers/info_controller.rb:117:in `photo'
-e:2:in `load'
-e:2
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Hartford Ruby Group November meeting: 11/24

2008-11-18 Thread Dan Bernier

The November meeting is this Monday, 6-8 PM.

Flinn Mueller (http://www.actsasflinn.com/) will be talking about
rspec, and we'll hopefully hear stories from Voices that Matter
attendees.

We'll raffle off The Professional Ruby Collection: Mongrel, Rails
Plugins, Rails Routing, Refactoring to REST, and Rubyisms CD
http://www.amazon.com/Professional-Ruby-Collection-Refactoring-Addison-Wesley/dp/0132417995

GeeZeo offices
750 Main St, Hartford
Suite 1314
(next to the CVS)

Also, remember that our December meeting will be 12/15, to avoid the holidays.

See you Monday,
Dan

-- 
twitter @danbernier
http://invisibleblocks.wordpress.com
http://groups.google.com/group/hartford-ruby-brigade

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



[Rails] Re: Problem with gem

2008-11-18 Thread [EMAIL PROTECTED]

Hi Manisha,

Actually Gem installation need enough memory on your server/system and
Bandwidth.
or if it is not just download that gem and install specific.
like :
gem install rails-2.0.2.gem,

Thanks,
DeployD.

On Nov 18, 3:48 pm, Manisha <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am trying to install ROR in Ubuntu on my virtualbox VM.
> I followed the instruction on Documents for installation of the
> same.As i am working in office where we have to deal with proxy; i
> have also set the appropriate proxy.
> after installing Rubygems, I can do
>
> $ sudo gem update
>
> but cannot do
> $ sudo gem update --system
>
> or even  $ sudo gem install ..
>
> The Error which I am getting is
>
> ERROR:  http://gems.rubyforge.org/does not appear to be a repository
> ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
> Errno::ETIMEDOUT: Connection timed out - connect(2) (http://
> gems.rubyforge.org/yaml)
>
> I am unable to understand where the problem is. Can anybody help
> please?  :((
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Creating a Query and then a select box based off query results

2008-11-18 Thread Thorsten Müller

Roughly you will change the view when the user selects a server.
Use the onchange (not onclick) event of the select box
to trigger the next view.
Obviously that should be an Ajax call, since there is no
need to update the whole page.

something similar, a category select with subcategories:

the view with the main category select:

Kies een categorie
  <%= options_from_collection_for_select(@categories, "id",
"title", (@product.category ? @product.category.category_id : 0)) %>
  

the action to get the sub categories:

  def sub_category
@product = Product.find(params[:id])
@categories = Category.find(:all, :order => "title
ASC", :conditions => "category_id = #{params[:category_id]} AND
published=1")
respond_to do |format|
  format.js
end
  end

the ajax response used by this action:

page.replace(:category_sub, :partial => 'depot/products/
sub_category_select', :locals => {:categories => @categories, :product
=> @product})

and the partial used by the ajax response:


  <%= options_from_collection_for_select(categories, "id", "title",
product.category_id) %>


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



[Rails] Re: Best Practice for Timeliness?

2008-11-18 Thread MaD

that depends: generally spoken, business logic should be put into
models. but if you only want to change format, coloring, etc. thats a
typical helper-function.


On 18 Nov., 04:50, Ben Wilson <[EMAIL PROTECTED]> wrote:
> Hey, I want to highlight rows in an index view based on their
> timeliness. That is, is a record late, due soon, etc. Is it a better
> practice to put the business logic in the helper or model?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Best Practice for Timeliness?

2008-11-18 Thread Thorsten Müller

While business logic should in fact go into the model
(if possible, otherwise controller, never in the view or helpers),
this isn't exactly business logic. It's just a question about
how to display some given data and that goes into
the helper or view.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Problem with gem

2008-11-18 Thread Manisha

Hello,

I am trying to install ROR in Ubuntu on my virtualbox VM.
I followed the instruction on Documents for installation of the
same.As i am working in office where we have to deal with proxy; i
have also set the appropriate proxy.
after installing Rubygems, I can do

$ sudo gem update

but cannot do
$ sudo gem update --system

or even  $ sudo gem install ..

The Error which I am getting is

ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
Errno::ETIMEDOUT: Connection timed out - connect(2) (http://
gems.rubyforge.org/yaml)

I am unable to understand where the problem is. Can anybody help
please?  :((

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



[Rails] Excellent Job Opportunity: Lead Engineering (Ruby On Rails), New Delhi

2008-11-18 Thread Jitendra Singh

Hi All,

We are looking for motivated Ruby on Rails/Java technology
professionals with 3+ years of relevant experience and a strong
background in computer science, in particular Internet technologies.
The role would involve both hands-on development as well as mentoring
the existing team.

Position: Lead Engineering
Location: Okhla Phase 1, New Delhi

Skills:
• Evidence of strong technical skills in one or more of the following
areas is required:
J2EE (EJB, JSP, Servlets)/ PHP
Ruby on Rails (Preferred)
• Proficiency in a leading database system • Experience in OO design
and modeling (UML) • Experience working on open source projects •
Experience of leading teams of 4-5 professionals • Excellent
Communication Skills • Strong Analytical skills

About us: Qualtech is an ISO and Microsoft certified Company. It is a
Project Management and Software Development Company. Promoted by group
of IIT graduates, the company has an excellent track record of
providing software solutions to top names in national and
international market. We have positioned ourselves as Domain and
Technology agnostic Business Application Software Services Company.
And with that positioning, we have implemented several successful
projects across the spectrum of Microsoft (.net) and J2EE
technologies. We provide a very good work environment to our people
with immense opportunities for growth and development as per
individual's career aspirations. We are 100+ People strong company.

You can also visit us at www.qualtech-consultants.com

If you or someone you know would be interested in discussing
opportunities available, please e-mail me a copy of current resume (in
Word format) as well as a contact number and best time to speak.

Please feel free to email/ Call me if you have any queries.

Best Regards,
Jitendra Singh
Work: 011-41601994, ext-295
Direct: 011-46527938
Cell: 09891463198
Email: [EMAIL PROTECTED]
F-16, 3rd Floor
Okhla Phase - I
New Delhi - 110020
www.qualtech-consultants.com

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



[Rails] Best Practice for Timeliness?

2008-11-18 Thread Ben Wilson

Hey, I want to highlight rows in an index view based on their
timeliness. That is, is a record late, due soon, etc. Is it a better
practice to put the business logic in the helper or model?

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



[Rails] Re: Restless Rails

2008-11-18 Thread Rob Nichols

Yes, I'd do it with a custom controller method too.

Bas van Westing wrote:
> Hi All,
> 
> I would advise you to look at recipe 13 "Handle Multiple Models in
> One Form" from Advanced Rails Recipies (by Mike Clark, sold by
> pragmatic programmers). It a little too big to post here, so buy the
> PDF.
> I'm using it and it works great.
> 

However, it does assume the list of items belong_to another class. Of 
course I could create a class to hold those items, but I think it would 
just be easier to create a custom controller method.

> Don't try to invent the wheel yourself.

Surely that cliché is inappropriate as it is the wheel that is 
reinvented itself. I'm the Luddite that's resisting the reinvention. If 
anything I could be using that cliché myself asking the Rest advocates 
to stop reinventing the wheel :o)

However, my point isn't that Rest is bad, but rather that it should not 
be the only way to use Rails. I hoping that Restless Luddites like me 
will not be excluded in the splendidness that is Rails.

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

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



[Rails] Creating a Query and then a select box based off query results

2008-11-18 Thread [EMAIL PROTECTED]

Hello,

I am a newbie here and was hoping someone had some experience and
suggestions on how to accomplish the below task:

I would like to figure out how to give my users a prepopulated list
based off there selection.  I am creating am application that users
specific servers and would like to show them the list of suppliers who
build these servers.  For example, if they chose a server X200 the
next box would then prepopulate its self with the supplier thats is
responsible for building this server. Anyone have any idea how I would
go about doing this.  I have a query that pulls the data but I have no
idea what my next steps should be.

Thank You,

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



[Rails] Re: Difference between include and joins in find?

2008-11-18 Thread Frederick Cheung

Well to answer the question in the subject line, I wrote this a little
while back: 
http://www.spacevatican.org/2008/6/22/the-difference-between-include-and-joins
A key thing to note is that include in 2.1 and include in 2.0.2 are
different (but the 2.1 code will fall back to the 2.0.2 code if
necessary).
Does the companies table not have columns called ref_company_id ?

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



[Rails] Re: Missing js.erb template

2008-11-18 Thread Valentino Lun

Dear all

I found that there is some logical problem in my code. I will review it. 
Please ignore my post.

Thank you.

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

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



[Rails] Re: Rails Stability

2008-11-18 Thread glennswest

Your "code" is past being "old" in ruby and rails terms.
Almost everything has been updated/fixed and resolved.
I've got production sites that have been running for 6 months, with
a reboot at most once a month. (On windows). On linux,
no problem at all. Update and run it on passenger.

I run code on windows and linux, and find the portability is great.
Long with running it over half a dozen different databases.

Php is Not portable, nor stable from my past projects.


On Nov 18, 1:04 am, Fernando Perez <[EMAIL PROTECTED]>
wrote:
> Frederick Cheung wrote:
> > On 17 Nov 2008, at 16:09, Bobnation wrote:
>
> >> Don't let that one blog entry turn you away. Like Jeremy said, a lot
> >> of stuff can cause instabilities, including configuration. I would
> >> search around for some hosts and see which ones are having the
> >> greatest luck with mod_rails (or another config) and maybe even think
> >> about running your own virtual server somewhere just for the fun.
>
> > eg see
> >http://www.loudthinking.com/posts/30-myth-1-rails-is-hard-to-deploy
> > All the 37signals stuff will be moving to mod_rails soonish
>
> > Fred
>
> I run Nginx+Thin each in its own virtual machine. My Thin virtual
> machine only crashed once, but I can't tell you why, anyway it was
> simply a matter of restarting the VM. Probably a memory leak somewhere
> in the code.
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: sortable_element trouble

2008-11-18 Thread David Trasbo

David Trasbo wrote:

> Can anyone help me out here? This problem has twisted my brain for two
> days...

OK, after a bit of research I found a solution:

http://dev.rubyonrails.org/ticket/6489

Ghosting (for some reason) needs to be enabled to trigger a request...
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: dynamic condition for has_one and eager loading issue

2008-11-18 Thread [EMAIL PROTECTED]

Wow, that sounds complicated. :-)

However, I m really interested in this topic.
Maybe you can explain me the proposed "rails way" to accomplish for
example a relation which depends on the currently logged in user (just
as an example)

Thanks a lot in advance...
Volker

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



[Rails] Re: Difference between include and joins in find?

2008-11-18 Thread boblu

I finally get this right.

Here is the conclution.

In find method,

use ":join=>[:association_name]" will simply do a 'full join', which
drop all rows that do not match the association conditions.

use ":join=>['join table_b on table_a.id=table_b.xx']",  this is a
'full join' too.

use ":join=>['left(or right) join table_b on table_a.id=table_b.xx']",
this is the usual left or right join.


use ":include=>[:association_name]" will be supposed to do a 'left
outer join', this will work most of the time.
but I don't know why it sometimes generates wierd SQL statement like
this.

##   table 1: companies  ##
id  int
.

##   table 2: sections   ##
id int
ref_company_id  int
ref_meta_id  int


#  class Company  < ActiveRecord
#
has_one  :main_section,  :class=>"Section",  :foreign_key=>"ref_company_id", 
:conditions=>"ref_meta_id=0"
#
has_many  :all_sections, :class=>"Section",  :foreign_key=>"ref_company_id"
#  end

#  class Section < ActiveRecord
#
belongs_to :company, :class=>"Company", :foreign_key=>"ref_company_id"
#  end

Company.find(:all, :select=>'companies.*', :include=>
[:all_sections],  :conditions=>"sections.id<500")

*
Unknown column 'companies.ref_company_id' in 'field list':
SELECT `companies`.`id` AS t0_r0,
  `companies`.`ref_company_id` AS t0_r16,
  `companies`.`ref_meta_id` AS t0_r17,
  `sections`.`id` AS t1_r0,
  `sections`.`ref_company_id` AS t1_r1,
  `sections`.`ref_meta_id` AS t1_r2,
FROM`companies`  LEFT OUTER JOIN `sections` ON
sections.ref_meta_id = companies.id
WHERE  ( sections.id<500 )
**


On Nov 18, 2:57 pm, boblu <[EMAIL PROTECTED]> wrote:
> OK.
>
> I figured out that "join" is actually doing an "inner join" which
> filters the rows that don't have association.
> And "include" is actually doing an 'outter join' which shows all the
> rows from tables.
>
> But, however, I still can not figure out why that strange SQL
> statement comes out.
>
> Can anyone please help me?
>
> On Nov 18, 1:52 pm, boblu <[EMAIL PROTECTED]> wrote:
>
> > I had real weird problem here.
>
> > If I use "joins" in find, both development and production environment
> > give right answers.
> > But, when I use  "include" in find, the development environment goes
> > all right. However, the find method fails in production enviroment.
>
> > Let me describe this in detail.
>
> > I have two tables.
>
> > ##   table 1: companies  ##
> > id  int
> > .
>
> > ##   table 2: sections   ##
> > id int
> > ref_company_id  int
> > ref_meta_id  int
> > 
>
> > A company will have one section, and a section may have sub-sections.
> > when ref_meta_id is 0, the section is the main section of a company
> > whose id is ref_company_id.
> > when ref_meta_id is not  0, the section is a sub-section of a company
> > whose id is ref_company_id.
>
> > And here are the two models
>
> > #  class Company  < ActiveRecord
> > #    has_one  :main-
> > section,  :class=>"Section",  :foreign_key=>"ref_company_id", 
> > :conditions=>"ref_meta_id=0"
> > #    has_many  :all-
> > sections, :class=>"Section",  :foreign_key=>"ref_company_id"
> > #  end
>
> > #  class Section < ActiveRecord
> > #
> > belongs_to :company, :class=>"Company", :foreign_key=>"ref_company_id"
> > #  end
>
> > All these things are good in both development and production
> > environment.
> > #  Company.find(1).main-section
> > #  Company.find(1).all-sections
> > #  Section.find(1).company
>
> > Now comes to the find method used in controller.
> > First use joins, as I said before, the following methods went well in
> > both development and production enviroment.
> > #  Company.find(:all, :select=>'companies.*', :joins=>[:all-
> > sections],  :conditions=>"companies.id<500")
> > #  Company.find(:all, :select=>'companies.*', :joins=>[:all-
> > sections],  :conditions=>"sections.id<500")
>
> > Then use include,
> > #  Company.find(:all, :select=>'companies.*', :joins=>[:all-
> > sections],  :conditions=>"companies.id<500")
> > this went well in both development and production enviroment.
>
> > However,
> > #  Company.find(:all, :select=>'companies.*', :joins=>[:all-
> > sections],  :conditions=>"sections.id<500")
> > this went well in development environment, but in production
> > environment, I get this error.
>
> > *
> > Unknown column 'companies.ref_company_id' in 'field list':
> > SELECT `companies`.`id` AS t0_r0,
> >               `companies`.`ref_company_id` AS t0_r16,
> >               `companies`.`ref_meta_id` AS t0_r17,
> >               `sections`.`id` AS t1_r0,
> >               `sections`.`ref_company_id` AS t1_r1,
> >               `sections`.`ref_meta_id` AS t1_r2,
> > FROM    `companies`  LEFT OUTER JOIN `sections` ON
> > sections.ref_meta_id =