[Rails] Re: Removing part of a String

2009-05-07 Thread Svetlana Vt

JannaB wrote:
> I want to get the names of all files in a given directory. When I
> employ the Dir[] method, it returns the name of the files with the
> pathname I invoked it with:
> 
>   allfiles = Dir["public/images/icons/**"]
> 
> So to remedy this, I try to sub out the directory prefixing the
> string, as:
> 
>   for fil in allfiles do
>  render :text => fil.sub( "public/images/icons/",
> "" )
>   end
> 
> Yet even this doesn't remove the directory name. Clearly I am doing
> something stooopid, but just don't see it. Can someone please have a
> look and see what I am missing here? Thanks you, Janna

require 'pathname'
allfiles = Pathname.new('/opt')
allfiles.children.map{|a| a.basename.to_s}

or

Dir.chdir("/opt") do
allfiles = Dir["**"]
end
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Rails SequencedHash source file.

2009-05-07 Thread Eddy RB

Rick Lloyd wrote:
> gem install collections
> 
> require 'collections'

That does it!! Thanks.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Removing part of a String

2009-05-07 Thread 7stud --

Rick Lloyd wrote:
> Dir.entries("public/images/icons") should do nicely...

And in any case:

fil = "public/images/icons/hello.ico"
p fil.sub("public/images/icons/", "")

--output:--
"hello.ico"

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

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



[Rails] filter_parameter_logging for multi model forms

2009-05-07 Thread Ram

Hi all,

I have a multi model form setup in the classic Ryan Bates Complex
forms style (railscasts.com/episodes/73) for my signup page.

The two models in this are the Account model and the User model and
this structure cannot be changed right now. The User model has
password and password_conf attributes which are, unfortunately, taken
alongwith the rest of the User's attributes into an array
user_attributes[]. This array is then processed in the Account model
as is the method shown in the above screencasts.

Now i understand filter_parameter_logging works for hashes and sub
hashes. But in this case, its an array. Any ideas on how i can handle
this? Hack into filter_parameter_logging?

Any and all thoughts are most welcome!

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



[Rails] Re: Rails SequencedHash source file.

2009-05-07 Thread Rick

gem install collections

require 'collections'


On May 7, 5:48 pm, Eddy Lu  wrote:
> I am testing AlumniOnRails
> (http://rubyforge.org/frs/?group_id=2959&release_id=17170) which is
> based on Rails 1.2.6 (I know it's outdated) and managed to get it up,
> installed the required gems, created and migrated the data and most of
> the basic alumni functionalities are up but one, the part that is broken
> seems to be missing a library and yet I can't seem to find it after a
> few reasonable searches.
>
> The logger shows *no such file to load -- collections/sequenced_hash*
> with a line within the controller having the code of *require
> 'collections/sequenced_hash* which is quite obvious that the
> *sequence_hash* library is missing.
>
> A few searches on Google shows a few references, one with the closest
> pointer ishttp://collections.rubyforge.org/classes/SequencedHash.html
> but unfortuntely the source link is dead. Does anyone keep this kind of
> old file or point me to somewhere it is? Thank you
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: RMagick, ImageMagick, Passenger and Dreamhost

2009-05-07 Thread Daniel2Surf

And also,
If i do this:

ruby -r RMagick -e"puts Magick::Long_version"

It shows the old version of ImageMagick

And if i set config.cache_classes to false on my environments/
production.rb everithing works fine...
but slowly...

May be the solution is to reset this cache_classes?

Thanks everybody.
Daniel

On 8 maio, 00:57, Daniel2Surf  wrote:
> Hey Rick,
> Thanks for answer..
> Yes i did compile my own ImageMagick and installed RMagick.
> Everything is like you said. But still no success...
>
> Same error message: This installation of RMagick was configured with
> ImageMagick 6.5.1 but ImageMagick 6.0.6 is in use.
>
> I think it's not possible to set or pass environment variables to
> passenger, apache...
>
> I'm trying this for almost a week...
> Please help me... if somebody uses Dreamhost or any similar shared
> hosting and did this please tell me how...
>
> So far... thanks for the help.
> Daniel
>
> On May 7, 4:25 pm, Rick  wrote:
>
> > It looks like you need to check the following:
>
> > 1) Did you install your own version of ImageMagick in your local
> > directory?  Both of the following two Unix commands should give the
> > same response. NOTE: YOUR_HOME should be the path to your home
> > directory.  i.e.: I see /Users/rick/local/bin/Magick-config on my
> > system.
>
> > $ ls ~/local/bin/Magick-config
> > YOUR_HOME/local/bin/Magick-config
> > $ which Magick-config
> > YOUR_HOME/local/bin/Magick-config
> > $
>
> > If the first command fails, you need to re-install ImageMagick paying
> > attention to the instructions for setting "--prefix=" in the
> > configuration step.  After the re-install of ImageMagick you'll need
> > to reinstall RMagick.
>
> > If the first command succeeds but the second fails, you need to add
> > the RMagick export settings to your shell's runtime command file.
>
> > Shell               RC File
> > bash               ~/.profile or ~/.bashrc
> > csh                 ~/.login or ~/.cshrc
> > tcsh                ~/.login or ~/.tcshrc
> > ksh                 ~/.profile or ~/.kshrc
> > sh                   ~/.profile
>
> > Edit your RC file and add the following lines:
>
> > $ export PATH=$HOME/local/bin:$PATH
> > $ export LDFLAGS=-L/$HOME/local/lib
> > $ export CPPFLAGS=-I/$HOME/local/include
> > $ export LD_RUN_PATH=$HOME/local/lib
>
> > Log out and back in and retry the "ls ~/local/bin/Magick-config" and
> > "which Magick-config".  The results of both commands should now be
> > identical.  If you check the file (more ~/local/bin/Magick-config) you
> > should see the prefix, exec_prefix, libdir, and included_dir as
> > pointing at your home directory.  RMagick should work now.
>
> > On May 6, 7:11 pm, Daniel2Surf  wrote:
>
> > > I need to use the newest version of RMagick, so i did everything as
> > > they say on this wiki:http://wiki.dreamhost.com/index.php/RMagick
>
> > > But, my Rails app isn't working, here is the error:
>
> > > This installation of RMagick was configured with ImageMagick 6.5.1 but
> > > ImageMagick 6.0.6 is in use.
>
> > > I tried to set the environment variable: LD_LIBRARY_PATH... but no
> > > success...
> > > I've read a lot of people with the same problem, but i couldn't find
> > > the solution.
> > > I guess the problem is to set a environment variable in passenger.
> > > Does anybody can help me?
>
> > > Thanks a lot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: RMagick, ImageMagick, Passenger and Dreamhost

2009-05-07 Thread Daniel2Surf

Hey Rick,
Thanks for answer..
Yes i did compile my own ImageMagick and installed RMagick.
Everything is like you said. But still no success...

Same error message: This installation of RMagick was configured with
ImageMagick 6.5.1 but ImageMagick 6.0.6 is in use.

I think it's not possible to set or pass environment variables to
passenger, apache...

I'm trying this for almost a week...
Please help me... if somebody uses Dreamhost or any similar shared
hosting and did this please tell me how...

So far... thanks for the help.
Daniel

On May 7, 4:25 pm, Rick  wrote:
> It looks like you need to check the following:
>
> 1) Did you install your own version of ImageMagick in your local
> directory?  Both of the following two Unix commands should give the
> same response. NOTE: YOUR_HOME should be the path to your home
> directory.  i.e.: I see /Users/rick/local/bin/Magick-config on my
> system.
>
> $ ls ~/local/bin/Magick-config
> YOUR_HOME/local/bin/Magick-config
> $ which Magick-config
> YOUR_HOME/local/bin/Magick-config
> $
>
> If the first command fails, you need to re-install ImageMagick paying
> attention to the instructions for setting "--prefix=" in the
> configuration step.  After the re-install of ImageMagick you'll need
> to reinstall RMagick.
>
> If the first command succeeds but the second fails, you need to add
> the RMagick export settings to your shell's runtime command file.
>
> Shell               RC File
> bash               ~/.profile or ~/.bashrc
> csh                 ~/.login or ~/.cshrc
> tcsh                ~/.login or ~/.tcshrc
> ksh                 ~/.profile or ~/.kshrc
> sh                   ~/.profile
>
> Edit your RC file and add the following lines:
>
> $ export PATH=$HOME/local/bin:$PATH
> $ export LDFLAGS=-L/$HOME/local/lib
> $ export CPPFLAGS=-I/$HOME/local/include
> $ export LD_RUN_PATH=$HOME/local/lib
>
> Log out and back in and retry the "ls ~/local/bin/Magick-config" and
> "which Magick-config".  The results of both commands should now be
> identical.  If you check the file (more ~/local/bin/Magick-config) you
> should see the prefix, exec_prefix, libdir, and included_dir as
> pointing at your home directory.  RMagick should work now.
>
> On May 6, 7:11 pm, Daniel2Surf  wrote:
>
> > I need to use the newest version of RMagick, so i did everything as
> > they say on this wiki:http://wiki.dreamhost.com/index.php/RMagick
>
> > But, my Rails app isn't working, here is the error:
>
> > This installation of RMagick was configured with ImageMagick 6.5.1 but
> > ImageMagick 6.0.6 is in use.
>
> > I tried to set the environment variable: LD_LIBRARY_PATH... but no
> > success...
> > I've read a lot of people with the same problem, but i couldn't find
> > the solution.
> > I guess the problem is to set a environment variable in passenger.
> > Does anybody can help me?
>
> > Thanks a lot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails SequencedHash source file.

2009-05-07 Thread Eddy Lu

