[Rails] Re: rails on ruby-1.8.7

2009-02-09 Thread MaD

the current stable version (for 1.8) is 1.8.7. that's all you have to
know.

but to answer your question:
of course development is focussing on compatibility with the next
generation of ruby. 1.8.8 is still to come out later this year (even
though 1.9.1 has been released). but it's not experimental or
anything. 1.8.7 is working fine. with 1.9.1 there are still problems
with some gems.

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



[Rails] Re: fastercsv, freezing into vendor/gems

2009-02-09 Thread MaD

well, i just looked at it again. you're right: "rake gems:unpack"
should provide exactly the functionality you're looking for. however i
don't know why it's failing for you.

and on that snippet of yours: try it and tell us whether it's working
or not. looks promising.

On 9 Feb., 17:25, bingo bob  wrote:
> I made a little progress..
> I went to vendor
> mkdir gems
> went in there
> and unpacked fastercsvsent it to my webhost...
>
> However on the webhost the line require 'fastercsv' still fails.
>
> I read on joyent knoweldeg base running this in environment.rb might do
> it...
>
> config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
>   File.directory?(lib = "#{dir}/lib") ? lib : dir
> end
>
> Will that code above solve the problem, claims to search within
> vendor/gems!
>
> bb
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: fastercsv, freezing into vendor/gems

2009-02-09 Thread MaD

well, i just looked at it again. you're right: "rake gems:unpack"
should provide exactly the functionality you're looking for. however i
don't know why it's failing for you.

and on that snippet of yours: try it and tell us whether it's working
or not. looks promising.

On 9 Feb., 17:25, bingo bob  wrote:
> I made a little progress..
> I went to vendor
> mkdir gems
> went in there
> and unpacked fastercsvsent it to my webhost...
>
> However on the webhost the line require 'fastercsv' still fails.
>
> I read on joyent knoweldeg base running this in environment.rb might do
> it...
>
> config.load_paths += Dir["#{RAILS_ROOT}/vendor/gems/**"].map do |dir|
>   File.directory?(lib = "#{dir}/lib") ? lib : dir
> end
>
> Will that code above solve the problem, claims to search within
> vendor/gems!
>
> bb
> --
> Posted viahttp://www.ruby-forum.com/.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: mysql install problem

2009-02-09 Thread MaD

^ make sure you'Re getting 1.8.7 (which is the latest stable). 1.9.1
still causes problems with some gems.

On 9 Feb., 23:18, Chad  wrote:
> You're trying to update the rails framework, not ruby.
>
> http://www.ruby-lang.org/en/downloads/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 on ruby-1.8.7

2009-02-09 Thread toy

Thanks for answering!
and please :), one more question.

I looked for '1.8.7' all the time.
I read '1.8.7' is as pre-release(or experimental-release) for '1.9'.

and I found this, in CHANGELOG of rails-2.1.2.
* Ruby 1.9 compatibility.  #1689, #10546 [Cheah Chu Yeow, frederico]

Is this the point of the answer?
> you can run rails up to the latest version using ruby 1.8.7 without
> problems.

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



[Rails] WebOrb usage

2009-02-09 Thread Sarika Patil

Hi,

I m newbie for flex and want it to be implemented with rails.
I followed the steps given in flexiblerails but what i wanted to know is

What is the use of weborb ?

Without installing weborb plugin also my flex project runs fine.
So can any one tell me.

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

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



[Rails] Re: How to install Rails on CentOS 5.2

2009-02-09 Thread Xie Hanjian
Hi Paryank,

Though I have no direct solution for you, I think compile/install Ruby
1.8.7 may solve this problem, while ruby packages on CentOS is obsolete.

Jan

* Paryank  [2009-02-09 21:29:44 -0800]:

> 
> Hi
> 
> I have installed CentOS 5.2 on my PC. Ruby 1.8.5 and Ruby-devel
> packages are already installed. I have downloaded rubygems-1.3.1.tgz
> package and installed it. Now I am trying to install Rails by the
> command below:
> 
> gem install rails
> 
> But it gives me the following error:
> 
> ERROR:  While executing gem ... (Zlib::DataError)
> incorrect header check
> 
> zlib and zlib-devel are already installed on my pc. I can install
> other gems like hpricot etc. But still I cannot install rails.
> 
> Can somebody please guide me how can I install rails on CentOS?
> 
> Thank you,
> Paryank
> --~--~-~--~~~---~--~~
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en
> -~--~~~~--~~--~--~---

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


pgpZgGQECQxoA.pgp
Description: PGP signature


[Rails] Re: Get @current_user into model

2009-02-09 Thread Geekyra

Very interesting I will try it right away (actually I never done
anything to application.rb) and the way u treat it I think it will
work, thanks.

On Feb 9, 5:16 pm, Ram  wrote:
> Geekyra,
>
> Interesting.. had the same issue. Put this in application.rb
>
>   around_filter :you_dont_have_bloody_clue
>
>     protected
>
>     def you_dont_have_bloody_clue
>       klasses = [ActiveRecord::Base, ActiveRecord::Base.class]
>       methods = ["session", "cookies", "params", "request"]
>
>       methods.each do |shenanigan|
>         oops = instance_variable_get(:"@_#{shenanigan}")
>
>         klasses.each do |klass|
>           klass.send(:define_method, shenanigan, proc { oops })
>         end
>       end
>
>       yield
>
>       methods.each do |shenanigan|
>         klasses.each do |klass|
>           klass.send :remove_method, shenanigan
>         end
>       end
>
>     end
>
> --courtesy Pratik Naik (though highly NOT recommended by him)
>
> works like a charm.
>
> On Feb 9, 9:26 am, Julian Leviston  wrote:
>
> > What do u mean?
>
> > Blog:http://random8.zenunit.com/
> > Learn rails:http://sensei.zenunit.com/
>
> > On 09/02/2009, at 3:22 AM, Geekyra  wrote:
>
> > > Hello, can anybody help me, how to pass @current_user (generated by
> > > session[user_id] into a model ? for example I have a relationship like
> > > below :
>
> > > User has many Journals
> > > User has many Categories
> > > Journals has many Items
> > > Items has many Categories
>
> > > The problem is I like to sum "amount" field in Item model based on
> > > category and user. So every user has their own category and their own
> > > category amount. So if I want to make a method that return sum of item
> > > amount where do I put it anyway ? On this problem I can't make through
> > > association cause User and Item doesn't related at all, they only
> > > related by journals data.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Full Ajax Application

2009-02-09 Thread Geekyra

I'm not looking for full RIA as well, cos ur right Rails is the best
tool for back end and I really love the agile way. I'm just wan't to
make the client side run faster by partial refresh everything, why do
we need to refresh whole page if what we wan't to do is just refresh
one single line of data ? My point is I just want to make Net app run
faster for country who doesn't have a good net connection (for example
dial up 64kbps) who will suffer for waiting the whole page refreshing
when they only want to update 1 line data.

Actually i have done a full ajax app in rails but i think i violent
the rest way, for 7 rest route that rails provide I'm only using
create and update using form_remote_for and destroy using
link_to_remote. For new, edit, and show i'm using link_to_function
(not link_to_remote) so the client doesn't bother server at all, so
actually I doesn't have new, edit, and show method in controller,
aren't that breaking the REST way ?

And now i have some project that is a crazier ajax way :) I just have
one page (called it dashboard) that have 2 region left and right. On
the left I want to put it all the navigation and link to the data and
the right region is the view of data itself. So the point is everytime
i i choose the navigation on the left dashboard it will replace the
right dashboard with the data so I the view doesn't refesh full page
but only partial right region so It will run as fast as possible.
After several trying i realized the javascript code is really
complicated, so I just wan't to know are there any easier way to do my
problem ?

On Feb 10, 12:10 pm, Robert Walker 
wrote:
> Geekyra wrote:
> > AHH Robert u shoot me straight into my heart cos I'm already falling
> > in love with RAILS :), but very - very thanks anyway cos u restrain me
> > from finding and bugging another mailing list just to cover my ajax
> > exhaustion. Ahh start to learning another framework anw and one more
> > time thanks for the RIA sites suggestion
>
> > On Feb 9, 8:54 am, Robert Walker 
>
> I love Rails as well, and my post was not at all an attack on Rails. It
> just a matter of "the right tool for the right job." Rails is built to
> design a certain type of application and is best used for that task.
>
> It just sounded to me like you were looking for a full-on RIA
> application, and there are some really great frameworks out there for
> building those. Most of them, however, don't really stand on their own.
> They need a back-end. They need something running on the server-side to
> take care of managing the application's data. Rails would make an
> excellent choice to act as that server-side piece. Besides that it's not
> likely that your entire web site will be built as an RIA. That may be
> just one small part of the larger site. Rails would also be an excellent
> choice for handling that which is outside the scope of the RIA.
> --
> 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: uploading files

2009-02-09 Thread abdul hafeez
in ruby on rails we can able to upload by using paperclipp

Go through this link
http://infrastacks.com/?p=57

Enjoy..
Regards
Hafeez

On Tue, Feb 10, 2009 at 11:13 AM, krishna  wrote:

>
> how to upload multiple photos to a rails application.
> >
>

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



[Rails] Problem in integrating Juggernaut chat plugin with Community Engine

2009-02-09 Thread saideep a.v.s
Hello,

  I have been trying to integrate juggernaut chat plugin with
Community-engline and as rails decided to deprecate
add_variables_to_assigns method
in rails 2.2. They don't include this on the list of deprecated methods so I
don't know how to find an alternative to this method. This method is used by
the juggernaut plugin and I wanna try getting it to work with rails 2.2. I
tried copying the source code of this method and add_instance_variable_names
source to the application.rb file but now I'm getting NameError
(uninitialized class variable @@protected_view_variables in
ApplicationController). Does anyone know if there are any alternatives to
these methods?


Following is the error