I am testing AlumniOnRails
(http://rubyforge.org/frs/?group_id=2959&release_id=17170) which is
based on Rails 1.2.6 (I know it's outdated) and managed to get it up,
installed the required gems, created and migrated the data and most of
the basic alumni functionalities are up but one, the part that is broken
seems to be missing a library and yet I can't seem to find it after a
few reasonable searches.

The logger shows *no such file to load -- collections/sequenced_hash*
with a line within the controller having the code of *require
'collections/sequenced_hash* which is quite obvious that the
*sequence_hash* library is missing.

A few searches on Google shows a few references, one with the closest
pointer is http://collections.rubyforge.org/classes/SequencedHash.html
but unfortuntely the source link is dead. Does anyone keep this kind of
old file or point me to somewhere it is? 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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 3 code...

2009-05-07 Thread Sheldon Finlay

You could look at the Rails 3 branch at github:

http://github.com/rails/rails/tree/3-0-unstable

On May 7, 9:14 pm, Rahil Kumar 
wrote:
> I would like to see few examples in Rails 3 and would like to see few
> Rails 3 code.
>
> I know, few samples were shown at Rails conference. Can any one point me
> few of them.
>
> Thanks
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: triple state radio buttons

2009-05-07 Thread Andrew Vargo

What if you have the third/null value hidden? You can use javascript
for a "clear choice" link or something, which would check the 3,
hidden radio button.  It could also be the default for new.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Marnen Laibow-Koser

Todd Fox wrote:
> thanks Marnen and everyone, do you know of any examples or something i 
> can have a look at to get my head around it?

What's to get your head around?  Just pretend your XML file is an HTML 
page, and proceed accordingly with your favorite template language (ERb, 
Builder, Haml, Markaby, whatever).  There's no new concept involved.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Todd Fox

thanks Marnen and everyone, do you know of any examples or something i 
can have a look at to get my head around it?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Marnen Laibow-Koser

Todd Fox wrote:
> sorry more info on what it's used for would help, the xml is being read 
> by google maps api so we can load html code inside the popup bubble.
> 
> so yeah we dont really control the consuming end :(

It seems to me, then, that you have two good options.  Either use ERb 
and/or Builder to put the HTML in the XML DOM, or (if the HTML has to be 
a string) use a CDATA section.  Don't make your life harder with all 
those &entities;.

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
mar...@marnen.org
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Todd Fox

sorry more info on what it's used for would help, the xml is being read 
by google maps api so we can load html code inside the popup bubble.

so yeah we dont really control the consuming end :(
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: triple state radio buttons

2009-05-07 Thread zambezi

I appreciate the answers and help.

So I added a third radio button to the group. Remember that what I
need is a three state situation (null, true, false).  This of course
effectively gives me a quadruple state.  So I set the third radio
button's value to NIL which gets me back to a three state situation..

Now let me provide a little background.
This is being used for a lengthy questionnaire (there are 50+ sets of
questions).  In short, part of good questionnaire design requires that
the design doesn't bias the respondant to particular answers.

So I don't want the radio button group to show a default value.  It
potentially confuses respondants and may bias their input.   However
with the above configuration (the third radio button value of NIL),
this becomes the default value and is diplayed to user as checked .
Is there a way to avoid this.  If I am going to use a three button
group configuration, I need to have them all unchecked initially.

Thanks,
Bill

On May 7, 6:31 pm, "E. Litwin"  wrote:
> As the previous poster said, provide a "Neither" or "None" option and
> have that one be selected as the default when the page loads.
> That is much easier for a user to understand as well.
>
> On May 7, 2:28 pm, Hassan Schroeder 
> wrote:
>
> > On Thu, May 7, 2009 at 2:22 PM, zambezi  wrote:
> > > It appears that some ivory towered radio button designer never
> > > conceived that a user might click on a radio button group, change
> > > their mind and want to undo the click therefore returning to a false-
> > > false state.
>
> > Quoting the HTML 4 spec:
>
> > If no radio button in a set sharing the same control name is initially "on",
> > user agent behavior for choosing which control is initially "on" is 
> > undefined.
> > Note. Since existing implementations handle this case differently, the
> > current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4),
> > which states:
>
> >   At all times, exactly one of the radio buttons in a set is checked.
> >   If none of the  elements of a set of radio buttons specifies
> >   `CHECKED', then the user agent must check the first radio button
> >   of the set initially.
>
> > Since user agent behavior differs, authors should ensure that in each
> > set of radio buttons that one is initially "on".
> > 
>
> > If you want a "no preference" option, you should provide one explicitly.
>
> > FWIW,
> > --
> > Hassan Schroeder  hassan.schroe...@gmail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Observers or callbacks?

2009-05-07 Thread zubin

I'd really like to know the answer to that too!

On Mar 21, 11:52 am, tekwiz  wrote:
> Thanks elioncho! I understand that it is a best practice to separate
> certain functionality out of models into observers.
>
> I guess I should clarify my question... Is there any _technical_
> reason to use observers instead of callbacks or visa versa.
>
> -- TW
>
> On Mar 20, 8:15 pm, elioncho  wrote:
>
> > Hi tekwiz,
>
> > This is excerpt is from Agile Web Development with Rails:
>
> > Callbacks are a fine technique, but they can sometimes result in a
> > model class
> > taking on responsibilities that aren’t really related to the nature of
> > the model.
> > For example, on page 385 we created a callback that generated a log
> > message
> > when an order was created. That functionality isn’t really part of the
> > basic
> > Order class—we put it there because that’s where the callback
> > executed.
> > Active Record observers overcome that limitation. An observer
> > transparently
> > links itself into a model class, registering itself for callbacks as
> > if it were part
> > of the model but without requiring any changes in the model itself.
>
> > On Mar 20, 4:11 pm, tekwiz  wrote:
>
> > > Why use an Observer for a single model rather than using a callback in
> > > the ActiveRecord object?  They seem like they work identically.  Is
> > > there a difference I'm missing?
>
> > > For example, these seem like they would do the same thing:
>
> > >   class User < ActiveRecord::Base
> > >     after_create :send_welcome
>
> > >     protected
> > >       def send_welcome
> > >         UserMailer.send_welcome(self)
> > >       end
> > >   end
>
> > >   class UserObserver < ActiveRecord::Observer
> > >     def after_create(user)
> > >       UserMailer.send_welcome(user)
> > >     end
> > >   end
>
> > > -- TW
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Rails 3 code...

2009-05-07 Thread Rahil Kumar

I would like to see few examples in Rails 3 and would like to see few
Rails 3 code.

I know, few samples were shown at Rails conference. Can any one point me
few of them.

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

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



[Rails] Re: Removing part of a String

2009-05-07 Thread Rick

Dir.entries("public/images/icons") should do nicely...

On May 7, 11:06 am, JannaB  wrote:
> I want to get the names of all files in a given directory. When I
> employ the Dir[] method, it returns the name of the files with the
> pathname I invoked it with:
>
>       allfiles = Dir["public/images/icons/**"]
>
> So to remedy this, I try to sub out the directory prefixing the
> string, as:
>
>       for fil in allfiles do
>              render :text => fil.sub( "public/images/icons/",
> "" )
>       end
>
> Yet even this doesn't remove the directory name. Clearly I am doing
> something stooopid, but just don't see it. Can someone please have a
> look and see what I am missing here? Thanks you, Janna
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: triple state radio buttons

2009-05-07 Thread E. Litwin

As the previous poster said, provide a "Neither" or "None" option and
have that one be selected as the default when the page loads.
That is much easier for a user to understand as well.

On May 7, 2:28 pm, Hassan Schroeder 
wrote:
> On Thu, May 7, 2009 at 2:22 PM, zambezi  wrote:
> > It appears that some ivory towered radio button designer never
> > conceived that a user might click on a radio button group, change
> > their mind and want to undo the click therefore returning to a false-
> > false state.
>
> Quoting the HTML 4 spec:
>
> If no radio button in a set sharing the same control name is initially "on",
> user agent behavior for choosing which control is initially "on" is undefined.
> Note. Since existing implementations handle this case differently, the
> current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4),
> which states:
>
>   At all times, exactly one of the radio buttons in a set is checked.
>   If none of the  elements of a set of radio buttons specifies
>   `CHECKED', then the user agent must check the first radio button
>   of the set initially.
>
> Since user agent behavior differs, authors should ensure that in each
> set of radio buttons that one is initially "on".
> 
>
> If you want a "no preference" option, you should provide one explicitly.
>
> FWIW,
> --
> Hassan Schroeder  hassan.schroe...@gmail.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: projects works then breaks intermittently - mysql, linux

2009-05-07 Thread Freddy Andersen

Adam,

There is NO error report above... The output from you log file is
missing in this post. Please repost the error "report".
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: json formatting

2009-05-07 Thread robdoan

you can use except option in to_json
Example :
  @booking.to_json(:except=>[:updated_at,:property_id,:created_at]
and to get rid of booking. From rails 2.1+ you should configure in
config/initializers/new_rails_defaults.rb file  :
  ActiveRecord::Base.include_root_in_json = false


On May 6, 9:13 pm, lyntaff  wrote:
> I'm really new to rendering formats with rails and would appreciate a
> little help with a json issue.
>
> I have created a booking model in which I would like to sync with a
> jquery calendar called "full calendar" through json. They have an
> example json script output with the following:
>
> [
>    {
>       "id":1,
>       "title":"Event1",
>       "start":"2009-05-10",
>    },
>    {
>       "id":2,
>       "title":"Event2",
>       "start":"2009-05-20",
>       "end":"2009-05-22",
>       "url":"http:\/\/yahoo.com\/"
>    }
> ]
>
> When using the json format in rails I get:
>
> [
>    {
>       "booking":{
>          "updated_at":"2009-05-01T15:42:44Z",
>          "title":"Booking",
>          "property_id":1,
>          "id":1,
>          "end":"2009-05-19",
>          "start":"2009-05-06",
>          "created_at":"2009-05-01T15:42:44Z"
>       }
>    },
>    {
>       "booking":{
>          "updated_at":"2009-05-06T09:09:48Z",
>          "title":"Booking",
>          "property_id":1,
>          "id":2,
>          "end":"2009-08-26",
>          "start":"2009-08-19",
>          "created_at":"2009-05-06T09:09:48Z"
>       }
>    }
> ]
>
> How do I change how the json format is rendered within rails 2. I need
> to get rid of "booking", "updated_at", property_id" and created_at".
>
> Thanks for any help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: projects works then breaks intermittently - mysql, linux

2009-05-07 Thread Adam Akhtar

hi guys, the error report above was taken from the development.log. Ill 
rerun it later today when i get home and get more info for 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 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Receiver for *_path or *_url

2009-05-07 Thread docpneumo

Perhaps to clarify: I realize that what ever happens to be self
whenever the method is encountered is sent the message in the examples
I posted. I'm looking for the intended receiver so that I can use
something like:

  link_to 'Show', recvr.product_path(@product)

in my RColumn instances.

On May 7, 4:23 pm, docpneumo  wrote:
> I'm trying to find out the receiver for *_path messages as in:
>       link_to 'Show', product_path(@product)
>
> This came up when I moved the creation of view fragments into objects
> (RColumn) intended to encapsulate the view behaviors of the various
> fields in a record as part of an exploration of dynamic scaffolding
> (e.g. streamlined). Those objects do not have a product_path() method,
> of course. I thought at first that the controller using the RColumns
> within a view would be the receiver, but that appears to not be true.
> I suspect the receiver is a routing mapper object but do not know how
> to make that object available for use in my RColumn.
>
> BTW. The alternate form:
>                 link_to 'Show', { :controller => 'products', :action
> => 'show', :id => @product.id }
>           works in the RColumn context.
>
> Any suggestions?
>
> Doc Pneumo

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



[Rails] Re: sum - wrong number of arguments?

2009-05-07 Thread Milan Dobrota

They have some monkey patches in the project.

Tom Z Meinlschmidt wrote:
> maybe
> 
> what about "gems update" and update all the gems installed?
> 
> tom
> 
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] HABTM pregunta

2009-05-07 Thread Me

I have 2 habtm relations:

FORM <- HABTM-> COMPANIES
FORM <- HABTM -> SITES

Is there an easy way to do a query like:

Find out what sites belong to what company related to the form?

Also is there a better or more efficient way of setting this kind of
scenario up?

The FORM can have multiple companies associated as well as multiple
sites belonging to each company.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails plain ajax

2009-05-07 Thread robdoan

try using Jrails plugin (http://github.com/aaronchi/jrails/tree/
master)

On May 7, 5:25 am, Joshua Partogi  wrote:
> Dear all,
> Does anybody know a good reference for sending ajax request to rails without
> using the rails ajax helper? I want to use other framework, namely jQuery.
> Because without using the ajax helper from rails I encounter an authenticity
> error from rails.
>
> Thank you very much in advance,
>
> --
> If you can't believe in God the chances are your God is too small.
>
> Read my blog:http://joshuajava.wordpress.com/
> Follow us on twitter:http://twitter.com/scrum8
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: hide attribute from scaffolding

2009-05-07 Thread pb pb

Frederick Cheung wrote:
> On 7 May 2009, at 13:47, Bogdan Pop 
> wrote:
> 
>>
>> Hey,
>>
>> I have a simple model having some attributes. One of those  
>> attributes is
>> an overall grade, which I don't want users to be able to edit it on
>> their own. I display all the info in the database using a scaffold.
>>
>> However, while scaffolding, I can see and edit the grade attribute,
>> which I only want to be displayed.
> 
> Just edit the erb files the scaffold generator (and don't forget to
> enforce that people should be allowed to edit grades, you may want to
> look at attr_accessible/attr_protected )
> 
> Fred

Hey Fred... People are allowed to edit grades. The overall grade is 
applied to a photo, and people can rate it, but each one of the ratings 
is kept somewhere else. The grade attribute here holds only the 
arithmetic media of all rates people placed.

I thought there's some smarter way to hide it from the scaffolding 
except working inside the view...
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: triple state radio buttons

2009-05-07 Thread Hassan Schroeder

On Thu, May 7, 2009 at 2:22 PM, zambezi  wrote:

> It appears that some ivory towered radio button designer never
> conceived that a user might click on a radio button group, change
> their mind and want to undo the click therefore returning to a false-
> false state.

Quoting the HTML 4 spec:

If no radio button in a set sharing the same control name is initially "on",
user agent behavior for choosing which control is initially "on" is undefined.
Note. Since existing implementations handle this case differently, the
current specification differs from RFC 1866 ([RFC1866] section 8.1.2.4),
which states:

  At all times, exactly one of the radio buttons in a set is checked.
  If none of the  elements of a set of radio buttons specifies
  `CHECKED', then the user agent must check the first radio button
  of the set initially.

Since user agent behavior differs, authors should ensure that in each
set of radio buttons that one is initially "on".


If you want a "no preference" option, you should provide one explicitly.

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

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



[Rails] Receiver for *_path or *_url

2009-05-07 Thread docpneumo

I'm trying to find out the receiver for *_path messages as in:
  link_to 'Show', product_path(@product)

This came up when I moved the creation of view fragments into objects
(RColumn) intended to encapsulate the view behaviors of the various
fields in a record as part of an exploration of dynamic scaffolding
(e.g. streamlined). Those objects do not have a product_path() method,
of course. I thought at first that the controller using the RColumns
within a view would be the receiver, but that appears to not be true.
I suspect the receiver is a routing mapper object but do not know how
to make that object available for use in my RColumn.

BTW. The alternate form:
link_to 'Show', { :controller => 'products', :action
=> 'show', :id => @product.id }
  works in the RColumn context.

Any suggestions?

Doc Pneumo

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



[Rails] Re: triple state radio buttons

2009-05-07 Thread zambezi

Thanks for the reply, Philip.

Dropdown boxes are cumbersome visually and ergonomically for the user
and I would rather not go there.

If I have a pair of grouped Ruby generated radio buttons, then
following are the initial possibilities or states:

false - false (in which case presumably a null is returned)
false - true (returns a 0)
true - false (returns a non-zero)

It appears that some ivory towered radio button designer never
conceived that a user might click on a radio button group, change
their mind and want to undo the click therefore returning to a false-
false state.  Some languages providing for a user interface have
caught on, some haven't.

Is it perhaps possible to do this by grouping a couple of checkboxes
and set then them up so that the user can select either one or none??

Thanks again,
Bill
Th



On May 7, 2:55 pm, Philip Hallstrom  wrote:
> > Can I coax a pair of radio buttons to consistently maintain their
> > triple state functionality (null, true, false)?
>
> > In others words allow the user to undo a response and return the
> > control to a null state (nothing selected).
>
> > I hope this isn't coming down to some sort of Javascript workaround.
>
> I don't think so.  radio button parameters are either
>
> ... passed with a value (if clicked)
> or
> ... passed with an empty value or not passed at all (if not clicked)
>
> There's no way to distinguish b/n unclicked (which would be your false
> I assume) and null.
>
> Why not turn them into drop downs with blank/true/false as values?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Removing part of a String

2009-05-07 Thread Philip Hallstrom


On May 7, 2009, at 2:06 PM, JannaB wrote:

>
> I want to get the names of all files in a given directory. When I
> employ the Dir[] method, it returns the name of the files with the
> pathname I invoked it with:
>
>  allfiles = Dir["public/images/icons/**"]
>
> So to remedy this, I try to sub out the directory prefixing the
> string, as:
>
>  for fil in allfiles do
> render :text => fil.sub( "public/images/icons/",
> "" )
>  end
>
> Yet even this doesn't remove the directory name. Clearly I am doing
> something stooopid, but just don't see it. Can someone please have a
> look and see what I am missing here? Thanks you, Janna


File.basename("/home/gumby/work/ruby.rb")  #=> "ruby.rb"
File.basename("/home/gumby/work/ruby.rb", ".rb")   #=> "ruby"

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



[Rails] Removing part of a String

2009-05-07 Thread JannaB

I want to get the names of all files in a given directory. When I
employ the Dir[] method, it returns the name of the files with the
pathname I invoked it with:

  allfiles = Dir["public/images/icons/**"]

So to remedy this, I try to sub out the directory prefixing the
string, as:

  for fil in allfiles do
 render :text => fil.sub( "public/images/icons/",
"" )
  end

Yet even this doesn't remove the directory name. Clearly I am doing
something stooopid, but just don't see it. Can someone please have a
look and see what I am missing here? Thanks you, Janna
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Setting Up Setters

2009-05-07 Thread Frederick Cheung



On 7 May 2009, at 13:55, rapdup  wrote:

>
> If I have a setter method that needs to manipulate the incoming value
> before setting itself, how can I do this without it be self
> referencing? In the example below, I've defined "start_date=", so how
> do I now save a value to start_date?
>

Look for write_attribute

Fred
> thx
>
> Ex:
> class Event
>   def start_date=(new_start_date)
>   self.start_date = new_start_date unless new_start_date >=
> start_date
>   end
> end
>
>
> >

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



[Rails] Re: hide attribute from scaffolding

2009-05-07 Thread Frederick Cheung



On 7 May 2009, at 13:47, Bogdan Pop   
wrote:

>
> Hey,
>
> I have a simple model having some attributes. One of those  
> attributes is
> an overall grade, which I don't want users to be able to edit it on
> their own. I display all the info in the database using a scaffold.
>
> However, while scaffolding, I can see and edit the grade attribute,
> which I only want to be displayed.

Just edit the erb files the scaffold generator (and don't forget to  
enforce that people should be allowed to edit grades, you may want to  
look at attr_accessible/attr_protected )

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

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



[Rails] Re: segmentation fault from mysql_adapter.rb

2009-05-07 Thread Gregg H.

Gregg H. wrote:
> I am also getting this, which I believe is related to the same problem:
> 
> ==  InitialStructureAndData: migrating 
> 
> -- create_table("areas", {:force=>true})
> rake aborted!
> An error has occurred, all later migrations canceled:
> 
> undefined method `each' for #
> 
> (See full trace by running task with --trace)

Fixed the problem.  This solves both of my errors:

http://forums.aptana.com/viewtopic.php?f=20&t=7563&p=27407&hilit=libmysql.dll#p27407
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: passing hard-coded values to controller

2009-05-07 Thread Colin Law
2009/5/7 big poppa 

>
> Suppose I wanted to do this. Wouldn't the syntax be (in config/
> routes.rb)
>
> map.connect '/patients/find', :controller=>'patient', :action=>'find'


Make sure it is before map.resources :patient otherwise this will be seen
first and you will get the problem you have described.  Also I do not put a
leading / when using map.connect but I do not know whether that is an issue
or not. So I would put map.connect 'patients/find' 

Use
rake routes
to show you the current mapping.

Colin


>
> prepended to the standard, scaffold generated
>
> map.connect ':controller/:action/:id'
> map.connect ':controller/:action/:id.:format'
>
> --b
>
> On May 7, 12:06 am, Colin Law  wrote:
> > Since find is not one of the standard actions, have you included a
> specific
> > route for patients/find?  The default routes generated by map.resources
> > :patients will assume that find is a patient id, expecting to see
> patients/2
> > for example.
> >
> > Colin
> >
> > 2009/5/6 big poppa 
> >
> >
> >
> > > sorry, that's a typo. it appears the way you suggested in my code (it
> > > compiles).
> >
> > > i'll look into the routing some more, i was ready to bash my head in
> > > last night and couldn't take it any more...
> >
> > > --b
> >
> > > On May 6, 12:59 am, Gul  wrote:
> > > > The way you are receiving parameter is wrong it should be like this
> >
> > > >   @patients = Patient.find(:all, :conditions => { :location =>params
> > > > [:search_string] })
> >
> > > > GUL
> >
> > > > On May 6, 12:40 pm, big poppa  wrote:
> >
> > > > > given the following code snippet:
> >
> > > > > class PatientsController < ApplicationController
> > > > > ...
> > > > > def find
> > > > >   @patients = Patient.find(:all, :conditions => { :location =>
> > > > > [params:search_string] })
> > > > > end
> >
> > > > > I would like to add a few hard coded links (i.e. show me all the
> > > > > patients in a particular location)
> >
> > > > > This makes sense to me:
> >
> > > > > <% link_to "=Hospital 1 census", {:controller=>"/
> > > > > patients", :action=>"find", :search_string=>"Hospital 1"} %>
> >
> > > > > but gives me error "Couldn't find Patient with ID=find" (The above
> > > > > link generates the URL example.com/patients/find?
> > > > > search_string=Hillcrest)
> >
> > > > > I tried playing around with routes.rb, but got nowhere. What am I
> > > > > doing wrong?
> >
> > > > > Thanks,
> > > > > --b
> >
>

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



[Rails] Setting Up Setters

2009-05-07 Thread rapdup

If I have a setter method that needs to manipulate the incoming value
before setting itself, how can I do this without it be self
referencing? In the example below, I've defined "start_date=", so how
do I now save a value to start_date?

thx

Ex:
class Event
   def start_date=(new_start_date)
   self.start_date = new_start_date unless new_start_date >=
start_date
   end
end


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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Hassan Schroeder

On Thu, May 7, 2009 at 9:28 AM, Todd Fox
 wrote:

> we need the html in xml (html wrapped inside the xml) for another
> application read and then render that html.

Does the html need to be an attribute? Or can it just be within an
xml envelope?  IOW, do you control the consuming end of this?

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

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



[Rails] Re: has_many / belongs_to issues

2009-05-07 Thread Jodi Showers

Bogdan -

On 7-May-09, at 4:47 PM, Bogdan Pop wrote:

>
> Hi,
>
> I just faced this problem today. I have a site which will have a USER
> model and a SUBMISSION model. Apart from the cosmetics parts, each  
> user
> will be able to have multiple submissions, while each submission could
> have or not a username.
>
> Basically, registration to make a submission will be optional. My
> question is will this work if someone tries to submit and it is not
> registered?

validation is under your control - just don't enforce  
(validates_presence_of) for :user relation

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



[Rails] hide attribute from scaffolding

2009-05-07 Thread Bogdan Pop

Hey,

I have a simple model having some attributes. One of those attributes is
an overall grade, which I don't want users to be able to edit it on
their own. I display all the info in the database using a scaffold.

However, while scaffolding, I can see and edit the grade attribute,
which I only want to be displayed.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] has_many / belongs_to issues

2009-05-07 Thread Bogdan Pop

Hi,

I just faced this problem today. I have a site which will have a USER
model and a SUBMISSION model. Apart from the cosmetics parts, each user
will be able to have multiple submissions, while each submission could
have or not a username.

Basically, registration to make a submission will be optional. My
question is will this work if someone tries to submit and it is not
registered?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Colin Law
I am not sure exactly what you would do, I am also not sure exactly what you
are doing with the xml.  It just seems that an erb view is the ideal tool
for generating html to be sent to the client.  Is there a lot of xml or is
it just a wrapper round the html?  If only a wrapper then you could generate
that 'by hand' so to speak in the erb file also, or in the layout file.

Can anyone else help? I do not really know what I am talking about here.

Colin

2009/5/7 Todd Fox 

>
> Todd Fox wrote:
> > how would that work?
>
> we need the html in xml (html wrapped inside the xml) for another
> application read and then render that html.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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



[Rails] Re: sanitize_params + whiteList

2009-05-07 Thread Tom Z Meinlschmidt

hi,
what about to put

WhiteListHelper.tags += %w(a em p strong blockquote h2 ul li)

into app/helpers/application_helper.rb ?

instead of config/...

tom

Petan Cert wrote:
> Hi all,
> 
> I just installed whiteList and sanitize_params plugins to get rid of
> with some bad html tags .
> 
> Put in my environment.rb:
> config.plugins = [:white_list, :sanitize_params, :all]
> 
> and in application.rb:
> before_filter :sanitize_params
> 
> add ok tags to config/initializers/whitelist_conf.rb
> WhiteListHelper.tags += %w(a em p strong blockquote h2 ul li)
> 
> but all the tags from the text fields are stripped. Am I missing
> something?
> THx P.


-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: Controller redirect_to to leave iframe

2009-05-07 Thread nextpulse

I used a quick workaround. Replace the redirect_to with:

render :text => "window.parent.document.location.href = '/myloc';"



On May 7, 11:51 am, nextpulse  wrote:
> thanks.
> Seems like I may have to render some JS in the controller to call the
> parent.
>
> On May 7, 11:46 am, Frederick Cheung 
> wrote:
>
> > On May 7, 7:43 pm, nextpulse  wrote:
>
> > > Inside an iframe, I want the controller to redirect_to to the parent
> > > (i.e.  target ='_parent').
> > > Any ideas?
> > > (Everything I've tried- via redirect_to - just keeps it inside the
> > > iframe)
>
> > i don't think you can do this server side - you need to set the right
> > target attribute etc on the link and so on.
>
> > Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Outputting strict JSON

2009-05-07 Thread lyntaff

Thanks, That worked great.

On May 7, 8:59 pm, Frederick Cheung 
wrote:
> On 7 May 2009, at 12:37, lyntaff  wrote:
>
>
>
> > Does any body know how I can output JSON so that instead of getting:
>
> > {booking: {id: 1, name: "foo"}
>
> There should be an initializer in your app called something like  
> new_rails_defaults.rb that shows you how to control this
>
> > You get this instead:
>
> > {id: 1, name: "foo"}
>
> > Can't find a solution for this at all
>
> > Thank you for any help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: segmentation fault from mysql_adapter.rb

2009-05-07 Thread Gregg H.

I am also getting this, which I believe is related to the same problem:

==  InitialStructureAndData: migrating 

-- create_table("areas", {:force=>true})
rake aborted!
An error has occurred, all later migrations canceled:

undefined method `each' for #

(See full trace by running task with --trace)

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

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



[Rails] Re: passing hard-coded values to controller

2009-05-07 Thread big poppa

Suppose I wanted to do this. Wouldn't the syntax be (in config/
routes.rb)

map.connect '/patients/find', :controller=>'patient', :action=>'find'

prepended to the standard, scaffold generated

map.connect ':controller/:action/:id'
map.connect ':controller/:action/:id.:format'

--b

On May 7, 12:06 am, Colin Law  wrote:
> Since find is not one of the standard actions, have you included a specific
> route for patients/find?  The default routes generated by map.resources
> :patients will assume that find is a patient id, expecting to see patients/2
> for example.
>
> Colin
>
> 2009/5/6 big poppa 
>
>
>
> > sorry, that's a typo. it appears the way you suggested in my code (it
> > compiles).
>
> > i'll look into the routing some more, i was ready to bash my head in
> > last night and couldn't take it any more...
>
> > --b
>
> > On May 6, 12:59 am, Gul  wrote:
> > > The way you are receiving parameter is wrong it should be like this
>
> > >   @patients = Patient.find(:all, :conditions => { :location =>params
> > > [:search_string] })
>
> > > GUL
>
> > > On May 6, 12:40 pm, big poppa  wrote:
>
> > > > given the following code snippet:
>
> > > > class PatientsController < ApplicationController
> > > > ...
> > > > def find
> > > >   @patients = Patient.find(:all, :conditions => { :location =>
> > > > [params:search_string] })
> > > > end
>
> > > > I would like to add a few hard coded links (i.e. show me all the
> > > > patients in a particular location)
>
> > > > This makes sense to me:
>
> > > > <% link_to "=Hospital 1 census", {:controller=>"/
> > > > patients", :action=>"find", :search_string=>"Hospital 1"} %>
>
> > > > but gives me error "Couldn't find Patient with ID=find" (The above
> > > > link generates the URL example.com/patients/find?
> > > > search_string=Hillcrest)
>
> > > > I tried playing around with routes.rb, but got nowhere. What am I
> > > > doing wrong?
>
> > > > Thanks,
> > > > --b
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Outputting strict JSON

2009-05-07 Thread Frederick Cheung



On 7 May 2009, at 12:37, lyntaff  wrote:

>
> Does any body know how I can output JSON so that instead of getting:
>
> {booking: {id: 1, name: "foo"}
>
>

There should be an initializer in your app called something like  
new_rails_defaults.rb that shows you how to control this
> You get this instead:
>
> {id: 1, name: "foo"}
>
> Can't find a solution for this at all
>
> Thank you for any help.
>
> >

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



[Rails] Re: triple state radio buttons

2009-05-07 Thread Philip Hallstrom

> Can I coax a pair of radio buttons to consistently maintain their
> triple state functionality (null, true, false)?
>
> In others words allow the user to undo a response and return the
> control to a null state (nothing selected).
>
> I hope this isn't coming down to some sort of Javascript workaround.

I don't think so.  radio button parameters are either

... passed with a value (if clicked)
or
... passed with an empty value or not passed at all (if not clicked)

There's no way to distinguish b/n unclicked (which would be your false  
I assume) and null.

Why not turn them into drop downs with blank/true/false as values?

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



[Rails] Re: sanitize_params + whiteList

2009-05-07 Thread Petan Cert

Anyone?

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

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



[Rails] triple state radio buttons

2009-05-07 Thread zambezi

Can I coax a pair of radio buttons to consistently maintain their
triple state functionality (null, true, false)?

In others words allow the user to undo a response and return the
control to a null state (nothing selected).

I hope this isn't coming down to some sort of Javascript workaround.

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



[Rails] Outputting strict JSON

2009-05-07 Thread lyntaff

Does any body know how I can output JSON so that instead of getting:

{booking: {id: 1, name: "foo"}


You get this instead:

{id: 1, name: "foo"}

Can't find a solution for this at all

Thank you for any help.

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



[Rails] Re: passing hard-coded values to controller

2009-05-07 Thread big poppa

thanks for your input and thoughtful reply. I like your proposal and
I'll give it a shot

Thanks,
--b

On May 7, 6:39 am, Colin Law  wrote:
> Having thought further about this I would suggest that you may going about
> it the wrong way anyway.  I think what you are trying to do is select a set
> of patients for display.  The default action for showing a set of patients
> is the index action, which by default would show all patients and is
> accessed by example.com/patients.  You could use the URL
> example.com/patients?search_string=Hillcrest (or whatever) and test for the
> presence of params[:search_string] in the index method of the controller.
> Then no special routing is required.
>
> Colin
>
> 2009/5/7 Colin Law 
>
> > Since find is not one of the standard actions, have you included a specific
> > route for patients/find?  The default routes generated by map.resources
> > :patients will assume that find is a patient id, expecting to see patients/2
> > for example.
>
> > Colin
>
> > 2009/5/6 big poppa 
>
> >> sorry, that's a typo. it appears the way you suggested in my code (it
> >> compiles).
>
> >> i'll look into the routing some more, i was ready to bash my head in
> >> last night and couldn't take it any more...
>
> >> --b
>
> >> On May 6, 12:59 am, Gul  wrote:
> >> > The way you are receiving parameter is wrong it should be like this
>
> >> >   @patients = Patient.find(:all, :conditions => { :location =>params
> >> > [:search_string] })
>
> >> > GUL
>
> >> > On May 6, 12:40 pm, big poppa  wrote:
>
> >> > > given the following code snippet:
>
> >> > > class PatientsController < ApplicationController
> >> > > ...
> >> > > def find
> >> > >   @patients = Patient.find(:all, :conditions => { :location =>
> >> > > [params:search_string] })
> >> > > end
>
> >> > > I would like to add a few hard coded links (i.e. show me all the
> >> > > patients in a particular location)
>
> >> > > This makes sense to me:
>
> >> > > <% link_to "=Hospital 1 census", {:controller=>"/
> >> > > patients", :action=>"find", :search_string=>"Hospital 1"} %>
>
> >> > > but gives me error "Couldn't find Patient with ID=find" (The above
> >> > > link generates the URL example.com/patients/find?
> >> > > search_string=Hillcrest)
>
> >> > > I tried playing around with routes.rb, but got nowhere. What am I
> >> > > doing wrong?
>
> >> > > Thanks,
> >> > > --b
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: RMagick, ImageMagick, Passenger and Dreamhost

2009-05-07 Thread Rick

It looks like you need to check the following:

1) Did you install your own version of ImageMagick in your local
directory?  Both of the following two Unix commands should give the
same response. NOTE: YOUR_HOME should be the path to your home
directory.  i.e.: I see /Users/rick/local/bin/Magick-config on my
system.

$ ls ~/local/bin/Magick-config
YOUR_HOME/local/bin/Magick-config
$ which Magick-config
YOUR_HOME/local/bin/Magick-config
$

If the first command fails, you need to re-install ImageMagick paying
attention to the instructions for setting "--prefix=" in the
configuration step.  After the re-install of ImageMagick you'll need
to reinstall RMagick.

If the first command succeeds but the second fails, you need to add
the RMagick export settings to your shell's runtime command file.

Shell   RC File
bash   ~/.profile or ~/.bashrc
csh ~/.login or ~/.cshrc
tcsh~/.login or ~/.tcshrc
ksh ~/.profile or ~/.kshrc
sh   ~/.profile

Edit your RC file and add the following lines:

$ export PATH=$HOME/local/bin:$PATH
$ export LDFLAGS=-L/$HOME/local/lib
$ export CPPFLAGS=-I/$HOME/local/include
$ export LD_RUN_PATH=$HOME/local/lib

Log out and back in and retry the "ls ~/local/bin/Magick-config" and
"which Magick-config".  The results of both commands should now be
identical.  If you check the file (more ~/local/bin/Magick-config) you
should see the prefix, exec_prefix, libdir, and included_dir as
pointing at your home directory.  RMagick should work now.


On May 6, 7:11 pm, Daniel2Surf  wrote:
> I need to use the newest version of RMagick, so i did everything as
> they say on this wiki:http://wiki.dreamhost.com/index.php/RMagick
>
> But, my Rails app isn't working, here is the error:
>
> This installation of RMagick was configured with ImageMagick 6.5.1 but
> ImageMagick 6.0.6 is in use.
>
> I tried to set the environment variable: LD_LIBRARY_PATH... but no
> success...
> I've read a lot of people with the same problem, but i couldn't find
> the solution.
> I guess the problem is to set a environment variable in passenger.
> Does anybody can help me?
>
> Thanks a lot.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: named_scope issue undefined method that is a db column name

2009-05-07 Thread erik

Reading is sometimes magic... OrderTrack.one().first does the
trick.
Erik


On May 7, 10:22 am, erik  wrote:
> Yeah, that's right.  I thought it was dying before sending the sql
> query, but i was reading my exception incorrectly.  I didn't believe
> it was an array because I had seen no_method 'blah' for 
> before, but it through me off as it said Class.
>
> So here's another dumb question... I can put [0] at the end of my
> OrderTrack.one[0] line, but is there a way to make named_scope
> only return a single object of the activerecord type as opposed to an
> array?
> Thanks.
> Erik
>
> On May 7, 10:04 am, Frederick Cheung 
> wrote:
>
> > On May 7, 5:58 pm, erik  wrote:> I'm new to named_scope so 
> > bear with me if this is dumb.
>
> > > I have created two named scopes both using lambda to pass in
> > > arguments.  One passes in a single argument and works great the other
> > > passes in two arguments and doesn't work and gives me this error:
>
> > I'm going to make a wild guess that this is because you're assuming
> > that OrderTrack.one(...) is a single object rather than an array
> > (possibly containing only one row)
>
> > Fred
>
> > > undefined method `last_reference' for #
>
> > > vendor/rails/activerecord/lib/active_record/base.rb:1833:in
> > > `method_missing_without_paginate'
> > > /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mislav-
> > > will_paginate-2.3.8/lib/will_paginate/finder.rb:170:in
> > > `method_missing'
> > > vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> > > `send'
> > > vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> > > `method_missing'
> > > vendor/rails/activerecord/lib/active_record/base.rb:2003:in
> > > `with_scope'
> > > (__DELEGATION__):2:in `__send__'
> > > (__DELEGATION__):2:in `with_scope'
> > > app/controllers/orders_controller.rb:23:in `show'
>
> > > The two named_scopes:
> > > class OrderTrack < ActiveRecord::Base
> > >     named_scope :one, lambda {|id,account_id| {:conditions => ["id = ?
> > > and account_id = ?",id,account_id]}}
> > >     named_scope :all, lambda {|account_id| {:conditions =>
> > > ["account_id = ?",account_id]}}
> > > end
>
> > > I believe I need to use lambda to pass in arguments.  The
> > > named_scope :all works great and ends up doing an sql query like:
> > > SELECT * FROM `order_tracks` WHERE (account_id = 344)
>
> > > But the single one that I want to end up doing something like:
> > > SELECT * FROM `order_tracks` WHERE (id = 3 and account_id = 344)
> > > doesn't want to work.
>
> > > This is soft of a contrived example, but I'm just trying to see if I
> > > understand this stuff.
> > > Thanks.
> > > Erik
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Setting Session Variables in Integration Tests

2009-05-07 Thread Kyle Peyton

I'm pretty new to integration testing and I'm not sure how to define 
tests.  I saw an example of someone doing it this way, so that's the way 
I formed mine.  What is the best way to write a normal test that allows 
me to set the "user_id" session variable so that the "get" can 
successfully happen?

-Kyle

Frederick Cheung wrote:
> On 7 May 2009, at 11:26, Kyle Peyton  s.net> wrote:
> 
>>  def user_for_test
>>open_session do |thing|
>>  def user.access_project_index_page
> 
> Actually it is the above line that is raising the exception - there is
> no user variable / method in scope here.
> This code lois pretty strange - are you really trying to define
> singleton methods on users?
> 
> Fred
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Setting Session Variables in Integration Tests

2009-05-07 Thread Frederick Cheung



On 7 May 2009, at 11:26, Kyle Peyton  wrote:

>
> All I want to do is set a session variable when I make a request.
> Here's my code:
>
> class ProjectIntegrationTest < ActionController::IntegrationTest
>  def test_truth
>user = user_for_test
>user.access_project_index_page
>  end
>
>  def user_for_test
>open_session do |thing|
>  def user.access_project_index_page

Actually it is the above line that is raising the exception - there is  
no user variable / method in scope here.
This code lois pretty strange - are you really trying to define  
singleton methods on users?

Fred
>
>session[:user_id] = 'someid'
>get project_index_path
>assert_response :success
>  end
>end
>  end
> end
>
> I'm getting this error:
>
> test_truth(ProjectIntegrationTest):
> NoMethodError: undefined method `user' for
> #
> method method_missing in test_process.rb at line 464
> method send! in integration.rb at line 448
> method method_missing in integration.rb at line 448
> method user_for_test in project_integration_test.rb at line 11
>
> Line 11 is the line where "session[:user_id] = 'someid'" is being set.
> What am I doing wrong for setting the session?
>
> -Kyle
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >

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



[Rails] Re: Upgrade old rails app issues.. help

2009-05-07 Thread Frederick Cheung



On 7 May 2009, at 11:18, "<-_-_-|Rek2|-_-_-->"  
 wrote:

>
> Hi, any help with this?
>
Have you tried doing what the error message suggests?

Fred
>
>> Hi I never had to upgrade someone elses rail application so this is
>> getting a bit fustrating but mostly because I have no experience..
>> I downloaded  http://sourceforge.net/projects/grabthemic  that has  
>> not
>> been updated for 2 years but I am going to build a Digg alike site so
>> decided to not reinvent the wheel and pick up a current project..
>> but I get this error:
>>
>> grabthemic-v0.7 $ ./script/server
>> => Booting WEBrick
>> => Rails 2.3.2 application starting on http://0.0.0.0:3000
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> session/cookie_store.rb:163:in
>> `ensure_session_key': A key is required to write a cookie  
>> containing the
>> session data. Use config.action_controller.session = { :key =>
>> "_myapp_session", :secret => "some secret phrase" } in
>> config/environment.rb (ArgumentError)
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> session/cookie_store.rb:74:in
>> `initialize'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:72:in
>> `new'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:72:in
>> `build'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:116:in
>> `build'
>>from
>> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/ 
>> inflector.rb:361:in
>> `inject'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:116:in
>> `each'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:116:in
>> `inject'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> middleware_stack.rb:116:in
>> `build'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> dispatcher.rb:82:in
>> `initialize'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> dispatcher.rb:52:in
>> `new'
>>from
>> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/ 
>> dispatcher.rb:52:in
>> `run_prepare_callbacks'
>>from
>> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:609:in
>> `prepare_dispatcher'
>>from
>> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:183:in  
>> `process'
>>from
>> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in  
>> `send'
>>from
>> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in  
>> `run'
>>from /home/rek2/Desktop/grabthemic-v0.7/config/ 
>> environment.rb:10
>>from
>> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
>> `gem_original_require'
>>from
>> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in  
>> `require'
>>from
>> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/ 
>> dependencies.rb:156:in
>> `require'
>>from
>> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/ 
>> dependencies.rb:521:in
>> `new_constants_in'
>>from
>> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/ 
>> dependencies.rb:156:in
>> `require'
>>from
>> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84
>>from
>> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
>> `gem_original_require'
>>from
>> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in  
>> `require'
>>from ./script/server:3
>>
>>
>>
>>>
>>
>
>
> >

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



[Rails] Re: Controller redirect_to to leave iframe

2009-05-07 Thread Tom Z Meinlschmidt

nextpulse wrote:
> Inside an iframe, I want the controller to redirect_to to the parent
> (i.e.  target ='_parent').
> Any ideas?
> (Everything I've tried- via redirect_to - just keeps it inside the
> iframe)
> 
> 
use responds_to_parent plugin

tom
-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: Controller redirect_to to leave iframe

2009-05-07 Thread nextpulse

thanks.
Seems like I may have to render some JS in the controller to call the
parent.


On May 7, 11:46 am, Frederick Cheung 
wrote:
> On May 7, 7:43 pm, nextpulse  wrote:
>
> > Inside an iframe, I want the controller to redirect_to to the parent
> > (i.e.  target ='_parent').
> > Any ideas?
> > (Everything I've tried- via redirect_to - just keeps it inside the
> > iframe)
>
> i don't think you can do this server side - you need to set the right
> target attribute etc on the link and so on.
>
> Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Controller redirect_to to leave iframe

2009-05-07 Thread Frederick Cheung



On May 7, 7:43 pm, nextpulse  wrote:
> Inside an iframe, I want the controller to redirect_to to the parent
> (i.e.  target ='_parent').
> Any ideas?
> (Everything I've tried- via redirect_to - just keeps it inside the
> iframe)

i don't think you can do this server side - you need to set the right
target attribute etc on the link and so on.

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



[Rails] Controller redirect_to to leave iframe

2009-05-07 Thread nextpulse

Inside an iframe, I want the controller to redirect_to to the parent
(i.e.  target ='_parent').
Any ideas?
(Everything I've tried- via redirect_to - just keeps it inside the
iframe)

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



[Rails] Setting Session Variables in Integration Tests

2009-05-07 Thread Kyle Peyton

All I want to do is set a session variable when I make a request.
Here's my code:

class ProjectIntegrationTest < ActionController::IntegrationTest
  def test_truth
user = user_for_test
user.access_project_index_page
  end

  def user_for_test
open_session do |thing|
  def user.access_project_index_page
session[:user_id] = 'someid'
get project_index_path
assert_response :success
  end
end
  end
end

I'm getting this error:

test_truth(ProjectIntegrationTest):
NoMethodError: undefined method `user' for
#
method method_missing in test_process.rb at line 464
method send! in integration.rb at line 448
method method_missing in integration.rb at line 448
method user_for_test in project_integration_test.rb at line 11

Line 11 is the line where "session[:user_id] = 'someid'" is being set.
What am I doing wrong for setting the session?

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

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



[Rails] Re: Upgrade old rails app issues.. help

2009-05-07 Thread <-_-_-|Rek2|-_-_-->

Hi, any help with this?


> Hi I never had to upgrade someone elses rail application so this is
> getting a bit fustrating but mostly because I have no experience..
> I downloaded  http://sourceforge.net/projects/grabthemic  that has not
> been updated for 2 years but I am going to build a Digg alike site so
> decided to not reinvent the wheel and pick up a current project..
> but I get this error:
>
> grabthemic-v0.7 $ ./script/server
> => Booting WEBrick
> => Rails 2.3.2 application starting on http://0.0.0.0:3000
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:163:in
> `ensure_session_key': A key is required to write a cookie containing the
> session data. Use config.action_controller.session = { :key =>
> "_myapp_session", :secret => "some secret phrase" } in
> config/environment.rb (ArgumentError)
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/session/cookie_store.rb:74:in
> `initialize'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:in
> `new'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:72:in
> `build'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
> `build'
> from
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/inflector.rb:361:in
> `inject'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
> `each'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
> `inject'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/middleware_stack.rb:116:in
> `build'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:82:in
> `initialize'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:52:in
> `new'
> from
> /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/dispatcher.rb:52:in
> `run_prepare_callbacks'
> from
> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:609:in
> `prepare_dispatcher'
> from
> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:183:in `process'
> from
> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `send'
> from
> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/initializer.rb:113:in `run'
> from /home/rek2/Desktop/grabthemic-v0.7/config/environment.rb:10
> from
> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
> from
> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
> from
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
> `require'
> from
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:521:in
> `new_constants_in'
> from
> /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in
> `require'
> from
> /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/server.rb:84
> from
> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in
> `gem_original_require'
> from
> /usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
> from ./script/server:3
>
>
>
> >
>   


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



[Rails] Re: has_many through association

2009-05-07 Thread Intern ruby

thanks Chron and Tom. It worked.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: projects works then breaks intermittently - mysql, linux

2009-05-07 Thread E. Litwin

Where is the code/log? It is not in your post.

On May 7, 1:00 am, Adam Akhtar 
wrote:
> Thats teh first thing i check and the code above is actually from the
> development log.
>
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: named_scope issue undefined method that is a db column name

2009-05-07 Thread erik

Yeah, that's right.  I thought it was dying before sending the sql
query, but i was reading my exception incorrectly.  I didn't believe
it was an array because I had seen no_method 'blah' for 
before, but it through me off as it said Class.

So here's another dumb question... I can put [0] at the end of my
OrderTrack.one[0] line, but is there a way to make named_scope
only return a single object of the activerecord type as opposed to an
array?
Thanks.
Erik


On May 7, 10:04 am, Frederick Cheung 
wrote:
> On May 7, 5:58 pm, erik  wrote:> I'm new to named_scope so 
> bear with me if this is dumb.
>
> > I have created two named scopes both using lambda to pass in
> > arguments.  One passes in a single argument and works great the other
> > passes in two arguments and doesn't work and gives me this error:
>
> I'm going to make a wild guess that this is because you're assuming
> that OrderTrack.one(...) is a single object rather than an array
> (possibly containing only one row)
>
> Fred
>
> > undefined method `last_reference' for #
>
> > vendor/rails/activerecord/lib/active_record/base.rb:1833:in
> > `method_missing_without_paginate'
> > /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mislav-
> > will_paginate-2.3.8/lib/will_paginate/finder.rb:170:in
> > `method_missing'
> > vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> > `send'
> > vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> > `method_missing'
> > vendor/rails/activerecord/lib/active_record/base.rb:2003:in
> > `with_scope'
> > (__DELEGATION__):2:in `__send__'
> > (__DELEGATION__):2:in `with_scope'
> > app/controllers/orders_controller.rb:23:in `show'
>
> > The two named_scopes:
> > class OrderTrack < ActiveRecord::Base
> >     named_scope :one, lambda {|id,account_id| {:conditions => ["id = ?
> > and account_id = ?",id,account_id]}}
> >     named_scope :all, lambda {|account_id| {:conditions =>
> > ["account_id = ?",account_id]}}
> > end
>
> > I believe I need to use lambda to pass in arguments.  The
> > named_scope :all works great and ends up doing an sql query like:
> > SELECT * FROM `order_tracks` WHERE (account_id = 344)
>
> > But the single one that I want to end up doing something like:
> > SELECT * FROM `order_tracks` WHERE (id = 3 and account_id = 344)
> > doesn't want to work.
>
> > This is soft of a contrived example, but I'm just trying to see if I
> > understand this stuff.
> > Thanks.
> > Erik
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: How to lock and unlock table in ruby on rails?

2009-05-07 Thread Frederick Cheung



On May 7, 1:50 pm, Tom Z Meinlschmidt  wrote:
>
> > ActiveRecord::Base.connection.execute('LOCK TABLES tablename WRITE')
> > ActiveRecord::Base.connection.execute('UNLOCK TABLES')
>
> imagine you lock the tables.. and then you will be disconnected from the
> session for some reason... tables are still locked, no way to work with
> them. That's the point dbs have transations...

actually mysql releases table locks held by a client if connection to
that client dies (I suppose it might take a while for it to notice
though). Table locks are generally not a very good thing generally.

Fred

>
> ...
>
> tom
>
> --
> === 
> 
> Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
>
> www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
> === 
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] relations between contact_person and contact_business

2009-05-07 Thread Trom Ton

Hello all,

i am stuck with something.

i have the following situation:

[code=]contacts---|
   |--|0-1|--contact_businesses
   | (either one of booth; business or contact)
   |--|0-1|--contact_people[/code]
i have a contacts model that either extends to contact_business or
contact_person, depending if its a person or a business.
now i whant to describe relationships between people and businesses.
i thought about something like this:
[code=]contacts---|
   |--|0-1|--contact_businesses
   | (either one of booth; business or contact)
   |--|0-1|--contact_people
   |
   |--|0-n|--contact_relations (contact_person_contact_id,
contact_business_contact_id)[/code]
so contact_relations would store the contact_id of the file that is
create/edited depending if it is a business or a person in
contact_business_contact_id or contact_person_contact_id and the
contact_id of the relation (wich must be the other kind) in the other
field.
this would be the way i would do it by hand, if i would have programmed
this in php. but in ror i dont really know or understand how this is t
be accomplished.

maybe self joins is the solution
(http://guides.rubyonrails.org/association_basics.html#self-joins). but
somehow i dont understand how this works and what table collums i would
need.

can somebody help me?

thanks a lot,

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

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



[Rails] Re: named_scope issue undefined method that is a db column name

2009-05-07 Thread Frederick Cheung



On May 7, 5:58 pm, erik  wrote:
> I'm new to named_scope so bear with me if this is dumb.
>
> I have created two named scopes both using lambda to pass in
> arguments.  One passes in a single argument and works great the other
> passes in two arguments and doesn't work and gives me this error:
>
I'm going to make a wild guess that this is because you're assuming
that OrderTrack.one(...) is a single object rather than an array
(possibly containing only one row)

Fred

> undefined method `last_reference' for #
>
> vendor/rails/activerecord/lib/active_record/base.rb:1833:in
> `method_missing_without_paginate'
> /opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mislav-
> will_paginate-2.3.8/lib/will_paginate/finder.rb:170:in
> `method_missing'
> vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> `send'
> vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
> `method_missing'
> vendor/rails/activerecord/lib/active_record/base.rb:2003:in
> `with_scope'
> (__DELEGATION__):2:in `__send__'
> (__DELEGATION__):2:in `with_scope'
> app/controllers/orders_controller.rb:23:in `show'
>
> The two named_scopes:
> class OrderTrack < ActiveRecord::Base
>     named_scope :one, lambda {|id,account_id| {:conditions => ["id = ?
> and account_id = ?",id,account_id]}}
>     named_scope :all, lambda {|account_id| {:conditions =>
> ["account_id = ?",account_id]}}
> end
>
> I believe I need to use lambda to pass in arguments.  The
> named_scope :all works great and ends up doing an sql query like:
> SELECT * FROM `order_tracks` WHERE (account_id = 344)
>
> But the single one that I want to end up doing something like:
> SELECT * FROM `order_tracks` WHERE (id = 3 and account_id = 344)
> doesn't want to work.
>
> This is soft of a contrived example, but I'm just trying to see if I
> understand this stuff.
> Thanks.
> Erik
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] named_scope issue undefined method that is a db column name

2009-05-07 Thread erik

I'm new to named_scope so bear with me if this is dumb.

I have created two named scopes both using lambda to pass in
arguments.  One passes in a single argument and works great the other
passes in two arguments and doesn't work and gives me this error:

undefined method `last_reference' for #


vendor/rails/activerecord/lib/active_record/base.rb:1833:in
`method_missing_without_paginate'
/opt/ruby-enterprise-1.8.6-20090201/lib/ruby/gems/1.8/gems/mislav-
will_paginate-2.3.8/lib/will_paginate/finder.rb:170:in
`method_missing'
vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
`send'
vendor/rails/activerecord/lib/active_record/named_scope.rb:171:in
`method_missing'
vendor/rails/activerecord/lib/active_record/base.rb:2003:in
`with_scope'
(__DELEGATION__):2:in `__send__'
(__DELEGATION__):2:in `with_scope'
app/controllers/orders_controller.rb:23:in `show'


The two named_scopes:
class OrderTrack < ActiveRecord::Base
named_scope :one, lambda {|id,account_id| {:conditions => ["id = ?
and account_id = ?",id,account_id]}}
named_scope :all, lambda {|account_id| {:conditions =>
["account_id = ?",account_id]}}
end

I believe I need to use lambda to pass in arguments.  The
named_scope :all works great and ends up doing an sql query like:
SELECT * FROM `order_tracks` WHERE (account_id = 344)

But the single one that I want to end up doing something like:
SELECT * FROM `order_tracks` WHERE (id = 3 and account_id = 344)
doesn't want to work.

This is soft of a contrived example, but I'm just trying to see if I
understand this stuff.
Thanks.
Erik

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



[Rails] Re: what database field type should i use ??

2009-05-07 Thread Tom Z Meinlschmidt

It's about performance.

if you'll have marriage status (single/married/divorced/etc) in table 
marriagestatuses, and using belongs_to/has_many via marriagestatus_id, 
and not using :include => marriagestatuses in you 'queries', db will do 
a lot of queries just for a few enumerables.

so each of us have to decide whether to use another 'enumerate table' or nor

tom

Billee D. wrote:
> Sometimes it''s a matter of taste or design constraint, but why not
> use a small join table and a foreign key? ENUM is also a great choice,
> as these guys have pointed out, but sometimes there is a bit of
> overhead -- but you shouldn't worry about that until it becomes an
> issue. Personally, I find it easier to maintain a simple join table
> and FK relationships than to mess with ENUM field types.
> 
> I don't know if this is still applicable, but it seems like there is a
> bit of data massaging in Rails for the ENUM type (Rails converts it
> internally to VARCHAR):
> 
> http://lists.rubyonrails.org/pipermail/rails/2005-January/001536.html
> 
> I like to let the database do as much work as it can, :-)
> 
> HTH!
> 
> Billee D.
> 
> On May 7, 4:43 am, Vipin  wrote:
>> in a database table if there is a field which has a certain set of
>> fixed values. for example
>> staus => {Single, Married, Divorced }
>> OR
>> state => {California, Albama, Olaska ...}
>>
>> so what should be preferred way out of the following for storing the
>> values
>>
>> 1. Keep the field as "string(Rails)"  VARCHAR(MySQL) itself and
>> while showing the field just show the field value.
>>
>> 2. Keep the field internally as a code like {:california =>
>> 01, :albama => 02, washington => 03 } but while showing the state
>> show only the corresponding state.
>>
>> By using option 2, a certain disadvantage is extra computation time
>> required to find out corresponding state name based on code when
>> showing the state field to user. But an advantage could be in terms of
>> smaller database. In my opinion, saving 01 as an integer could save
>> significant space than storing "california"  if number of records
>> happen to be in tens of thousands .
>>
>> please suggest ??
>>
>> vipin
> 

-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: has_many through association

2009-05-07 Thread Tom Z Meinlschmidt

Intern ruby wrote:
> 1) class Group < ActiveRecord::Base
> 
> has_many :group_users
>   has_many :users, :through => :group_users
> end
> 
> 2)class User < ActiveRecord::Base
> has_many :group_users
>   has_many :groups, :through => :group_users
> end
> 
> 3))class CreateGroupUsers < ActiveRecord::Migration   # JOINING
> TABLE
>   def self.up
> create_table :group_users do |t|
> t.column:group_id,:string
> t.column:user_id,:string
>   t.column  :group_admin, :boolean
>   t.timestamps
> end
>   end
> 
> Can anybody please help me how to set the value of group_admin in
> GroupUsers ?
> 
> I want to do like this :
> 
> @group.group_users.group_admin =1 (X- NOT WORKING THOUGH)

@group.group_users contains an array of users.. so you need to specify 
what user to set group_admin=1

try to open script/console and do:
 > test = Group.find(1)
 > test.group_users
 > test.group_users[0]
 > test.group_users[0].group_admin=1
-- 
===
Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

www.meinlschmidt.com  www.maxwellrender.cz  www.lightgems.cz
===

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



[Rails] Re: has_many through association

2009-05-07 Thread Ar Chron

> 
> @group.group_users.group_admin =1 (X- NOT WORKING THOUGH)

@group.group_users is not a single entity with the group_admin 
attribute, it's a collection of group_users records...

@group.group_users.each do |group_user|
  group_user.group_admin = 1
end

would set that attribute for every group_user record, but I don't think 
that is you want to do.

I'd think you want to assign the group_admin for a single group_users 
record for the group, which you'll need to select according to the 
user_id.

A particularly ugly, but very clear implementation, might be:

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



[Rails] Re: sending email problem

2009-05-07 Thread John Yerhot

Hey Kentor,

I'd check out the Rails Wiki on sending mail.
http://wiki.rubyonrails.org/howtos/mailers

Few questions:
What platform are you on?
How do you intended on sending the mail? (Sendmail, smtp?)
What does "doesn't work" mean?  Are there any errors in your
development.log file?


Thanks :)
On May 7, 6:42 am, Kentor  wrote:
> Hello,
>
> I'm very new to ruby on rails. I'm trying to setup a simple form to
> send an email. I've followed many different tutorials and nothing
> seems to work for me... I've tried using tls, pony plugin,
> actionmailer, etc... Even sending an email from the cmd prompt would
> be fine... I just want to be able to send anything to my gmail account
> from my localhost environment. Please understand that I am really new
> to ruby on rails.. please explain in as much detail as you can. Thanks
> a lot for your help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: DRb::DRbConnError

2009-05-07 Thread Mindtonic

I'm using backgroundrb, but I have removed all of my tests except for
one as I am rewriting them to make them even more thorough.  The test
that I am trying to run does not use backgroundrb.

On May 7, 12:33 pm, Frederick Cheung 
wrote:
> On May 7, 5:26 pm, Mindtonic  wrote:
>
> > Hello, I am trying to run my tests using rake, but I keep getting this
> > error.  Anyone know why that might be happening?
>
> Does your app make use of drb in any way ?
>
> Fred
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: DRb::DRbConnError

2009-05-07 Thread Frederick Cheung



On May 7, 5:26 pm, Mindtonic  wrote:
> Hello, I am trying to run my tests using rake, but I keep getting this
> error.  Anyone know why that might be happening?

Does your app make use of drb in any way ?

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



[Rails] [ANN] Manifesto and roadmaps for described_routes and path-to

2009-05-07 Thread Mike Burrows (asplake)

Hi all, please read on if you're interested in REST and web APIs.

I have posted roadmaps for described_routes and path-to (both
available as rubygems or at asplake's github) at 
http://positiveincline.com/?p=213.
The excerpt below is their manifesto.  I would be very grateful for
comments, whether here or on the site.

Thanks!
Mike
m...@asplake.co.uk
http://positiveincline.com
http://twitter.com/asplake

Clients of RESTful web applications typically use prior knowledge of
the target application’s structure to generate URIs.  This approach is
often very convenient, but much of this URI generation is hard-coded,
and (worse) spread across client code. This introduces a high degree
of coupling and makes clients unnecessarily vulnerable to server-side
change.

Steps to improve this situation:

   1. In clients, centralise the generation of URIs and make the
process driven by configuration data
   2. Have servers publish the required configuration data - i.e.
application metadata - in a readily understood format

path-to provides the means for client applications to model web
applications in terms of logical structure and URI mappings, and to
interact with them through dynamically-generated application-specific
APIs.  described_routes supports an application metadata structure
(published in JSON, YAML and XML formats) that can be consumed by path-
to, and (helpfully) generates it automatically online or offline from
the routes configured for a Rails-based application.

The two libraries can be used separately or together - an JavaScript
client is under independent development for example.  Moreover, the
underlying metadata format is framework-neutral; we have been careful
not to “leak” Rails concepts into it.

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



[Rails] sending email problem

2009-05-07 Thread Kentor

Hello,

I'm very new to ruby on rails. I'm trying to setup a simple form to
send an email. I've followed many different tutorials and nothing
seems to work for me... I've tried using tls, pony plugin,
actionmailer, etc... Even sending an email from the cmd prompt would
be fine... I just want to be able to send anything to my gmail account
from my localhost environment. Please understand that I am really new
to ruby on rails.. please explain in as much detail as you can. Thanks
a lot for your help.

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



[Rails] About rails version

2009-05-07 Thread y-w

Hello all.

I'm planning to use the ruby 1.8.5.
And I was wondering which version of rails should I use.

In the official web site it seems that rails still supports v 1.8.5

  We recommend Ruby 1.8.7 for use with Rails. Ruby 1.8.6, 1.8.5, 1.8.4
and 1.8.2 are still usable too, but version 1.8.3 is not.

  Source: Compile it yourself
  Windows installer: Ruby, popular extensions, editor
  OS X 10.4: Ships with broken Ruby, follow this guide
  OS X 10.5: Included with developer tools
  (then do "gem update rails")

However, it does not describe which version of rails fits to v 1.8.5.

Could someone educate me which version of gems and rails
fits to ruby v 1.8.5?

Best Regards,
Yu Watanabe

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



[Rails] Rails routes with prefix before the :id

2009-05-07 Thread Sharcho

This works:
map.connect '/bananas/pdf/file/:id.pdf', :controller =>
'bananas', :action => 'pdf'

This doesn't work:
map.connect '/bananas/pdf/file_:id.pdf', :controller =>
'bananas', :action => 'pdf'

So once I change the slash to underscore the route doesn't work the
way I expect it to.
Is there some way I need to escape the routes to make them work (Rails
2.1.2)?

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



[Rails] Nested attributes, fields_for

2009-05-07 Thread Kostas

Hello,

My ignorance in Rails should be evident from my wording perhaps,
however I couldn't resolve the following w/o tinkering with
action_view/helpers/form_builder.rb a bit. Please give me some
pointers if possible.

I have a model using globalize2 for translations. It is actually a
has_many assotiation. I am updating the translated attributes through
the nested attributes framework. I am building a form as usual and use
fields_for to show the translated attributes for the different locales
to be edited. So far so good everything works as expected.

However I need to specify the order by which the different locales
appear when fields_for runs. For example I want the :el locale fields
to appear before :en (yes, alphabetically, or more generally,  a
predictable ordering is need).

As it is, globalize2 doesn't use any :order in the assosiaction
definition and that makes sense, this path is called frequently and it
would impose additional strain in the db backend. So the different
locales appear with whatever order they are stored in the database (if
that) which can be considered arbitrary.

I thought of using:

<% f.fields_for :globalize_translations,
f.object.globalize_translations.find(:all, :order => "locale ASC") do |
t| %> ...

instead but the explicit object is ignored as it is an array and even
then, the objects within won't respond to new_record method (I am
editing an existing record).

So, any ideas? For the above to work as I'd like, I did this to
actionpack-2.3.2/lib/action_view/helpers/form_builder.rb (arround line
1039):

def fields_for_with_nested_attributes(association_name, args, block)
  name = "#{object_name}[#{association_name}_attributes]"
  association = @object.send(association_name)

  explicit_object = args.first [b]## if
args.first.respond_to?(:new_record?)[/b]

  if association.is_a?(Array)

children = explicit_object ? [explicit_object].flatten :
association
 
^

explicit_child_index = args.last[:child_index] if args.last.is_a?
(Hash)

children.map do |child|
  fields_for_nested_model("#{name}[#{explicit_child_index ||
nested_child_index}]", child, args, block)
end.join
  else
fields_for_nested_model(name, explicit_object || association,
args, block)
  end
end

... which of course "works for me" but I have no idea of its side-
effects and of course I feel less than competent about changing core
code like this.

Please help :)

Thanks,
-Kostas

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Todd Fox

Todd Fox wrote:
> how would that work?

we need the html in xml (html wrapped inside the xml) for another 
application read and then render that html.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: is there simpler way to export html within xml

2009-05-07 Thread Todd Fox

how would that work?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] DRb::DRbConnError

2009-05-07 Thread Mindtonic

Hello, I am trying to run my tests using rake, but I keep getting this
error.  Anyone know why that might be happening?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] RMagick, ImageMagick, Passenger and Dreamhost

2009-05-07 Thread Daniel2Surf

I need to use the newest version of RMagick, so i did everything as
they say on this wiki: http://wiki.dreamhost.com/index.php/RMagick

But, my Rails app isn't working, here is the error:

This installation of RMagick was configured with ImageMagick 6.5.1 but
ImageMagick 6.0.6 is in use.

I tried to set the environment variable: LD_LIBRARY_PATH... but no
success...
I've read a lot of people with the same problem, but i couldn't find
the solution.
I guess the problem is to set a environment variable in passenger.
Does anybody can help me?

Thanks a lot.

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



[Rails] How to apply spreadsheet-excel-ole-storage.patch and parseexcel-ole-storage.patch

2009-05-07 Thread deepa

I am going to export data to excel file from my project.
I am using spreadsheet-excel (0.3.5.1) gem to read/write data in
excel.
I got # error when exporting some amount
of data to excel.
when i am searching for the above problem , i got spreadsheet-excel-
ole-storage.patch and parseexcel-ole-storage.patch as a solution from
http://code.google.com/p/ruby-ole/wiki/ExcelPatches.
(i got the patches from 
http://code.google.com/p/ruby-ole/source/browse/trunk/contrib/?r=51).

Now i just want to know how to use these patch  ??

Please guide me.

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



[Rails] Re: Google maps error with Rails 2.3.2

2009-05-07 Thread Carl LaFong



On Mar 28, 6:48 pm, Tam Kbe  wrote:
> I have been using Google Maps with Rails 2.0.2 and 2.1.0 which works
> fine. I followed this tutorial:
>
> Now after upgrading to Rails 2.3.2 I'm getting the following error:
> uninitialized constant ActionController::AbstractRequest
>
> on the following line:
> <%= GMap.header %>
>
> Has anything changed in Rails 2.3.2 regarding the way Google maps are
> called?
>
> Any ideas?
>
> Thanks,
>
> Tam
> --
> Posted viahttp://www.ruby-forum.com/.

Tam,
I had the same problem. I used the directions to edit the ym4-gm plug
in here:
http://railsforum.com/viewtopic.php?id=24839
it worked great for me.
Hope it helps.
Carl Lafong

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



[Rails] Micro-frameworks

2009-05-07 Thread Martin Streicher


I've written an article on micro-frameworks, featuring Sinatra for  
Ruby and Limonade for PHP. You can read the story online at 
http://www.linux-mag.com/id/7324 
.

I also wrote an intro to the Ruby debugger and how to use it in Rails.  
You can find it online at http://www.linux-mag.com/id/7319. I hope the  
story increases awareness of the debugger's usefulness.

Enjoy.

I am always looking to write topics helpful to the community, so  
please send suggestions, if you have any.

Martin


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



[Rails] Re: open call works fine in irb but not through webrick server

2009-05-07 Thread Karika

I tried using script/console
It still give me same error ...

-

D:\Ruby Applications\website>ruby script\console
Loading development environment.
>> require 'open-uri'
=> true
>> source = "http://google.com";
=> "http://google.com";
>> open(source)
OpenSSL::SSL::SSLError: SSL_CTX_new:: library has no ciphers
from D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in
`new'
from D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in
`initialize'
from D:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
from D:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
from D:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
from D:/ruby/lib/ruby/1.8/net/http.rb:324:in `start'
from D:/ruby/lib/ruby/1.8/open-uri.rb:544:in `proxy_open'
from D:/ruby/lib/ruby/1.8/open-uri.rb:525:in `direct_open'
from D:/ruby/lib/ruby/1.8/open-uri.rb:169:in `open_loop'
from D:/ruby/lib/ruby/1.8/open-uri.rb:164:in `catch'
from D:/ruby/lib/ruby/1.8/open-uri.rb:164:in `open_loop'
from D:/ruby/lib/ruby/1.8/open-uri.rb:134:in `open_uri'
from D:/ruby/lib/ruby/1.8/open-uri.rb:424:in `open'
from D:/ruby/lib/ruby/1.8/open-uri.rb:85:in `open'
from (irb):13
>>

-
On May 6, 6:49 pm, Tom Z Meinlschmidt  wrote:
> irb != rails
>
> so try this script via script/console
>
> irb is interactive ruby console, so libraries etc could be different for
> ruby and for rails
>
> if this will work in script/console, then it will work via
> mongrel/webrick as well
>
> tm
>
>
>
>
>
> Karikawrote:
> > require 'rss/1.0'
> > require 'rss/2.0'
> > require 'open-uri'
>
> > source = "something.com" # url or local file
> > content = "" # raw content of url will be loaded here
> > open(source,:proxy => nil) do |s| content = s.read end
> > rss = RSS::Parser.parse(content, false)
>
> > puts "Root values"
> > print "RSS title: ", rss.channel.title, "\n"
> > ##
> > Now, running this code through IRB works fine and gives me correct
> > result.
> > Whereas, If I run same piece of code through WEBRICK server, it gives
> > me following error ...
>
> > ---­---
> > OpenSSL::SSL::SSLError in Document#feed
> > SSL_CTX_new:: library has no ciphers
> > RAILS_ROOT: ./script/../config/..
>
> > Application Trace | Framework Trace | Full Trace
> > D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in `new'
> > D:/ruby/lib/ruby/site_ruby/1.8/net/protocols.rb:38:in `initialize'
> > D:/ruby/lib/ruby/1.8/net/http.rb:430:in `open'
> > D:/ruby/lib/ruby/1.8/net/http.rb:430:in `do_start'
> > D:/ruby/lib/ruby/1.8/net/http.rb:419:in `start'
> > D:/ruby/lib/ruby/1.8/net/http.rb:821:in `request'
> > D:/ruby/lib/ruby/1.8/net/http.rb:615:in `get'
> > ---­---
>
> > Any clue ??
> > Is it something to do with SSL certification ?
>
> > Thanks,
> >KarikaShah
>
> --
> ===­
> Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache
>
> www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz
> ===­-
>  Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] has_many through association

2009-05-07 Thread Intern ruby

1) class Group < ActiveRecord::Base