NameError (undefined local variable or method `add_variables_to_assigns' for
#):
/vendor/plugins/juggernaut/lib/juggernaut.rb:145:in `render'
/app/controllers/chat_rooms_controller.rb:89:in `send_data'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'

/usr/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'



Thanks & Regards,

Saideep Annadatha

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



[Rails] Common model validation probelm

2009-02-09 Thread Dharmdip Rathod

Hello ,

I am facing strange problem here. I have model customer.rb , i am
validating following fields

  validates_presence_of :email
  validates_format_of :email, :with =>
/(^([...@\s]+)@((?:[-_a-z0-9]+\.)+[a-z]{2,})$)|(^$)/i
  validates_uniqueness_of :email
  validates_presence_of  :password,  :on => :create
  validates_length_of :password, :in => 4..20, :allow_nil => false,:on
=> :create
  validates_presence_of:password_confirmation, :if =>
:password_required?
  validates_confirmation_of :password,   :if => :password_required?
  validates_presence_of :first_name
  validates_presence_of :last_name
  validates_presence_of :address
  validates_presence_of :country_id
  validates_presence_of :state_id
  validates_presence_of :city
  validates_numericality_of :zip
  validates_presence_of :phone
  validates_presence_of :securityque_id
  validates_presence_of :answer
  validates_acceptance_of  :policy

after submitting form successfully , i am giving update facility for
updatepassword, and edit profile when i am updating profile it ask for
password field and when i am updating password it ask for nothing .
is there any way 
thank in advance.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] uploading files

2009-02-09 Thread krishna

how to upload multiple photos to a rails application.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 remove special characters? (ie. &)

2009-02-09 Thread Alan Brown
Of course, you can't use this to handle all possible encoded strings

On Mon, Feb 9, 2009 at 8:29 PM, stretch  wrote:

>
> Yachtman,
>
> Check out http://www.ruby-doc.org/core-1.9/classes/CGI.html#M000527
> (It worked with 2.2 also)
>
> >> ugly = CGI::escapeHTML('')
> => "
" > > >> print CGI::unescapeElement(ugly, "A", "IMG") >
=> nil > > >> print CGI::unescapeElement(ugly, "A", "IMG", "BR") > => nil > > There might be a higher level function too, but this shows you how you > might use this directly > > Al > > On Feb 9, 7:34 pm, yachtman wrote: > > This might be such a stupid simple question, so forgive me--I did > > search the forum and elsewhere and couldn't find the answer... > > > > I have an HTML text string that formats nicely on a web page: > > > > s = "Mom & Dad"=> "Mom & Dad" > > > > How do I convert s to just ascii characters, ie. "Mom & Dad"? > > > -- Available for Ruby on Rails development opportunities --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send 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 install Rails on CentOS 5.2

2009-02-09 Thread Paryank

Hi

I have installed CentOS 5.2 on my PC. Ruby 1.8.5 and Ruby-devel
packages are already installed. I have downloaded rubygems-1.3.1.tgz
package and installed it. Now I am trying to install Rails by the
command below:

gem install rails

But it gives me the following error:

ERROR:  While executing gem ... (Zlib::DataError)
incorrect header check

zlib and zlib-devel are already installed on my pc. I can install
other gems like hpricot etc. But still I cannot install rails.

Can somebody please guide me how can I install rails on CentOS?

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



rubyonrails-talk@googlegroups.com

2009-02-09 Thread Robert Walker

yachtman wrote:
> This might be such a stupid simple question, so forgive me--I did
> search the forum and elsewhere and couldn't find the answer...
> 
> I have an HTML text string that formats nicely on a web  page:
> 
> s = "Mom & Dad"=> "Mom & Dad"
> 
> How do I convert s to just ascii characters, ie. "Mom & Dad"?

I haven't tried this, but it looks like a robust solution that might 
work for you:
http://htmlentities.rubyforge.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: 1 vs True vs 't'

2009-02-09 Thread Rob Biedenharn

On Feb 9, 2009, at 9:52 PM, yachtman wrote:
> Robert,
>
> Thanks for the reply.
>
> I imagine in this case, since I am only counting based on a boolean
> value, there should be no worry about sanitization?
>
> On Feb 8, 3:54 pm, Robert Walker 
> wrote:
>> Robert Walker wrote:
>>> Table.count(:conditions => [ "approved = ?", true ])
>>
>> Well I meant Table.count(:conditions => [ "approved = ?", false ]),  
>> but
>> you get the idea.
>> --


You're not doing ['approved = ?',false] for the sanitization as much  
as for letting the database adapter fill in its own notion of what  
value it uses for false.  Even if you were doing more than counting,  
you have control of the inputs so there's no SQL injection here.

-Rob

Rob Biedenharn  http://agileconsultingllc.com
r...@agileconsultingllc.com


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



[Rails] Re: Full Ajax Application

2009-02-09 Thread Robert Walker

Geekyra wrote:
> AHH Robert u shoot me straight into my heart cos I'm already falling
> in love with RAILS :), but very - very thanks anyway cos u restrain me
> from finding and bugging another mailing list just to cover my ajax
> exhaustion. Ahh start to learning another framework anw and one more
> time thanks for the RIA sites suggestion
> 
> On Feb 9, 8:54�am, Robert Walker 

I love Rails as well, and my post was not at all an attack on Rails. It 
just a matter of "the right tool for the right job." Rails is built to 
design a certain type of application and is best used for that task.

It just sounded to me like you were looking for a full-on RIA 
application, and there are some really great frameworks out there for 
building those. Most of them, however, don't really stand on their own. 
They need a back-end. They need something running on the server-side to 
take care of managing the application's data. Rails would make an 
excellent choice to act as that server-side piece. Besides that it's not 
likely that your entire web site will be built as an RIA. That may be 
just one small part of the larger site. Rails would also be an excellent 
choice for handling that which is outside the scope of the RIA.
-- 
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: sparse tables seems to be an impossible term to search on google

2009-02-09 Thread frankjmat...@gmail.com

ive asked this question a half a dozen different ways and none have
ever gotten an answer.

is it really such a bad idea? some feedback would be welcome... or
maybe a point in the direction of the appropriate forum for these
kinds of questions.

- FJM

On Feb 9, 10:34 am, "frankjmat...@gmail.com" 
wrote:
> without bringing up 3000 articles on low languages and theory which i
> am not looking for.
>
> i just want some pointers to effectively storing variable column
> sparse tables in ruby/rails preferably with a lean towards pulling
> them all together in a cohesive table...
>
> afaik i need a table for my rows
> a table for my columns
> a table for cells.
> and a table of "tables"
>
> that seems like a really long and stupid way to store variable sized
> tables...
>
> is there a more generic/simple way to do this?
>
> i realize this may be an edge case but in this situation, im 98% sure
> this is what i  need... just cant figure out how to make it work
> effectively.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: dynamic constant assignment

2009-02-09 Thread Jeffrey L. Taylor

Quoting Erwin :
> 
> I also tried :
> 
>   AVAILABLE_LOCALES = ALL_LOCALES.dup
>  AVAILABLE_LOCALES.delete_if{|key, value| key == I18n.locale }
> 
> but get also an error ... dynamic constant assignment (SyntaxError)
> with the dup ...
> I don't understand as I can do it with irb 
> 
> 
> On 9 fév, 23:06, Erwin  wrote:
> > I have a constant set up like that :
> > ALL_LOCALES
> > => {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
> > GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
> > "pl"=>"Polski", "en-US"=>"English (US)", "pt-BR"=>"Português
> > (Brasil)"}
> >
> > my locale is set :  I18n.locale
> > => :"en-US"
> >
> > based on the current locale , dynamically changed, I would like to
> > define a new constant,   AVAILABLE_LOCALES which would be the
> > ALL_LOCALES minus the current locale...
> >
> > AVAILABLE_LOCALES
> > => {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
> > GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
> > "pl"=>"Polski", "pt-BR"=>"Português (Brasil)"}
> >
> > I dont' see how todo that ?  any clue ?

What is constant about a variable that changes everytime the locale changes?
And if you have multiple users with different locales, potentially changes
with every request?  Given how changeable it is, why do you want to confuse
the future maintainer by implying it is constant when it isn't.

Or put another way, why can't the variable be named available_locales.

Shrug,
  Jeffrey

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



[Rails] Re: How to remove special characters? (ie. &)

2009-02-09 Thread stretch

Yachtman,

Check out http://www.ruby-doc.org/core-1.9/classes/CGI.html#M000527
(It worked with 2.2 also)

>> ugly = CGI::escapeHTML('')
=> "
" >> print CGI::unescapeElement(ugly, "A", "IMG")
=> nil >> print CGI::unescapeElement(ugly, "A", "IMG", "BR") => nil There might be a higher level function too, but this shows you how you might use this directly Al On Feb 9, 7:34 pm, yachtman wrote: > This might be such a stupid simple question, so forgive me--I did > search the forum and elsewhere and couldn't find the answer... > > I have an HTML text string that formats nicely on a web  page: > > s = "Mom & Dad"    => "Mom & Dad" > > How do I convert s to just ascii characters, ie. "Mom & Dad"? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send 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: Serverside chart generator

2009-02-09 Thread alberto

ziya gives you great looking swf graphs.

Instructions to install the gem and samples:

http://ziya.liquidrail.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: before_save :strip_whitespace => saves with spaces

2009-02-09 Thread Newb Newb

Thanks for the reply.
Could you tell me the way of implementation pls.
How can i resolve it.


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

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



[Rails] Re: threading, returning from action method, blocking

2009-02-09 Thread alberto

I would give the spawn plugin a try.

http://rubyforge.org/projects/spawn/

spawn do
do_stuff  # stuff takes a long time
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: upload multiple images with attachment_fu

2009-02-09 Thread Dharmdip Rathod

Sarika Patil wrote:
> hi,
> 
> You may use RMagick for this since there is method Image_list which 
> helps to create an array of images and store them into single image
> 
> 
> Dharmdip Rathod wrote:
>> i am getting array of images but when i trying to save it,
>> it gives error
>> 
>>NoMethodError (undefined method `strip' for
>>#)
>> 
>> 
>> help ?

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: Help with Scaffolding deprecation on Rails 2.2.2

2009-02-09 Thread stretch

Fred,

perhaps creating the app with the version you need will help avoid
this and other issues.  You can do it by specifying the version
enclosed in underscores before passing the name of the new app:

   rails _1.2.3_ mynewapp

Al

On Feb 9, 3:56 pm, Frederick Cheung 
wrote:
> On Feb 9, 11:28 pm, untz  wrote:
>
> > On line 46, on my WEBrick server, this is what is set:
>
> > config.time_zone = ‘UTC’
>
> just remove that - it's an option only available with rails >= 2.1
> (which was the case when you generated the app, but now you're trying
> to run with an older version)
>
> > Question(s):
>
> > (1) Should I stick with learning Rails 2.2.2 and upgrade to Ruby 1.9?
>
> certainly don't skip to ruby 1.9 unless you are using a version of
> rails ready for it (which right now means rails 2.3rc1).  I would
> stick to 2.2.2 if you're still learning
>
> Fred
>
> > (2) Is the 2nd Edition of this book now deprecated or is there a
> > workaround to my problem?
>
> > (3) Any good resources on learning the new version of Rails?
>
> > Happy programming!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Search between dates won't work properly

2009-02-09 Thread Julian Leviston

I didn't know you could pass an array of arrays!

Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/

On 10/02/2009, at 6:29 AM, Gabi Ge   
wrote:

>
> Jeff Burlysystems wrote:
>> How about:
>>
>> ...
>> require 'time'
>> ...
>> invoices = Invoice.find(:all, :conditions=>['issue_date is not null
>> and (issue_date >= ? or issue_date <= ?)', Time.parse('2009-02-09
>> 00:00:00'), Time.parse('2009-02-09 23:59:59')] :order=>'issue_date')
>> ...
>>
>> Jeff
>
> Thanks for your reply, and your help! It gave me a hint and solved the
> problem like this:
>
> self.cond << ["invoices.issue_date > ?", from - 1] unless from.blank?
> self.cond << ["invoices.issue_date < ?", to + 1] unless to.blank?
>
> because issue_date is a datetime, and generating an invoice means  
> saving
> both date and time of the day. This way the search will have the same
> results as in your example.
>
> Once again, thank you for your help!
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >

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



[Rails] How to remove special characters? (ie. &)

2009-02-09 Thread yachtman

This might be such a stupid simple question, so forgive me--I did
search the forum and elsewhere and couldn't find the answer...

I have an HTML text string that formats nicely on a web  page:

s = "Mom & Dad"=> "Mom & Dad"

How do I convert s to just ascii characters, ie. "Mom & Dad"?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Server won't start with ActiveMerchant

2009-02-09 Thread stretch

Lee,

Do you need to have a require statement in environment.rb?

require 'active_merchant'

Al

On Feb 9, 4:19 pm, Lee Munroe 
wrote:
> Hi,
>
> Everything was working fine until I went to use ActiveMerchant.
> Have spent a few hours trying to figure this out with no success.
>
> Here's the error I'm getting
>
> ** Starting Rails with development environment...
> Exiting
> /Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in
> `load_missing_constant': uninitialized constant ActiveMerchant
> (NameError)
>
> And in environment.rb I have
>
> unless RAILS_ENV == 'production'
>     PAYPAL_ACCOUNT = 'sandboxacco...@example.com'
>     ActiveMerchant::Billing::Base.mode = :test
>   else
>     PAYPAL_ACCOUNT = 'paypalacco...@example.com'
>   end
>
> Appreciate anyone kind enough to help me out. Can't get my head around
> this and holding me back.
>
> Cheers
> --
> 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: 1 vs True vs 't'

2009-02-09 Thread yachtman

Robert,

Thanks for the reply.

I imagine in this case, since I am only counting based on a boolean
value, there should be no worry about sanitization?

On Feb 8, 3:54 pm, Robert Walker 
wrote:
> Robert Walker wrote:
> > Table.count(:conditions => [ "approved = ?", true ])
>
> Well I meant Table.count(:conditions => [ "approved = ?", false ]), but
> you get the idea.
> --
> 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: AR:BASE.default_timezone

2009-02-09 Thread James Byrne

Brent Miller wrote:
> in your test_helper:
> 
> require 'mocha'
> 
> Then, in your test
> 
> def test_something
>   tz = :local
>   ActiveRecord::Base.expects(:default_timezone).returns(tz)
>   assert_equal tz, ActiveRecord::Base.default_timezone
> end
> 
> The trick is to set tz to be whatever you want to get back from
> AR::Base.default_timezone.  If you use AR::Base.expects, then your
> test will fail if AR::Base.default_timezone is called more than once
> or not at all.  If you don't care how many times it gets called (i.e.,
> if that's not something you need to test), then use "AR::Base.stubs
> (:default_timezone).returns(tz)" instead.
> 

However, what I am testing is a library that actually modifies 
ActiveRecord behaviour based on the default_timezone setting. So, it is 
pointless to mock or stub what I am actually testing.  I eventually just 
overrode the environment setting in the test itself.

  it "should set the UTC time (for _at/_on) correctly" do
ActiveRecord::Base.default_timezone = "utc"
...
  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: dbd-odbc gem not

2009-02-09 Thread Ben Lieber

FYI: I un-installed and re-installed Ruby, rails, and Rubygems. Still 
getting the SAME error. Any help would be rally appreciated, I've burned 
so many hours on this stupid little problem now.

Thanks

-Ben
-- 
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: favored development environment

2009-02-09 Thread blasterpal

AgileHack,

I work in an in-house Rails shop for a fairly large site (we are a
team of about 7 developers, not including operations and QA).  We use
OSX on PowerMacs and Mac Minis with Textmate and git. Some are
starting to poke around with MacVim and others swear by Netbeans.
Secondly, everyone uses OSX for dev personally except for one guy who
uses Debian.

Largely, everyone chooses OSX and Macs, its not a forced decision. All
the vendors who come in to staff augment or work on other projects
from respectable Ruby/Rails shops always show up with Macbooks.

For what it's worth, I don't use a MacBook pro, never have. I think
they are too much $$ for RoR dev. I use a bottom of the line with
extra RAM.

H
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Option on select form helper to customize "Select" text?

2009-02-09 Thread Wes Gamble

Fred,

Thanks for the info.  I neglected to mention that this is on Rails 1.2.6 
(please no one "helpfully suggest" that I upgrade - thanks ;]), so these 
options are not available.  It's fine - I won't die.

One further question, if you use a "unified" helper like date_select in 
the current v. of Rails (obviously), can you set different promopts for 
each component input field of the date?

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

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



[Rails] Re: controller utility method: want to use in tests. Where should it go?

2009-02-09 Thread itsastickup

Ok 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] Server won't start with ActiveMerchant

2009-02-09 Thread Lee Munroe

Hi,

Everything was working fine until I went to use ActiveMerchant.
Have spent a few hours trying to figure this out with no success.

Here's the error I'm getting

** Starting Rails with development environment...
Exiting
/Library/Ruby/Gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:445:in
`load_missing_constant': uninitialized constant ActiveMerchant
(NameError)

And in environment.rb I have

unless RAILS_ENV == 'production'
PAYPAL_ACCOUNT = 'sandboxacco...@example.com'
ActiveMerchant::Billing::Base.mode = :test
  else
PAYPAL_ACCOUNT = 'paypalacco...@example.com'
  end

Appreciate anyone kind enough to help me out. Can't get my head around
this and holding me back.

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

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



[Rails] Re: controller utility method: want to use in tests. Where should it go?

2009-02-09 Thread Frederick Cheung


On 10 Feb 2009, at 00:01, itsastickup wrote:

>
> Hi,
>
> I've a simple method I call in my action methods. So far I've put it
> in application.rb in the ActionController class.
>
> However I can't call it from my test code. Where should I be putting
> it? I've tried adding this to application.rb :
>
> module ActionController
>
>  def handy
>  return dostuff
>  end
>
> end
>
> but it didn't work.
>
> Is this possible?


adding a method to application.rb lets controllers call it because you  
are adding a method to ApplicationController and your controllers  
inherit from that.
In a test you are subclassing Test::Unit::TestCase (or more recently  
ActiveSupport::TestCase or some other class if you are using a  
different testing framework), so clearly you can't call and  
ApplicationController instance method. Easiest thing is probably to  
put the methods in a module and include it in both places.

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: Search between dates won't work properly

2009-02-09 Thread Frederick Cheung


On 9 Feb 2009, at 17:29, Gabi Ge wrote:

>
> I'd like to search for invoices in the database, having the date range
> set (from, to). The problem is that invoices whose issue dates match  
> the
> 'from' or 'to' dates will not show up in results.
>
> For example:
> Created an invoice today ("2009-02-09"), and I'm searching by  
> issue_date
> between from and to, these are the params:
>
> "filter"=>{"from"=>"2009-02-09", "to"=>"2009-02-09"}

Is the issue date a date column or a datetime column ?
if you have a datetime column containing  2009-02-09 14:00 and compare  
it to 2009-02-09 then the 2009-02-09 is turned into 2009-02-09 00:00  
which can mess things up for you.

Fred
>
>
> In the model I have the sql conditions, as well as a scope, looks like
> this:
>
> self.cond = Array.new
> self.cond << ["invoices.issue_date >= ?", from] unless from.blank?
> self.cond << ["invoices.issue_date <= ?", to] unless to.blank?
> result = join_conditions
> ---
> named_scope :filter, lambda { |invoice_filter|
>{ :conditions => invoice_filter.sql_conditions }}
>
> The scope gets a filter object that has both 'from' and 'to' fields  
> set.
> If I set the 'to' field to tomorrow's date, then the invoice will
> appear, but I don't understand why it wouldn't work as is since there
> are '<=' & '>=' comparisons in conditions.
>
> Any help or suggestion would be appreciated!
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Re: Specifying session_id in params?

2009-02-09 Thread Frederick Cheung


On 9 Feb 2009, at 20:42, Brian Culler wrote:



I am using a Flex based front end on top of a rails backend.  When the
SWF is first loaded from the rails app to the client's browser, a
session is created on the rails side.

However, subsequent requests from the loaded Flex app are also  
creating

whole new sessions as well.  I need the flex app's calls to continue
using the existing session.

So I am sending the flexapp the original session id, and am then
appending that session id into the params when it sends it back.  Is
there anything else you need to do besides inserting the specific
session id into the request params to get rails to use that session id
instead of making a new one?  If it makes a difference, this is a
multipart post from the flex app back to the rails server.



Reading the session_id from the params is turned off by default. Try  
setting the cookie_only option to false (and make sure that the  
session_key option matches whatever flex is sending)


Fred

smime.p7s
Description: S/MIME cryptographic signature


[Rails] executing a generator on the browser

2009-02-09 Thread bbtosurf

Hi

I currently have a generator which creates a directory of files. I
want clients on my app to be able to execute that generator and save
those files in their personal folder on the server. The thing is that
I have always executed this generator via terminal and it always
creates the series of files on the current path on the terminal where
I executed the command. How can a user execute this generator on the
browser and the files be created in his personal folder.

thanx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 utility method: want to use in tests. Where should it go?

2009-02-09 Thread itsastickup

Hi,

I've a simple method I call in my action methods. So far I've put it
in application.rb in the ActionController class.

However I can't call it from my test code. Where should I be putting
it? I've tried adding this to application.rb :

module ActionController

  def handy
  return dostuff
  end

end

but it didn't work.

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



[Rails] Re: Help with Scaffolding deprecation on Rails 2.2.2

2009-02-09 Thread Frederick Cheung



On Feb 9, 11:28 pm, untz  wrote:
> On line 46, on my WEBrick server, this is what is set:
>
> config.time_zone = ‘UTC’

just remove that - it's an option only available with rails >= 2.1
(which was the case when you generated the app, but now you're trying
to run with an older version)
>
> Question(s):
>
> (1) Should I stick with learning Rails 2.2.2 and upgrade to Ruby 1.9?
>
certainly don't skip to ruby 1.9 unless you are using a version of
rails ready for it (which right now means rails 2.3rc1).  I would
stick to 2.2.2 if you're still learning

Fred

> (2) Is the 2nd Edition of this book now deprecated or is there a
> workaround to my problem?
>
> (3) Any good resources on learning the new version of Rails?
>
> Happy programming!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: AR:BASE.default_timezone

2009-02-09 Thread Foliosus

in your test_helper:

require 'mocha'

Then, in your test

def test_something
  tz = :local
  ActiveRecord::Base.expects(:default_timezone).returns(tz)
  assert_equal tz, ActiveRecord::Base.default_timezone
end

The trick is to set tz to be whatever you want to get back from
AR::Base.default_timezone.  If you use AR::Base.expects, then your
test will fail if AR::Base.default_timezone is called more than once
or not at all.  If you don't care how many times it gets called (i.e.,
if that's not something you need to test), then use "AR::Base.stubs
(:default_timezone).returns(tz)" instead.

Brent

On Feb 9, 11:30 am, James Byrne 
wrote:
> I have a requirement to test code whose execution depends upon the
> default_timezone setting.  I have tried several approaches to this but
> nothing that I do in my test seems to alter the behaviour that is set in
> environment.rb.
>
> Is there a way to dynamically alter AR's method of storing datetime
> during a test? Currently I attempt to do this in this fashion:
>
>     [ "local", "utc" ].each do |tz|
>       ActiveRecord::Base.default_timezone = tz
>       @my_mage = Magik.new
>       @my_mage.description = tz
>       @my_mage.my_time_local = DateTime.now
>       @my_mage.my_time_utc = DateTime.now.utc
>       @my_mage.save!
>       puts @my_mage.description
>     end
>
> but the contents of the my_time_local and my_time_utc do not seem to be
> what I expect:
>
> default_timezone = local
> Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
>   now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77585 <- Time.now
>   UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
>   now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.77609 <- Time.now.utc
>
> default_timezone = utc
> Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
>   now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77807 <- Time.now
>   UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
>   now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.7783 <- Time.now.utc
> .
>
> Is it possible to override AR default_timezone values for testing?
> --
> 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] Newbie - has_many :through case?

2009-02-09 Thread gamericax

hi,

i'm a newbie digging ROR for a week (and loving it i might add) and
trying to get a project done at the same time.  i'm more used to
direct SQL so trying to get hang of active record asssociations and
figure out what is done for me and what is not by script/generate
model and db:migrate.

in a nutshell, i have 3 core models where users enter competitions
with submissions.

entities:
- competition
- user
- submission

will need to:
pull all submissions by competition
pull all users by competition
pull all competitions by user
pull all submissions by user


1. is this a case of has_many :through like so?

class Competition < ActiveRecord::Base
  has_many :submissions
  has_many :users, :through => :submission
end

class Submission < ActiveRecord::Base
  belongs_to :competition
  belongs_to :submission
end

class User < ActiveRecord::Base
  has_many :submissions
  has_many :competitions, :through => :submissions
end


2. do i create joining tables and define FKs by updating migration
script manually?  if there are materials on step instructions you can
point me to, that will be great too!

3. if i need to add polymorphic behaviors(e.g. commentable and
rateable) to each of these models, do i just pile up the association
definitions?  after adding on media and various type/category models,
this probably will get pretty long and not sure whether cache/memory/
performance situation will become unmanageable.  An example of
relatively complex association definition will give me a good idea.

thx for reading.

-ji

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



[Rails] acts_as_textiled missing something, possibly config?

2009-02-09 Thread mfabache

I've got acts_as_textiled working on my Mac,no problems.
Same install process on RedHat FC8, is acting weird.

For example:

1.) Already inplace HTML tags are not translated.  An  appears as
.  However any new 'h1.' works fine
2.) putting in href substitues get blownout into some weird
representation.  a "Listings" which I want to get
translated as "Listings":/lists actually gets translated to
"
"Listings":/lists

Have I missed something, somewheres?
RedCloth is 3.0.4 and 4.1.1, acts_as_textiled I got from github (git
clone...)

I've also tried various browsers (lynx, opera, firefox, etc.), same
result.

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



[Rails] Fixtures load inconsistently

2009-02-09 Thread Foliosus

Hi all,

I've got a weird problem with loading fixtures, and I'm hoping someone
out there can help.  I'm having problems running my tests, because for
one of my models the fixtures are loading strangely.  Here's an
example fixture:

john_doe:
  status: student
  department:
  alumni:
  title:
  applicant:
  student_status:
  staff:
  pref_first_name:
  faculty:
  applicant_status:
  year_in_school: freshman
  chair:
  pidm: 12345678
  reed_id: L12345
  program:
  middle_initial:
  first_name: John
  student: Y
  login: doej
  last_name: Doe
  email: d...@reed.edu

This is a model that's wrapping a legacy table.  It has no id column.
However, its pidm column is the primary key, so in my model I've got:

  set_primary_key :pidm
  alias_attribute :id, :pidm

If I load up my fixtures using "rake:fixtures:load RAILS_ENV=test"
then everything works just fine.  My 5 fixtures for this model go in
to the test db exactly as written.  However, when I run my test suite,
and rails loads the fixtures, 3 of the 5 fixtures load up with their
pidm field set to 91.