has_many :group_users
  has_many :users, :through => :group_users
end

2)class User < ActiveRecord::Base
has_many :group_users
  has_many :groups, :through => :group_users
end

3))class CreateGroupUsers < ActiveRecord::Migration   # JOINING
TABLE
  def self.up
create_table :group_users do |t|
t.column:group_id,:string
t.column:user_id,:string
  t.column  :group_admin, :boolean
  t.timestamps
end
  end

Can anybody please help me how to set the value of group_admin in
GroupUsers ?

I want to do like this :

@group.group_users.group_admin =1 (X- NOT WORKING THOUGH)
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Dabs like product filtering

2009-05-07 Thread John Butler

Hi,

Im trying to create a search\filtering similar to dabs, see link below.
So the "Refine Your Search" menu breaks down the different
categories\sub categories for a product with a count of how many are
available and you can drill down

Is there a plugin in rails that makes this easy(ive looked about but
nothing seemed to meet this requirment)

or

is there any advice on how best to do this.

Options maybe to do it dynamically so when a customer searches then get
the relevant sub categories and do the counts seperately(this seems
intensive and will kill performance as the dataset gets bigger)

Another option may be to do it evytime a new product is added to update
a table with counts etc, again this seems a bit overkill as it will need
to be done everytime a product is added/edited etc