It's surprising because it's only 3 of the 5. I've been poking at it
all morning, with no luck. I've changed data values, etc., and it's
always the same 3 that come out with 91.  The other 2 fixtures have
the pidm that's set in the fixture's yaml file.

Has anybody encountered this? Or does anybody have suggestions?

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] Help with Scaffolding deprecation on Rails 2.2.2

2009-02-09 Thread untz

I am reading “Agile Web Development with Rails, 2nd Edition”, which is
based on 1.2.6. However, on my Leopard based iMac, I was running Rails
2.2.2.

When I got to the part with associating a scaffold to my :products
(located on the bottom of page 67), it outputted a No Scaffold method
error (because scaffolds are not included in 2.2.2).

After searching some web sites, particularly , I tried to install 1.2.6 by issuing: gem
install rails—version 1.2.6—include-dependencies.

This worked correctly, but when I still type check the current version
from bash it states:

Rails 2.2.2

I then went into my app’s config/environment.rb file and set
RAILS_GEM_VERSION to 1.2.6.

When I tried to re-start the WEBrick server, I got the following
error:

=> Booting WEBrick…
./script/../config/../config/environment.rb:46: undefined method
`time_zone=’ for # (NoMethodError)
from /Users/untz/.gem/ruby/1.8/gems/rails-1.2.6/lib/initializer.rb:
45:in `run’ from ./script/../config/../config/environment.rb:13

On line 46, on my WEBrick server, this is what is set:

config.time_zone = ‘UTC’

Question(s):

(1) Should I stick with learning Rails 2.2.2 and upgrade to Ruby 1.9?

(2) Is the 2nd Edition of this book now deprecated or is there a
workaround to my problem?

(3) Any good resources on learning the new version of Rails?

Happy programming!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: can't call request.remote_ip from object?

2009-02-09 Thread Foliosus

Models should be blissfully unaware that they are attached to a web
app.  For example, if you use your models from the console, or a rake
task, there is no web app, so if your models assume that a controller
exists you're asking for trouble.

In this case, however, you can simply feed the :last_known_up
and :last_known_user_agent to your model this way:

class UserController
  def some_action
@user = User.find(params[:id])
@user.update_metadata(:last_known_up =>
request.remote_ip, :last_known_user_agent => request.user_agent)
  end
end

class User
  def update_metadata(options = {})
options.reverse_merge!(:last_login_at => Time.now)
self.update_attributes(options)
  end
end

Brent

On Feb 9, 11:34 am, Taylor Strait 
wrote:
> class User
>
>   def update_metadata
>     self.update_attributes({:last_login_at => Time.now,
>                             :last_known_up => request.remote_ip,
>                             :last_known_user_agent =>
> request.user_agent})
>   end
>
> This does not work. It bombs out with:
>
> undefined local variable or method `request' for #
>
> But the request calls work in a controller such as:
>
> @ip = request.remote_ip
> @agent = request.user_agent
>
> What is the proper way to get this data into my model?
> --
> 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: File upload time-out?

2009-02-09 Thread mkoga

checkout http://wiki.codemongers.com/NginxHttpCoreModule#client_max_body_size

Richard wrote:
> I have an app that uploads large mp3 files (teaching), of around 30
> megs or so. I am running my app on a mongrel cluster behind nginx. The
> file uplaods seem to hang.
>
> Is there a max execution time setting in rails, mongrel or nginx that
> is causing this?
>
> Thanks
>
> Richard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Option on select form helper to customize "Select" text?

2009-02-09 Thread Frederick Cheung



On Feb 9, 8:06 pm, Wes Gamble 
wrote:
> All,
>
> Is there any built-in way in the "select" form helper to display
> something other than "Select" in the :include_blank option?
> Specifically, for a date helper, would like to show "Month", "Day",
> "Year" respectively for those options in 3 selects.
>
If the :include_blank option is a string then that is used for the
blank option. There's also the :prompt option. I do recall that
support of this with the date_select stuff was only added recently.

Fred
> Thanks,
> Wes
> --
> 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: dynamic constant assignment

2009-02-09 Thread Erwin

I also tried :

  AVAILABLE_LOCALES = ALL_LOCALES.dup
 AVAILABLE_LOCALES.delete_if{|key, value| key == I18n.locale }

but get also an error ... dynamic constant assignment (SyntaxError)
with the dup ...
I don't understand as I can do it with irb 


On 9 fév, 23:06, Erwin  wrote:
> I have a constant set up like that :
> ALL_LOCALES
> => {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
> GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
> "pl"=>"Polski", "en-US"=>"English (US)", "pt-BR"=>"Português
> (Brasil)"}
>
> my locale is set :  I18n.locale
> => :"en-US"
>
> based on the current locale , dynamically changed, I would like to
> define a new constant,   AVAILABLE_LOCALES which would be the
> ALL_LOCALES minus the current locale...
>
> AVAILABLE_LOCALES
> => {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
> GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
> "pl"=>"Polski", "pt-BR"=>"Português (Brasil)"}
>
> I dont' see how todo that ?  any clue ?
>
> thanks a lot fyh
> erwin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Option on select form helper to customize "Select" text?

2009-02-09 Thread Wes Gamble

Rick,

Thanks, but not what I'm looking for.

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

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



[Rails] Re: Fixtures loading *very* strangely

2009-02-09 Thread Brent Miller

I've tried that; there are lots of things out there that assume the 
primary key is called "id" -- this simple fix makes all of them work.

Even if I remove it, though, I still get the same weird loading 
behavior. :(

Rob Biedenharn wrote:
> On Feb 9, 2009, at 4:47 PM, Brent Miller wrote:
> 
>>  set_primary_key 'pidm'
>>  alias_attribute :id, :pidm
>> end
> 
> I'm not sure if it changes your situation, but you shouldn't need that
> alias_attribute.  Just use id and ActiveRecord should use your real
> primary key column under the covers.
> 
> -Rob

-- 
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: Fixtures loading *very* strangely

2009-02-09 Thread Rob Biedenharn

On Feb 9, 2009, at 4:47 PM, Brent Miller wrote:

>
> Hi all,
>
> I've just hit a snag, and I'm hoping somebody out there can help.
>
> I'm working on an app that uses some legacy tables.  One of them  
> doesn't
> have a column named "id" so I've got the following:
>
> class Student
>  set_primary_key 'pidm'
>  alias_attribute :id, :pidm
> end

I'm not sure if it changes your situation, but you shouldn't need that  
alias_attribute.  Just use id and ActiveRecord should use your real  
primary key column under the covers.

-Rob

>
>
> When I'm testing, I need 5 student fixtures.  I have them defined like
> this one:
>
> john_doe:
>  status: student
>  department:
>  alumni:
>  title:
>  applicant:
>  student_status:
>  staff:
>  pref_first_name:
>  faculty:
>  applicant_status:
>  year_in_school: freshman
>  chair:
>  pidm: 12345678
>  reed_id: L12345
>  program:
>  middle_initial:
>  first_name: John
>  student: Y
>  login: doej
>  last_name: Doe
>  email: d...@reed.edu
>
> When I load the fixtures into my test database with "rake
> db:fixtures:load RAILS_ENV=test" everything works great.  However,  
> when
> I run my test suite, and rails loads the fixtures, I get a big  
> problem:
> three of the fixtures aren't loading with their pidm (id) correctly.
> All three load with a pidm of 91, which is problematic since it breaks
> any associations involving that primary key.
>
> The two other fixtures load ok, though, which makes me very confused.
>
> I've played around with the data differences between the fixtures, and
> futzing the non-pidm data doesn't seem to do anything.
>
> Has anybody encountered this?  Any advice?
>
> 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] threading, returning from action method, blocking

2009-02-09 Thread Jonathan Rochkind

So, in a Rails 2.1 app, I'm doing a bit of threading. Even though this
isn't exactly recommended, it seemed to work (taking care to use
ActiveRecord in a thread-safe manner, or not at all in threads).

But I've noticed something odd.

The main thing I do with a thread, is in an action method (ie, an action
in a controller), right before returning from the method, I start a
thread to do some finishing up clean-up in the background. Since this
cleanup is potentially a lengthy process, the idea is that this won't
prevent the response from returning to the browser.

def someAction
  # some stuff

  Thread.new do
#background(?) stuff
  end

  return
end

The expectation was that the response would be returned to the browser
immediately, it would not wait for that Thread to execute. It wouldn't
matter how long the code in "#background(?) stuff" took to run, the
Thread would be started, and then the next statement would be read after
the thread, ending the action method, proceeding with the view, without
waiting on the Thread. Everything could be asynchronous.

However, I've recently noticed that this doesn't seem to be the case.
The stuff in the Thread _is_ keeping the response from being returned.
If I put a "sleep(10)" at the top of the Thread do body, then everything
clears up--it doesn't wait an extra 10 seconds for teh response, THEN
the response is returned immediately. But without this, it seems that
something in the Thread is blocking the rest of the Rails process to
return the response, not for the entire time it takes it to run, but...
for some time.

Does anyone have any ideas what's going on, or how else to accomplish
this? (Please don't same BackgrounDRB).

Thanks,

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

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



[Rails] Re: favored development environment

2009-02-09 Thread Ar Chron

Have you considered a Linux VM?

I have XP as the main OS because it the corporate way (e-mail, office, 
etc), but all the Rails work in done with Ubuntu 8.04 LTS running under 
VMWare - Eclipse Ganymede works fine as my Rails editor. Now if I could 
just get it to understand HAML, I'd be all set.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Help with routes and params

2009-02-09 Thread Freddy Andersen

I think you have to have a look at Rails basics. A basic forum would
be something like:

forums has_many categories
categories has_many topics
topics has_many replies

then you have has_many routes like /forums/1/categories/1/topic and in
your routes.rb you would do

map.resources :forums do |forum|
  forum.resources :categories do |cat|
cat.resources :topics
  end
end

You could add :has_many => :topics but if you need members and/or
collections later its better this way.


On Feb 9, 1:26 pm, John Yerhot  wrote:
> Hi John,
>
> I highly suggest you take a peek as the associations that Rails
> provides.  A good place to start is the Rails 
> Guides.http://guides.rubyonrails.org/association_basics.html
> and also the guide on routes (particularly the part on nested
> resources)http://guides.rubyonrails.org/routing_outside_in.html
> These will make life much easier for you if you follow them.
>
> Sorry for not really answering your question... :)
>
> Again, I would go this route though.  :)
> On Feb 9, 12:46 pm, John Smith 
> wrote:
>
> > I need some help with routes and params. I am developming some forums
> > for a web. I want to be able to create new replies once a post has been
> > created. So I create a post and then I have to put a link named "Reply".
> > What I want to do is Reply.create, and pass post_id as a param to this
> > Reply.create action. How can I make this link? How can I get this param
> > in replies controller?
> > I  think I can create a whole new action, but I would like to use
> > Reply.create.
> > --
> > 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: mysql install problem

2009-02-09 Thread Chad

You're trying to update the rails framework, not ruby.

http://www.ruby-lang.org/en/downloads/



On Feb 9, 6:56 am, Eduardo Cirilo 
wrote:
> MaD wrote:
> > your post says:
> >   'You're running:  ruby 1.8.4'
>
> > while on ror.org is written:
> >   'We recommend Ruby 1.8.7 for use with Rails.'
>
> > 1.8.4 should work, too. but to make sure it ain't a version-conflict,
> > i'd update.
>
> > other than that, did you follow this hint?:
> >   'OS X 10.5: Included with developer tools (then do "gem update
> > rails")'
>
> Hi MaD,
>
> When I try to update it appens this:
>
> MBPEduCirilo:kshema098 eduardocirilo$ gem update rails
> Updating installed gems
> Nothing to update
>
> How can I update to Ruby 1.8.7? Is there another way?
>
> Regards,
> Ed
> --
> 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] Pretty Record Lists

2009-02-09 Thread Chad


Can anyone recommend a lightweight plugin that renders lists of
records nicely with ajax sort, pagination, edit/delete links, etc?  I
tried ActiveScaffold, which is really great, but it's too much for
what I'm trying to accomplish.

Ideally it would be used sorta like this (similar to AS):

controller:
@users = company.users

view:
<%= render :pretty_lists => @users %>

--
Thanks for any help,
Chad

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Option on select form helper to customize "Select" text?

2009-02-09 Thread Rick

Try this:

script/generate scaffold Thing name:string when:datetime text:body

You'll see:

In migration:

create_table :things do |t|
  t.string :name
  t.datetime :when
  t.text :body
end

In view:

New thing

<% form_for(@thing) do |f| %>
  <%= f.error_messages %>
.
.
  
<%= f.label :when %>
<%= f.datetime_select :when %>
  

start your server and check out: localhost:3000/things/new

On Feb 9, 10:06 am, Wes Gamble 
wrote:
> All,
>
> Is there any built-in way in the "select" form helper to display
> something other than "Select" in the :include_blank option?
> Specifically, for a date helper, would like to show "Month", "Day",
> "Year" respectively for those options in 3 selects.
>
> Thanks,
> Wes
> --
> 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: mysql install problem

2009-02-09 Thread Brent Miller

If you're on an Intel mac, try this:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- 
--with-mysql-dir=/usr/local/mysql
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql

Just be sure to get the mysql directories right to match your system 
setup.  These are the default for the MySQL binaries.

Brent

Eduardo Cirilo wrote:
> Manisha Tripathy wrote:
>> Have you installed mysql-client?
> 
> 
> 
> Yes I have...

-- 
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] dynamic constant assignment

2009-02-09 Thread Erwin

I have a constant set up like that :
ALL_LOCALES
=> {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
"pl"=>"Polski", "en-US"=>"English (US)", "pt-BR"=>"Português
(Brasil)"}

my locale is set :  I18n.locale
=> :"en-US"

based on the current locale , dynamically changed, I would like to
define a new constant,   AVAILABLE_LOCALES which would be the
ALL_LOCALES minus the current locale...

AVAILABLE_LOCALES
=> {"it"=>"Italian", "fr"=>"Français", "de"=>"Deutsch", "en-
GB"=>"English (UK)", "es"=>"Español (España)", "pt-PT"=>"Português",
"pl"=>"Polski", "pt-BR"=>"Português (Brasil)"}

I dont' see how todo that ?  any clue ?

thanks a lot fyh
erwin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: can't call request.remote_ip from object?

2009-02-09 Thread Brent Miller

Here's the sort of thing you're looking for:

class UserController
  def some_action
@user = User.find(params[:id])
@user.update_metadata(:last_known_ip => request.remote_ip,
  :last_known_user_agent => request.user_agent)
  end
end

class User
  def update_metadata(options = {})
options.reverse_merge!(:last_login_at => Time.now)
self.update_attributes(options)
  end
end

This will update the request data only if you're coming from a 
controller, where there is request data.

Brent

Taylor Strait wrote:
> class User
> 
>   def update_metadata
> self.update_attributes({:last_login_at => Time.now,
> :last_known_up => request.remote_ip,
> :last_known_user_agent =>
> request.user_agent})
>   end
> 
> This does not work. It bombs out with:
> 
> undefined local variable or method `request' for #
> 
> But the request calls work in a controller such as:
> 
> @ip = request.remote_ip
> @agent = request.user_agent
> 
> What is the proper way to get this data into my model?

-- 
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] dbd-odbc gem not

2009-02-09 Thread Ben Lieber

I have an application that requires dbd-odbc gem in order to work. So I
have to following in the environment.rb:

---
config.gem 'dbd-odbc', :version => '0.2.4', :lib => 'dbd/ODBC'
---

I recently had to switch to a new computer, so new install of ubuntu,
rails, gems, etc. I installed dbd-odbc as you can see:

---
$ gem list
...
dbd-odbc (0.2.4)
...
---

my app keeps failing though, and if I run a rake, it tries to reinstall
the same gem each time, but then the app still doesn't see it:

---
$ sudo rake gems:install
[trace ...]
no such file to load -- dbd-odbc
[trace ...]
gem install dbd-odbc --version "= 0.2.4"
Successfully installed dbd-odbc-0.2.4
1 gem installed
Installing ri documentation for dbd-odbc-0.2.4...
Installing RDoc documentation for dbd-odbc-0.2.4...
--