http://www.dabs.com/category/components-and-storage,storage,accessories/11161

Any advice appreciated,

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

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



[Rails] Template : modify file to add code

2009-05-07 Thread Encore lui

Hello,

 When using rails templates
(http://github.com/jeremymcanally/rails-templates/tree/master), is it
possible to complete a file and to add code in this file ?

For example, i create a model "home" and i would like to insert a
"validates_of" condition. How can i do that ?

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

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



[Rails] Re: what database field type should i use ??

2009-05-07 Thread Billee D.

Sometimes it''s a matter of taste or design constraint, but why not
use a small join table and a foreign key? ENUM is also a great choice,
as these guys have pointed out, but sometimes there is a bit of
overhead -- but you shouldn't worry about that until it becomes an
issue. Personally, I find it easier to maintain a simple join table
and FK relationships than to mess with ENUM field types.

I don't know if this is still applicable, but it seems like there is a
bit of data massaging in Rails for the ENUM type (Rails converts it
internally to VARCHAR):

http://lists.rubyonrails.org/pipermail/rails/2005-January/001536.html

I like to let the database do as much work as it can, :-)

HTH!

Billee D.

On May 7, 4:43 am, Vipin  wrote:
> in a database table if there is a field which has a certain set of
> fixed values. for example
> staus => {Single, Married, Divorced }
> OR
> state => {California, Albama, Olaska ...}
>
> so what should be preferred way out of the following for storing the
> values
>
> 1. Keep the field as "string(Rails)"  VARCHAR(MySQL) itself and
> while showing the field just show the field value.
>
> 2. Keep the field internally as a code like {:california =>
> 01, :albama => 02, washington => 03 } but while showing the state
> show only the corresponding state.
>
> By using option 2, a certain disadvantage is extra computation time
> required to find out corresponding state name based on code when
> showing the state field to user. But an advantage could be in terms of
> smaller database. In my opinion, saving 01 as an integer could save
> significant space than storing "california"  if number of records
> happen to be in tens of thousands .
>
> please suggest ??
>
> vipin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Paperclip: strange mime type on windows