Has anyone seen this behavior before?

Thanks for any help!

-Ben
-- 
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: AR:BASE.default_timezone

2009-02-09 Thread Brent Miller

What you really want to do is mock the default_timezone for the scope of 
a particular test.  For example,

require 'mocha'

class MagikTest < ActiveSupport::TestCase
  def test_something
tz = 'Alaska'
ActiveRecord::Base.stubs(:default_timezone).returns(tz)
assert_equal tz, ActiveRecord::Base.default_timezone
  end
end

This just shows you how the stubbing works; in practice, this test is 
testing the Mocha library, and not your app. :)  The trick here is to 
decide what you want the default_timezone call to return, and assign 
that value to tz.  Then every time you call AR::Base.default_timezone 
during that test, you'll get back the value of tz.

You'll need to grab the mocha library first: gem install mocha

You can use this to test your app against multiple timezones to really 
make sure it works.

Brent

James Byrne wrote:
> I have a requirement to test code whose execution depends upon the
> default_timezone setting.  I have tried several approaches to this but
> nothing that I do in my test seems to alter the behaviour that is set in
> environment.rb.
> 
> Is there a way to dynamically alter AR's method of storing datetime
> during a test? Currently I attempt to do this in this fashion:
> 
> [ "local", "utc" ].each do |tz|
>   ActiveRecord::Base.default_timezone = tz
>   @my_mage = Magik.new
>   @my_mage.description = tz
>   @my_mage.my_time_local = DateTime.now
>   @my_mage.my_time_utc = DateTime.now.utc
>   @my_mage.save!
>   puts @my_mage.description
> end
> 
> but the contents of the my_time_local and my_time_utc do not seem to be
> what I expect:
> 
> default_timezone = local
> Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
>   now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77585 <- Time.now
>   UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
>   now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.77609 <- Time.now.utc
> 
> default_timezone = utc
> Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
>   now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77807 <- Time.now
>   UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
>   now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.7783 <- Time.now.utc
> .
> 
> Is it possible to override AR default_timezone values for testing?

-- 
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] Fixtures loading *very* strangely

2009-02-09 Thread Brent Miller

Hi all,

I've just hit a snag, and I'm hoping somebody out there can help.

I'm working on an app that uses some legacy tables.  One of them doesn't
have a column named "id" so I've got the following:

class Student
  set_primary_key 'pidm'
  alias_attribute :id, :pidm
end

When I'm testing, I need 5 student fixtures.  I have them defined like
this one:

john_doe:
  status: student
  department:
  alumni:
  title:
  applicant:
  student_status:
  staff:
  pref_first_name:
  faculty:
  applicant_status:
  year_in_school: freshman
  chair:
  pidm: 12345678
  reed_id: L12345
  program:
  middle_initial:
  first_name: John
  student: Y
  login: doej
  last_name: Doe
  email: d...@reed.edu

When I load the fixtures into my test database with "rake
db:fixtures:load RAILS_ENV=test" everything works great.  However, when
I run my test suite, and rails loads the fixtures, I get a big problem:
three of the fixtures aren't loading with their pidm (id) correctly.
All three load with a pidm of 91, which is problematic since it breaks
any associations involving that primary key.

The two other fixtures load ok, though, which makes me very confused.

I've played around with the data differences between the fixtures, and
futzing the non-pidm data doesn't seem to do anything.

Has anybody encountered this?  Any advice?

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: There is already an object named 'schema_migrations' in the

2009-02-09 Thread Ben Lieber

Looks like there was another post with a similar issue, just figured I'd 
cross-reference in case someone actually does still want to use the 
activerecord-odbc-adapter.

-- 
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 SQL Server 2008 and migrations using activerecord-odbc-adapter gem

2009-02-09 Thread Ben Lieber

Huh, good post, I was having the same issue approx the same time 
(http://www.ruby-forum.com/topic/176528#773255), wish I had found your 
post then.

I'm on a SqlServer 2005 db, but it was the same exact issue. Ended up 
switching to the rails-sqlserver-2000-2005-adapter and most problems 
went away. But good to know the actual cause of the original issue.

Thanks!

-Ben


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

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



[Rails] Re: Help with routes and params

2009-02-09 Thread John Yerhot

Hi John,

I highly suggest you take a peek as the associations that Rails
provides.  A good place to start is the Rails Guides.
http://guides.rubyonrails.org/association_basics.html
and also the guide on routes (particularly the part on nested
resources)
http://guides.rubyonrails.org/routing_outside_in.html
These will make life much easier for you if you follow them.

Sorry for not really answering your question... :)


Again, I would go this route though.  :)
On Feb 9, 12:46 pm, John Smith 
wrote:
> I need some help with routes and params. I am developming some forums
> for a web. I want to be able to create new replies once a post has been
> created. So I create a post and then I have to put a link named "Reply".
> What I want to do is Reply.create, and pass post_id as a param to this
> Reply.create action. How can I make this link? How can I get this param
> in replies controller?
> I  think I can create a whole new action, but I would like to use
> Reply.create.
> --
> 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: Run rake tasks from the controller

2009-02-09 Thread elioncho

Great, great stuff, thanks a lot guys! I was thinking about using the
ftools, but doubt overcame me. I'm never too sure which approach I
must take. Thanks again for your input.

On Feb 9, 4:12 pm, "K. R."  wrote:
> But why do you not use the 'ftools' of ruby? so you can forgot the rake
> task.
>
> Create a folder:
> FileUtils.mkdir_p 'name'
>
> Destroy a folder:
> FileUtils.rm_rf(path)
>
> With after_save you can call the method who use .mkdir and with
> after_destroy .rm_rf...
>
> for example:
> after_save :create_folder
> after_destroy :destroy_folder
>
> private
> def create_folder
>   FileUtils.mkdir_p 'name'
> end
>
> def destroy_folder
>   FileUtils.rm_rf(path)
> end
>
> Elias Orozco wrote:
> > Maybe is good to explain what I am trying to do a little more. I want
> > to create a directory (folder) for a particular user when he/she
> > creates an account in my website. That will be the folder were all the
> > things he/she uploads will be stored. So I want to run a rake task
> > that will create the user folder once he registers. So the idea is to
> > have a rake task on an observer and pass the user business name that
> > will be used to name the folder.
>
> > I hope I explained myself.
>
> > 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: Run rake tasks from the controller

2009-02-09 Thread K. R.

But why do you not use the 'ftools' of ruby? so you can forgot the rake 
task.

Create a folder:
FileUtils.mkdir_p 'name'

Destroy a folder:
FileUtils.rm_rf(path)


With after_save you can call the method who use .mkdir and with 
after_destroy .rm_rf...

for example:
after_save :create_folder
after_destroy :destroy_folder

private
def create_folder
  FileUtils.mkdir_p 'name'
end

def destroy_folder
  FileUtils.rm_rf(path)
end






Elias Orozco wrote:
> Maybe is good to explain what I am trying to do a little more. I want
> to create a directory (folder) for a particular user when he/she
> creates an account in my website. That will be the folder were all the
> things he/she uploads will be stored. So I want to run a rake task
> that will create the user folder once he registers. So the idea is to
> have a rake task on an observer and pass the user business name that
> will be used to name the folder.
> 
> I hope I explained myself.
> 
> 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: Rails Colo in Pacific Northwest?

2009-02-09 Thread william.hard...@gmail.com

Sorry, Pacific Northwest of the USA.  Anyone had experience with
anywhere besides P.A.?

On Feb 6, 9:52 pm, "s.ross"  wrote:
> If it's thePacificNorthwest of USA, try Planet Argon, in Portland.
>
> http://planetargon.com/
>
> On Feb 6, 2009, at 7:54 PM, Julian Leviston wrote:
>
>
>
> >Pacificnorthwest of where? I'm on Australia.
>
> > Blog:http://random8.zenunit.com/
> > Learn rails:http://sensei.zenunit.com/
>
> > On 07/02/2009, at 12:22 PM, "william.hard...@gmail.com" 
> >  >> wrote:
>
> >> Does anyone have any experience with or knowledge of a Rails-savvy
> >> colocation facility in the vicinity of thePacificNorthwest?
>
> >> Thanks!
> >> 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] Re: rendering original view

2009-02-09 Thread K. R.

Why do you really want to render the show method of schools_controller? 
Do you not render the new-action of the schools_controller? the bad form 
was send from the new action of the schools controller isn't it?

format.html { render :action => "new", :controller => 'schools' }




bingo bob wrote:
>   def create
> 
> # next statement is original and is removed
> # @review = Review.new(params[:review])
> 
> @school = School.find(params[:school_id])
> # @review = @school.reviews.create!(params[:review])
> @review = @school.reviews.build(params[:review])
> 
> 
> respond_to do |format|
>   if @review.save
> 
> flash[:notice] = 'Review was successfully created.'
> # format.html { redirect_to(@review) }
> format.html { redirect_to(@school) }
> format.xml  { render :xml => @review, :status => :created,
> :location => @review }
>   else
> # format.html { render :action => "new" }
> format.html { render :action => "new" }  #  <- HERE
> format.xml  { render :xml => @review.errors, :status =>
> :unprocessable_entity }
>   end
> end
>   end
> 
> 
> In this view the line
> 
> format.html { render :action => "new" }
> 
> renders the reviews new method when the validation fails...thing is I
> want to show the school and the error messages, (schools controller show
> method) like this line,  format.html { redirect_to(@school) }.
> 
> any help on how to do this?

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

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



[Rails] Re: Run rake tasks from the controller

2009-02-09 Thread elioncho

Maybe is good to explain what I am trying to do a little more. I want
to create a directory (folder) for a particular user when he/she
creates an account in my website. That will be the folder were all the
things he/she uploads will be stored. So I want to run a rake task
that will create the user folder once he registers. So the idea is to
have a rake task on an observer and pass the user business name that
will be used to name the folder.

I hope I explained myself.

Thanks

On Feb 9, 3:56 pm, elioncho  wrote:
> Good,
>
> But how can I call a rake task from the model, and send some extra
> params to it?
>
> Thanks,
>
> Elías
>
> On Feb 9, 3:53 pm, "K. R."  wrote:
>
> > Why do you run rake tasks in the controller? controllers are not really
> > good to execute rake tasks. move it into the model and call it from the
> > controller.
>
> > Elias Orozco wrote:
> > > Hello,
>
> > > How can I run rake tasks from the controller and send extra params to
> > > it too? Thanks,
>
> > > El as
>
> > --
> > 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: Best Way to detect if you are in a migration?

2009-02-09 Thread Harold

I recently posted a similar question. No answer...

http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/5d38a62129fa63e4/a78671aa145bf278?hl=en#a78671aa145bf278

On Feb 9, 3:11 pm, Frantisek Psotka 
wrote:
> I im interested in this question, has somebody the answer?
> --
> 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: Run rake tasks from the controller

2009-02-09 Thread K. R.

For example with BJ, so the webserver is no permanently in use...

- Bj.submit "cmd.exe /c rake kipf:convert_movie id=#{id}" in windows
- Bj.submit "system rake kipf:convert_movie id=#{id}" in linux (not 
sure)



Elias Orozco wrote:
> Good,
> 
> But how can I call a rake task from the model, and send some extra
> params to it?
> 
> Thanks,
> 
> El�as

-- 
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: can't call request.remote_ip from object?

2009-02-09 Thread K. R.

request are only readable in the controller. Take the ip address in the 
controller and move it as a parameter into the model.

ip = request.remote_ip
@model.ip = ip

or put it into a hash (with all other parameters) and call the method in 
the model.


Taylor Strait wrote:
> class User
> 
>   def update_metadata
> self.update_attributes({:last_login_at => Time.now,
> :last_known_up => request.remote_ip,
> :last_known_user_agent =>
> request.user_agent})
>   end
> 
> This does not work. It bombs out with:
> 
> undefined local variable or method `request' for #
> 
> But the request calls work in a controller such as:
> 
> @ip = request.remote_ip
> @agent = request.user_agent
> 
> What is the proper way to get this data into my model?

-- 
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: textile, markdown suggestions

2009-02-09 Thread Galen King

I've put up a little survey to see what people prefer. Check it out
and let us know your thoughts: 
http://luciddesign.co.nz/2009/2/9/textile-vs-markdown-vs-tinymce-etc

On Jan 25, 5:46 am, Fernando Perez 
wrote:
> > I prefer Markdown since the markup doesn't interfere much with the
> > readability as text.
>
> Is it possible with Markdown to create something like: Our
> Team
>
> I couldn't find any info about that. I use rdiscount to parse the plain
> text to html.
> --
> 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: Run rake tasks from the controller

2009-02-09 Thread elioncho

Good,

But how can I call a rake task from the model, and send some extra
params to it?

Thanks,

Elías

On Feb 9, 3:53 pm, "K. R."  wrote:
> Why do you run rake tasks in the controller? controllers are not really
> good to execute rake tasks. move it into the model and call it from the
> controller.
>
> Elias Orozco wrote:
> > Hello,
>
> > How can I run rake tasks from the controller and send extra params to
> > it too? Thanks,
>
> > El as
>
> --
> 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: Run rake tasks from the controller

2009-02-09 Thread K. R.

Why do you run rake tasks in the controller? controllers are not really 
good to execute rake tasks. move it into the model and call it from the 
controller.




Elias Orozco wrote:
> Hello,
> 
> How can I run rake tasks from the controller and send extra params to
> it too? Thanks,
> 
> El�as

-- 
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] Run rake tasks from the controller

2009-02-09 Thread elioncho

Hello,

How can I run rake tasks from the controller and send extra params to
it too? Thanks,

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



[Rails] Image rotator plugin

2009-02-09 Thread Shockmeister

Hi all,

Has anyone used farooq ali's rails plugin for media applications? (see
link below)

http://www.jroller.com/abstractScope/entry/flash_mp3_imageslideshow_media_player

I am trying to create a simple slideshow on my site and I am using
farooq's plugin for image rotator (http://www.longtailvideo.com/). I
have created an xspf playlist file to run through the images. When I
open the browser, however, the images are not displaying. I have never
written an xspf file before so I'm not sure what I'm doing wrong. Can
someone take a look at my xspf file to see if is correct? At least
then I'll know that the problem lies elsewhere.


http://xspf.org/ns/0/";>

http://localhost:3000/images/image_1.JPG
http://localhost:3000/images/image_2.JPG
http://localhost:3000/images/image_3.JPG
http://localhost:3000/images/image_4.JPG




Many 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] Specifying session_id in params?

2009-02-09 Thread Brian Culler

I am using a Flex based front end on top of a rails backend.  When the
SWF is first loaded from the rails app to the client's browser, a
session is created on the rails side.

However, subsequent requests from the loaded Flex app are also creating
whole new sessions as well.  I need the flex app's calls to continue
using the existing session.

So I am sending the flexapp the original session id, and am then
appending that session id into the params when it sends it back.  Is
there anything else you need to do besides inserting the specific
session id into the request params to get rails to use that session id
instead of making a new one?  If it makes a difference, this is a
multipart post from the flex app back to the rails server.

Here is an example sequence of events -- the first request is what
serves the SWF to the client's browser:

Processing MainController#index (for 127.0.0.1 at 2009-02-09 15:31:44)
[GET]
  Session ID: ff99a1a31c21bcd247390e8c54b65dc9

Next, I am doing a callback from within the flex SWF as a multipart post
request, with the "_session_id" parameter specified:

Processing ApiController#upload (for 127.0.0.1 at 2009-02-09 15:32:05)
[POST]
  Session ID: c104c28b75d712f3dd81f59dd39d963d
  Parameters: {"Filename"=>"att2.jpg",
"_session_id"=>"ff99a1a31c21bcd247390e8c54b65dc9", "action"=>"upload",
"Upload"=>"Submit Query", "controller"=>"api", "fb_sig_user"=>"null",
"Filedata"=>#}

As you can see, the "_session_id" parameter in the 2nd request matches
the first requests Session ID.  However, the 2nd request clearly is
getting a different session.

Any ideas?
-- 
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] flickraw: flickr.tags.getListUserRaw

2009-02-09 Thread ha we

Hi!

I need to call the flickr.tags.getListUserRaw API method
(http://www.flickr.com/services/api/flickr.tags.getListUserRaw.html)
with the flickraw gem.

Unfortunately there is no documentation how to authenticate and then
call the method. Just calling flickr.tags.getListUserRaw doesn't work,
although flickr.tags.getListUser does work.

I set my FlickRaw.api_key and FlickRaw.shared_secret ... how do I go
about now?

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] ferret - mysql server has gone away

2009-02-09 Thread K. R.

I've problem with ferret (acts_as_ferret). search-engine and webserver
are on the same machine. I use acts_as_ferret :field => ... to define
which columns are indexed. I recreate the index with
Search.rebuild_index (Search is my model).

To find some results, I use Search.find_with_ferret("keyword", {}, {}).
Sometimes, I merge conditions to this query in the last hash. I create
an index over 7'000 records.

For a while, the search is run correctly. Suddently, after perhaps 10
requests, I receive the error message below and the search doesn't run
anymore.

Has someone a solution for this problem Thanks for helping!


ActiveRecord::StatementInvalid: Mysql::Error: MySQL server has gone
away: SELECT * FROM `searches` WHERE (searches.id in
('266582','261710','261788','266607','262659','258206','261781','258207','261783','262124'))
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract_adapter.rb:147:in
`log'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:299:in
`execute'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/mysql_adapter.rb:515:in
`select'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in
`select_all_without_query_cache'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/connection_adapters/abstract/query_cache.rb:61:in
`select_all'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:582:in
`find_by_sql'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1341:in
`find_every'
  from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:536:in
`find'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:384:in
`retrieve_records'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:360:in
`each'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:360:in
`retrieve_records'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:300:in
`ar_find_by_contents'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:288:in
`find_records_lazy_or_not'
  from
/home/schwinge/ruby/gems/gems/acts_as_ferret-0.4.3/lib/class_methods.rb:185:in
`find_with_ferret'
  from (irb):19
-- 
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: Best Way to detect if you are in a migration?

2009-02-09 Thread Frantisek Psotka

I im interested in this question, has somebody the answer?
-- 
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] Option on select form helper to customize "Select" text?

2009-02-09 Thread Wes Gamble

All,

Is there any built-in way in the "select" form helper to display
something other than "Select" in the :include_blank option?
Specifically, for a date helper, would like to show "Month", "Day",
"Year" respectively for those options in 3 selects.

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

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



[Rails] Re: Diff tool in Ruby with HTML output

2009-02-09 Thread Maurício Linhares

I was looking for something that could turn the diff output into nice
HTML, but thanks anyway.

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



On Mon, Feb 9, 2009 at 3:37 PM, Jeff Lewis  wrote:
>
> $ irb
>>> `echo "testing 123\ntesting" > ./file1.txt`
> => ""
>>> `echo "testing 123\nhey, something new\ntesting" > ./file2.txt`
> => ""
>>> puts "\n#{`diff -cws file1.txt 
>>> file2.txt`}\n"
> 
> *** file1.txt   2009-02-09 10:25:44.0 -0800
> --- file2.txt   2009-02-09 10:28:31.0 -0800
> ***
> *** 1,2 
> --- 1,3 
>  testing 123
> + hey, something new
>  testing
>
> 
> => nil
>>>
>
> Jeff
>
> On Feb 8, 12:08 pm, Maurício Linhares 
> wrote:
>> Hello,
>>
>> Anyone knows of any tool that can generate a diff between two files
>> and output HTML code that i could use in a page?
>>
>> Doesn't need to be a Ruby tool, any Unix compatible tool would do the
>> trick, I just need it to output HTML.
>>
>> -
>> Maurício Linhareshttp://alinhavado.wordpress.com/(pt-br) 
>> |http://blog.codevader.com/(en)
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: [ANN] The end of Capchas: Thorny Form plugin

2009-02-09 Thread Petite Abeille


On Feb 9, 2009, at 8:43 PM, Wybo Wiersma wrote:

> It is not an unbreakable solution, but it is likely to continue to
> work for quite some time. The following joke from Ned Batchelders blog
> nicely sketches why:

For what's worth, Nanoki, a wiki engine implemented in Lua, uses Ned  
Batchelders tricks to keep itself spam free.

For an illustration, check the source of the various form:

http://svr225.stepx.com:3388/main/editor
http://svr225.stepx.com:3388/cloud/editor

Cheers,

--
PA.
http://alt.textdrive.com/nanoki/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: [ANN] The end of Capchas: Thorny Form plugin

2009-02-09 Thread Petite Abeille


On Feb 9, 2009, at 8:43 PM, Wybo Wiersma wrote:

> The following joke from Ned Batchelders blog
> nicely sketches why:

Perhaps worthwhile pointing out the URL as well:

"Stopping spambots with hashes and honeypots"
-- Ned Batchelder, January 2007
http://nedbatchelder.com/text/stopbots.html

--
PA.
http://alt.textdrive.com/nanoki/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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] The end of Capchas: Thorny Form plugin

2009-02-09 Thread Wybo Wiersma

Thorny Form is a Rails plugin for unobtrusively protecting forms
against form-SPAM.

It adds extra fields like a honeypot and some others which can then be
checked before the form-data is used in your application. 

To use Thorny Form you just need to change two lines per form. First
in the view 
  form_for has to be replaced by thorny_form_for
  (remote_form_for by remote_thorny_form_for). 
  
Then in the controller you have to add a check for spam in the shape 
of
  self.thorny_form_free_of_spam?. 
  
See the full Thorny Form docs for a code example and installation 
instructions here:
http://www.logilogi.org/pub/doc/plugins/thorny_form/

It is not an unbreakable solution, but it is likely to continue to
work for quite some time. The following joke from Ned Batchelders blog
nicely sketches why:

Jim and Joe are out hiking in the forest, when in the distance,
they see a huge bear. The bear notices them, and begins angrily
running toward them. Jim calmly checks the knots of his shoes and
stretches his legs.

Joe asks incredulously, “What are you doing? Do you think you can
outrun that bear!?”

Jim replies, “I don’t have to outrun the bear, I just have to
outrun you.”

Thorny Form is under the Affero GPL, and developed by the LogiLogi
Foundation (http://foundation.logilogi.org)

greetings,

Wybo Wiersma

---

::Student:
- Informatiekunde (computer linguistics, IR, webtech), History and Philosophy
- Member of the Center for Metahistory Groningen (http://www.rug.nl/let/cmg)

::Free Software and Open Source Developer:
- Active in the LogiLogi Foundation (http://foundation.logilogi.org)
- http://www.LogiLogi.org, Cumulative, shared commenting, publication and
   idea sharing: Where insight comes together...
- ComLinToo, a computational linguistics toolset written in Perl

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



[Rails] can't call request.remote_ip from object?

2009-02-09 Thread Taylor Strait

class User

  def update_metadata
self.update_attributes({:last_login_at => Time.now,
:last_known_up => request.remote_ip,
:last_known_user_agent =>
request.user_agent})
  end

This does not work. It bombs out with:

undefined local variable or method `request' for #