2009-05-07 Thread Marco Mastrodonato

I partially solved using this plugin to get correct mime from extension:
http://code.google.com/p/mimetype-fu/

And in my model i added:

  validate :validate_content_type

  protected

  def validate_content_type
errors.add(:file, "Format #{File.mime_type?(file.path)} is 
invalid!") unless File.mime_type?(file.path) == "application/pdf"
  end


If somebody want to get better this code will be appreciated
Thanks in any case
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: problems with scriptaculous..

2009-05-07 Thread Sergio Ruiz


okay, i found it.. i am stupid..

there is a space in the div  name..



i removed the space, and it works fine..

i suck..

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

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



[Rails] ActionMailer - which object has perform_delivery_test method

2009-05-07 Thread James Byrne

How do I determine where the method perform_delivery_test(mail) is
located?  This method is defined as part of ActionMailer::Base as a
private method but I cannot find it defined when I do this in the
console:

>> print ActionMailer::Base.private_methods.sort
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: problems with scriptaculous..

2009-05-07 Thread Sergio Ruiz

hmm.. for some reason, neither of these work...

this is really perplexing me..

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

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



[Rails] Paperclip: strange mime type on windows

2009-05-07 Thread Marco Mastrodonato

When i upload a pdf, validations doesn't work, only images validation
works. Avoiding check, file was loaded but with this content type:
file_content_type: "binary/octet-stream"

How can i solve? I'd like to have "application/pdf"
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Add class to "form_for"

2009-05-07 Thread anton effendi
your welcome


On Thu, May 7, 2009 at 2:50 PM, Jim Burgess <
rails-mailing-l...@andreas-s.net> wrote:

>
> Wonderful,that works just fine.
> Thank you very much indeed.
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>


-- 
Wu You Duan

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



  1   2   >