But the request calls work in a controller such as:

@ip = request.remote_ip
@agent = request.user_agent

What is the proper way to get this data into my model?
-- 
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] classpath Issue

2009-02-09 Thread Ganesh Krishnan

I am new to Ruby/RoR and would appreciate any help on the issue I am
trying to resolve far past 2 days.

I have a java application as a jar and I have included in the controller
as below.

  require 'java'
  require 'C:/Documents and Settings/user/Desktop/application.jar'

  include_package 'whatever.something'

After that I am calling a method from one of the classes in the jar.

  puts Java::WhateverSomething::Engine.helloWorld()

This helloWorld() program does a very complex thing :) and returns an id
string that I am trying to display in the console. This external
application has a call to the DB.

I have the driver jar in the application.jar. Also, I have included in
the RoR java runtime library and all places I can think of but still I
am getting the 'Class Not Found' exception. Can someone point what I am
doing wrong?

java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
...
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getConnection(DriverManager.java:545)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
...

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: development Windows or Linux?

2009-02-09 Thread EduardoChinchilla


My 2 cents:

I never used Linux before, the first task I did after installing
Ubuntu, a month ago,  was to set up a Rails environment, if you´re
from Windows world it could take some time just because it´s different
to install software in Linux, but once all it´s set up you don´t have
to mess a lot with the OS. There are many good tutorials on the web.
Now i´m the happy owner of a linux box with a complete Rails
environment for free, if it helps I could tell you that I only had  2
problems:

1. Using Netbeans 6.5 for linux I had problems to configure it to use
my gems repository for the ruby interpreter (not JRuby), this is when
I realize that in Ubuntu I was not the root user! and NB require real
root user permissions. I tried to configure GEM_PATH to use a
repository inside my user dir but this did not work. After some hours
of battle I give up and tried Netbeans 7, and it works!! Of course if
you don´t plan to use Netbeans you do not have to care.

2.I recommend to install Git before you start any programming, sooner
or later you´ll need it. for example:
   script/plugin install git://github.com/thoughtbot/paperclip.git won
´t work if you do not have Git installed on your system,who knows
it!!!. Well this may not be a linux issue but if you are as clueless
as me this could save you some time

In the end it is a good learning experience, and I do not regret of my
decision.

Good luck


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



[Rails] AR:BASE.default_timezone

2009-02-09 Thread James Byrne

I have a requirement to test code whose execution depends upon the
default_timezone setting.  I have tried several approaches to this but
nothing that I do in my test seems to alter the behaviour that is set in
environment.rb.

Is there a way to dynamically alter AR's method of storing datetime
during a test? Currently I attempt to do this in this fashion:

[ "local", "utc" ].each do |tz|
  ActiveRecord::Base.default_timezone = tz
  @my_mage = Magik.new
  @my_mage.description = tz
  @my_mage.my_time_local = DateTime.now
  @my_mage.my_time_utc = DateTime.now.utc
  @my_mage.save!
  puts @my_mage.description
end

but the contents of the my_time_local and my_time_utc do not seem to be
what I expect:

default_timezone = local
Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
  now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77585 <- Time.now
  UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
  now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.77609 <- Time.now.utc

default_timezone = utc
Local: Mon Feb 09 14:20:06 UTC 2009 = 1234189206.0 <- AR.my_time_local
  now: Mon Feb 09 14:20:06 -0500 2009 = 1234207206.77807 <- Time.now
  UTC: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.0 <- AR.my_time.utc
  now: Mon Feb 09 19:20:06 UTC 2009 = 1234207206.7783 <- Time.now.utc
.

Is it possible to override AR default_timezone values for testing?
-- 
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: Search between dates won't work properly

2009-02-09 Thread Gabi Ge

Jeff Burlysystems wrote:
> How about:
> 
> ...
> require 'time'
> ...
> invoices = Invoice.find(:all, :conditions=>['issue_date is not null
> and (issue_date >= ? or issue_date <= ?)', Time.parse('2009-02-09
> 00:00:00'), Time.parse('2009-02-09 23:59:59')] :order=>'issue_date')
> ...
> 
> Jeff

Thanks for your reply, and your help! It gave me a hint and solved the 
problem like this:

 self.cond << ["invoices.issue_date > ?", from - 1] unless from.blank?
 self.cond << ["invoices.issue_date < ?", to + 1] unless to.blank?

because issue_date is a datetime, and generating an invoice means saving 
both date and time of the day. This way the search will have the same 
results as in your example.

Once again, thank you for your help!
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: Search between dates won't work properly

2009-02-09 Thread Rick

things = Thing.find_all_by_field('start_at'..'end_at')


On Feb 9, 7:29 am, Gabi Ge  wrote:
> I'd like to search for invoices in the database, having the date range
> set (from, to). The problem is that invoices whose issue dates match the
> 'from' or 'to' dates will not show up in results.
>
> For example:
> Created an invoice today ("2009-02-09"), and I'm searching by issue_date
> between from and to, these are the params:
>
>  "filter"=>{"from"=>"2009-02-09", "to"=>"2009-02-09"}
>
> In the model I have the sql conditions, as well as a scope, looks like
> this:
>
>  self.cond = Array.new
>  self.cond << ["invoices.issue_date >= ?", from] unless from.blank?
>  self.cond << ["invoices.issue_date <= ?", to] unless to.blank?
>  result = join_conditions
> ---
>  named_scope :filter, lambda { |invoice_filter|
>     { :conditions => invoice_filter.sql_conditions }}
>
> The scope gets a filter object that has both 'from' and 'to' fields set.
> If I set the 'to' field to tomorrow's date, then the invoice will
> appear, but I don't understand why it wouldn't work as is since there
> are '<=' & '>=' comparisons in conditions.
>
> Any help or suggestion would be appreciated!
> --
> 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] rendering original view

2009-02-09 Thread bingo bob

  def create

# next statement is original and is removed
# @review = Review.new(params[:review])

@school = School.find(params[:school_id])
# @review = @school.reviews.create!(params[:review])
@review = @school.reviews.build(params[:review])


respond_to do |format|
  if @review.save

flash[:notice] = 'Review was successfully created.'
# format.html { redirect_to(@review) }
format.html { redirect_to(@school) }
format.xml  { render :xml => @review, :status => :created,
:location => @review }
  else
# format.html { render :action => "new" }
format.html { render :action => "new" }  #  <- HERE
format.xml  { render :xml => @review.errors, :status =>
:unprocessable_entity }
  end
end
  end


In this view the line

format.html { render :action => "new" }

renders the reviews new method when the validation fails...thing is I
want to show the school and the error messages, (schools controller show
method) like this line,  format.html { redirect_to(@school) }.

any help on how to do this?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] submit_to_remote change from 2.1 to 2.2 now gives wrong number of arguments

2009-02-09 Thread Andres Paglayan
Hi,

this snippet

<%= submit_to_remote('create_button', 'Add Phone',
  :submit =>
"phone_form",
:url =>
send( "#...@phonable_type.to_s.downcase.singularize}_phones_path",
@phonable_id),
:method => "post",
   :html => {:class =>
'submit'}
 ) %>


was working totally fine under 2.1.1,
it throws wrong number of arguments (3 for 2) on 2.2.2

submit_to_remote on 2.1.1
was

# File
vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb,
line 412 

412:   def submit_to_remote(name, value, options = {})
413: options[:with] ||= 'Form.serialize(this.form)'
414: 
415: options[:html] ||= {}
416: options[:html][:type] = 'button'
417: options[:html][:onclick] = "#{remote_function(options)}; return 
false;"
418: options[:html][:name] = name
419: options[:html][:value] = value
420: 
421: tag("input", options[:html], false)
422:   end


while on 2.2.2 is

# File vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb, 
line 421
421:   def submit_to_remote(name, value, options = {})
422: options[:with] ||= 'Form.serialize(this.form)'
423: 
424: html_options = options.delete(:html) || {}
425: html_options[:name] = name
426: 
427: button_to_remote(value, options, html_options)
428:   end


now it wraps the lower level button_to_remote,
but I don't get why mine is failing,


looks like submit and button to remote should be the same,
but not sure what's going on,

any help is appreciated,

Thank you,




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



[Rails] Help with routes and params

2009-02-09 Thread John Smith

I need some help with routes and params. I am developming some forums
for a web. I want to be able to create new replies once a post has been
created. So I create a post and then I have to put a link named "Reply".
What I want to do is Reply.create, and pass post_id as a param to this
Reply.create action. How can I make this link? How can I get this param
in replies controller?
I  think I can create a whole new action, but I would like to use
Reply.create.
-- 
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
-~--~~~~--~~--~--~---



  1   2   3   >