[Rails] Re: Interesting Class variable problem

2009-04-27 Thread Frederick Cheung



On Apr 27, 11:49 pm, Commander Johnson 
wrote:
> class PostOfTheDay
>   private
>
>   def self.current_day
>     DateTime.now.utc.to_date
>   end
>
>   @@current_post = nil
>   @@current_day = current_day
>
>   def self.get_random_post
>     posts = Post.all
>
>     posts[rand(posts.size)]
>   end
>
>   public
>
>   def self.fetch
>     if @@current_post.nil? || @@current_day != current_day
>       @@current_post = get_random_post
>       @@current_day = current_day
>     end
>
>     return @@current_post
>   end
> end
>
> I would expect the class variables @@current_post and @@current_day to never
> change when not accessed. However, in development mode, on each request, a
> different Post is returned because either the Klazz has been garbage
> collected (?) or the initializers
>
In development mode classes are cleaned out and loaded from scratch on
each request (this is why you don't need to restart the server to see
changes. In production this isn't true.

Fred

> @@current_post = nil
> @@current_day = current_day
>
> have been re-run. But isn't it required to initialize a class variable
> before usage?
>
> Why is this the default behaviour? Any pointers on a different approach?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Migrating rails 2.2.2 to 2.3.2

2009-04-27 Thread Commander Johnson
Oh and don't forget rake rails:update!

On Tue, Apr 28, 2009 at 8:54 AM, Commander Johnson <
commanderjohn...@gmail.com> wrote:

> Hi Don,
>
> This document helped me to migrate from 2.1 to 2.3:
>
> http://guides.rubyonrails.org/2_3_release_notes.html
>
> I also found a Google search on 'rails 2.3 ' very useful.
>
> CmdJohnson
>
>
> On Tue, Apr 28, 2009 at 4:51 AM, Don French  wrote:
>
>>
>> I tried to just change the rails gem I use with my application and I
>> got the following error:
>> /usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
>> active_support/core_ext/module/aliasing.rb:33:in `alias_method':
>> undefined method `template_exists?' for class
>> `ActionController::Base' (NameError)
>>
>> I can create a new project and it starts fine. Where is this error
>> coming from? Are there certain steps to migrate from 2.2.2 to 2.3.2?
>>
>> Don French
>> >>
>>
>

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



[Rails] Re: what's the easiest way for novice to install RoR

2009-04-27 Thread Sergio Footenko

Hi

 Try book recomended for me in this forum 
http://www.ruby-forum.com/topic/185496#new

 It is really, very very good book
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: what's the easiest way for novice to install RoR

2009-04-27 Thread Commander Johnson
Hi Sumon,

I recommend that you start in Windows (because that is your most familiar
environment) using RubyStack:

http://bitnami.org/stack/rubystack

RubyStack is like WAMP for Ruby. When you're comfortable with it, switch to
Linux because it will run much faster.

CmdJohnson

On Tue, Apr 28, 2009 at 6:59 AM, Sumon  wrote:

>
> hi,
>
> i am fairly novice in RoR. Even i don't have clear idea of RoR. but i
> am highly interested to learn RoR. i have some experience in php
> (mostly windows environment). so far i understand, RoR is best with
> linux. well, i have fedora 10 installed. php,mysql and apache2 is also
> installed. i am able to browse a page http://localhost/test_script.php
>
> in addition, in windows i use WAMP(Windows Apache MySql and PHP) which
> is really easy and install in one shot. now i am looking for
> equivalent of WAMP in fedora 10. i guess there are no tool in linux
> like WAMP. so, if i get an step by step instruction of "How to install
> RoR in Fedora 10" it shall feel lucky. please don't answer me to
> googled. because i already do that and make confused myself. you guys
> are expert. so please let me have the best link or guideline.
>
> please note that, i am new in linux too. and i know where is the
> terminal in fedora 10 and some basic knowledge of file structures.
>
> thanks
> Sumon
> >
>

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

2009-04-27 Thread Sergio Footenko

I have
Rails 2.3.2

 I'll buy this book today, and I like this tutorials that you adviced. 
Thanks you. But I'd be happy see many more advices =))

-- 
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] what's the easiest way for novice to install RoR

2009-04-27 Thread Sumon

hi,

i am fairly novice in RoR. Even i don't have clear idea of RoR. but i
am highly interested to learn RoR. i have some experience in php
(mostly windows environment). so far i understand, RoR is best with
linux. well, i have fedora 10 installed. php,mysql and apache2 is also
installed. i am able to browse a page http://localhost/test_script.php

in addition, in windows i use WAMP(Windows Apache MySql and PHP) which
is really easy and install in one shot. now i am looking for
equivalent of WAMP in fedora 10. i guess there are no tool in linux
like WAMP. so, if i get an step by step instruction of "How to install
RoR in Fedora 10" it shall feel lucky. please don't answer me to
googled. because i already do that and make confused myself. you guys
are expert. so please let me have the best link or guideline.

please note that, i am new in linux too. and i know where is the
terminal in fedora 10 and some basic knowledge of file structures.

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



[Rails] Re: What is 'Representational State Transfer'?

2009-04-27 Thread Robert Walker

David A. Black wrote:
> Hi --
> 
> Robert Walker wrote:
>>
>> Representational:
>> The web consists of resources in the form of web pages that are
>> represented using a Uniform Resource Identifier (URI). REST extends this
>> definition to refer to other types of resources of an application (i.e.
>> database tables). Which, can also be represented using a URI.
>> http://example.com/posts/1 represents the first Post resource in the
>> posts collection.
> 
> A resource in the REST sense isn't anything as concrete as a database
> table, though. It's more conceptual. As Fielding says: "The resource is
> not the storage object. The resource is not a mechanism that the server
> uses to handle the storage object."

Absolutely. Thanks David for this elaboration.

> A given system gives and receives representations of resources. A
> resource is a very high-level construct; a representation is more
> specific, and has a content-type and so forth. Resources don't. (Even
> more low-level are matters of storage, which may vary and which are not,
> themselves, either resources or representations.)
> 
> A resource is always in a given state. Resource states are altered via
> the exchange of representations. So if I want to correct the spelling of
> my name on a site, I submit a representation of my profile with the new
> spelling (probably in the form of a Web form). If I want to make sure
> it's OK, I request a representation (probably in the form of an HTML
> document) to inspect.

Nice explanation. I look forward to reading your articles when I have a
few spare moments.
-- 
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: Rails2 Documetation.

2009-04-27 Thread Conrad Taylor
On Mon, Apr 27, 2009 at 9:03 PM, Sergio Footenko <
rails-mailing-l...@andreas-s.net> wrote:

>
> Hello !
>
>  I started to learn the ruby on rails 2(!) and I have many problems with
> documentation. I'm new in this, and I don't know difference between 1x
> and 2x versions of rails, oh , yes, I can see difference after seen
> error messages in
> firefox, removing this documentation, and adding this sites to
> markedlist =)
>

This really depends on what version of Rails you have installed?  In
general,
if you have questions and/or need information about the current version of
Rails, I would recommend taking a look at the following:

http://api.rubyonrails.org


>
>  I never seen the tutorial or 1 of 4 books (received from friend of
> mine) is worked, after reading 50 pages I understand that is for old
> version and does not works  for me, tutorials does not works too. =(( I
> killed much time for broken documentation.  I know only one place where
> documentation is actual is  http://guides.rubyonrails.org/ , but it is
> not enough for learning.


First, I would highly recommend getting a good book.  Thus, I would
recommend
getting a copy of "Agile Web Development with Rails 3rd" by Dave Thomas et
al.
Next, if you're working with Rails 2.3.2 in conjunction with the above book,
I would
recommend taking a look at the following links:

http://guides.rubyonrails.org/2_3_release_notes.html
http://pragprog.wikidot.com/changes-in-rails-2-3


>
>
>  I looking for working(!) documentation for rails 2(!), and maybe any
> advices how to search it and determine defference without diving to this
> broken documentation.
>
>  Ok, I have question about associations. How to retrieve/send parameters
> between the controllers without using the "hidden_fields" for html
> forms?
>
>  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] Rails2 Documetation.

2009-04-27 Thread Sergio Footenko

Hello !

 I started to learn the ruby on rails 2(!) and I have many problems with
documentation. I'm new in this, and I don't know difference between 1x
and 2x versions of rails, oh , yes, I can see difference after seen
error messages in
firefox, removing this documentation, and adding this sites to
markedlist =)

 I never seen the tutorial or 1 of 4 books (received from friend of
mine) is worked, after reading 50 pages I understand that is for old
version and does not works  for me, tutorials does not works too. =(( I
killed much time for broken documentation.  I know only one place where
documentation is actual is  http://guides.rubyonrails.org/ , but it is
not enough for learning.

 I looking for working(!) documentation for rails 2(!), and maybe any
advices how to search it and determine defference without diving to this
broken documentation.

 Ok, I have question about associations. How to retrieve/send parameters
between the controllers without using the "hidden_fields" for html
forms?

 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] Problem with SEO urls and the Find_By_ID() not working

2009-04-27 Thread Steve Shephed

I have a problem where the app I am developing uses SEO friendly urls
using the to_params method.

When using the the finder method find_by_id('13-Some-other-text') it
is not finding the record.
The record is there.
If I put a to_i() on the value it works fine.

I thought ActiveRecord did this automatically

Steve

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



[Rails] Introducing Pfeed plugin, automagically create fancy logs / activity updates in your rails app

2009-04-27 Thread abhishek.parolkar

Hey All!
   I just pushed a plugin that brings little more simplicity to the
way we
create customizable logs, either for implementing activity feed
feature or
logging for monitoring purposes. Let me know your thoughts. Though,
there is
little documentation, it should be enough for people to get started
and get
the idea.

Watch it yourself! http://github.com/parolkar/pfeed/tree/master

Its released under MIT-License


Regards,
Abhishek Parolkar
http://www.ohloh.net/accounts/parolkar/

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



[Rails] Migrating rails 2.2.2 to 2.3.2

2009-04-27 Thread Don French

I tried to just change the rails gem I use with my application and I
got the following error:
/usr/local/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/core_ext/module/aliasing.rb:33:in `alias_method':
undefined method `template_exists?' for class
`ActionController::Base' (NameError)

I can create a new project and it starts fine. Where is this error
coming from? Are there certain steps to migrate from 2.2.2 to 2.3.2?

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

2009-04-27 Thread Arthur Chan

Thanks guys,

I kinda understood the basic idea of the TSP. i wanna do something like 
heuristic functions. Or, something like:

http://www.ruby-forum.com/topic/127031#new

I don't know if the "grid" method mentioned is applicable for general 
TSP.

Thanks again.

Robert Anderson wrote:
> I said start here, no finish here :)
> 
> --
> Robert Anderson Nogueira de Oliveira
> _
> Tribunal de Justiça do Estado de Sergipe
> Graduando em Sistemas de Informação - UNIT
> MSN: ranophoe...@hotmail.com
> 
> "Ausência de evidência não é evidência de ausência." (Carl Sagan)

-- 
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: Asynchronous SSH tasks

2009-04-27 Thread Paul Denize

Found the solution

ssh_session = Net::SSH.start(...etc...)

sftp_conn = ssh_session.sftp.connect!   # needed to block connect here 
(!) or the upload seems to hang
sftp_conn.upload(src_file, tgt_file)

interrupted = false
trap('INT') { interrupted = true }
sftp_conn.loop() {
not interrupted and sftp_conn.pending_requests.any?   # check for 
pending requests
}
sftp_conn.close_channel()
ssh_session.loop(1) {
   not interrupted and ssh_session.busy?
 }
sftp_conn = ssh_session.sftp.connect!


One word of warning if sending lots of files (>300) fast then you may 
run out of open file handles (Windows).
I avoid the error by doing this call each now and then when starting 
another upload

if (sftp_conn.pending_requests.length>=100)
  interrupted = false
  trap('INT') { interrupted = true }
  sftp_conn.loop() {
not interrupted and sftp_conn.pending_requests.any?
  }
end

I guess I could have exited when the queue was smaller not empty also.

Hope this helps someone else.
-- 
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: Asynchronous copies

2009-04-27 Thread pdenize

Found the solution

ssh_session = Net::SSH.start(...etc...)

sftp_conn = ssh_session.sftp.connect!   # needed to block connect here
(!) or the upload seems to hang
sftp_conn.upload(src_file, tgt_file)

interrupted = false
trap('INT') { interrupted = true }
sftp_conn.loop() {
not interrupted and sftp_conn.pending_requests.any?   # check for
pending requests
}
sftp_conn.close_channel()
ssh_session.loop(1) {
   not interrupted and ssh_session.busy?
 }
sftp_conn = ssh_session.sftp.connect!


One word of warning if sending lots of files (>300) fast then you may
run out of open file handles (Windows).
I avoid the error by doing this call each now and then when starting
another upload

if (sftp_conn.pending_requests.length>=100)
  interrupted = false
  trap('INT') { interrupted = true }
  sftp_conn.loop() {
not interrupted and sftp_conn.pending_requests.any?
  }
end

I guess I could have exited when the queue was smaller not empty also.

Hope this helps someone else.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: if...elseif...else, broken; need help

2009-04-27 Thread Brendon

Perhaps using elsif instead of elseif will help.  But your code makes
no attempt to return a value, so the nil is expected.
If you are planning on returning a value, do something like this:
result = if person == "Somebody"
  "foo"
elsif person == "Another"
  "else if returned"
else
  "no match"
end

On Apr 23, 12:07 pm, DrV  wrote:
> I've been working on a new project and created a custom method for one
> of the models.  Nothing major.
>
> I brought up the console in --sandbox mode (also have tried in
> standard console), and tried playing with it.  To my surprise there
> was a problem with the if/elseif conditional.  The elseif portion
> simply would not work.  So I tried a couple commands as so to test the
> actual if/elseif integrity like so:
>
> person = "Jim"
> if person == "Sally"
> puts "Hi Sally"
> elseif person == "Jim"
> puts "Hi Jim"
> end
>
> This returns nil.  If I put a final  catch it will return that
> value.  What am I doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Find eager loads correct records but generates excess queries (Rails 2.1)

2009-04-27 Thread davidy

All SQL queries are generated by that one, single find() call. This is
really scary -- there is nothing in the documentation to suggest that
it can do this kind of "fake join", or the performance impact it can
have.

Sorry about the anonymisation, but the real table names would only
confuse things worse.

I suspect this is a bug/feature of Rails eager loading, caused by the
"triangular" relationships. S loads F using has_many, then F loads P
using belongs_to, then S loads P again using has_many through. It
"should" be smart enough not to, but that logic isn't in there. The
documentation is absolutely no help, and the source code is way too
complicated for this bear.

Q3 is the answer. I fixed the problem (with dramatic performance
improvement) using :include {hash}, like so.
  S.find_all_by_key([array of keys], :include => {:F => :P})

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



[Rails] Re: Is Amazon s3 always this slow?

2009-04-27 Thread Sanuk Mak

Chris Olsen wrote:
> I made some changes to prevent accessing all the files through an ssl
> connection, but it is still at about 3 seconds to download. (Actually
> the files are missing on the s3 server so it is really taking three
> seconds to find out that the files are not there).
> 
> The RightAws::S3Interface has also been changed from single-threaded
> mode to multi-threaded mode, but with very little, if any difference.
> 
> Can this be made any better?

Hi Chris,

What were the changes you made to prevent the accessing of files via 
ssl?
I'm experiencing the same slowness and am trying to figure out how to 
get a http connection to access the S3 files instead.

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: Writing a plugin: Need to get including class's name. Help?

2009-04-27 Thread Chris Johnson

Chris Johnson wrote:
> Hello.
> 
> For reference, here is some sample code that exemplifies what I am
> trying to do:
> http://gist.github.com/102816
> 
> I am trying to dynamically defined a class, whose name is either passed
> in as a parameter or based on the including class name.
> 
> So if I had something like this:
> class Green; acts_as_duck; end
> 
> I would expect the generated class to be called "GreenDuck", and to be
> defined within the "Green" class.
> 
> The problem is that no matter what I do, the dynamically referenced
> class name is always just "Class".
> 
> Any suggestions here?
> 
> Thanks.
> Chris

For the record, I got around this by doing some dynamic eval in the 
module eval:

http://gist.github.com/102836

Maybe there was a simpler way(?)

-Chris
-- 
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 Instance Variables

2009-04-27 Thread djolley

> Is this something that you can do with a before_filter?

I think you may be onto something.  Conceptually, it sounds like your
suggestion should work.  I'm just not sure that I know how to go about
implementing it.  I'll play around with the concept and post if I am
successful.  In the meantime, if anyone has any specific input on
precisely how to do this, I'd sure love to hear it.

Thanks for the input.

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



[Rails] google adsense breaks render :partial =>

2009-04-27 Thread Richard Schneeman

Hey everybody, i've got a control that returns a partial, no biggie.
Except when that partial contains the javascript for my adsense account.
Then the partial renders correctly, and then quickly replaces my page
with nothing by the ad. When i take away my adsense js, everything works
great. Has anyone encountered this before, or know how to get around it?

def submit_remote_form
   render :partial => "my_partial"
end

#views /my_partial

 <% remote_form_for :action => :submit_remote_form do |f| %>
  <%= f.text_field :something %>

<%= f.submit "submit" %>



http://pagead2.googlesyndication.com/pagead/show_ads.js";>

<% end %>

I know i could get around this by taking out the adsense js, but that
would require "creative" (to say the least) html/css design to get the
same result.
-- 
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 Instance Variables

2009-04-27 Thread djolley

> I am having difficulty imagining why you would want an instance variable of
> a controller that is not associated with an action, what else do controllers
> do?

The thing is that this particular instance variable is associated with
*ALL* of the actions of the controller.  I want to be DRY and only
specify the value of the instance variable once and have that value
available in all of the views associated with each of the actions of
that controller.

> Are you sure it is not an instance variable of a model that you should
> be using?

I don't think so.  Models extend from ActiveRecord::Base.  Therefore
in my nieve view of the Rails world, models are only used with
databases.  I don't have a database involved.  I just want to pass a
common value from the controller to the views and I don't want to have
to redundantly specify that value in each of the actions.

Thanks for the input.

... doug

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



[Rails] Asynchronous SSH tasks

2009-04-27 Thread Paul Denize

I have managed to get copies working well between Windows and Linux
but I noticed that the libraries allow Asynchronous operation.  I can
send Async commands and the loop till they complete but copies seem to
stay busy forever.  Maybe I am just not cleaning up right (it does not
seem so)

ssh_session = Net::SSH.start(...etc...)


# ssh_session.exec("sleep 10")
ssh_session.sftp.connect.upload(src_file, tgt_file)


ssh_session.loop(1) {
   puts "I=#{interrupted} B="+...@ssh_session.busy?.inspect
   not interrupted and @ssh_session.busy?
 }


If the sleep is called (instead of the upload) it waits 10 secs and
then is not busy and wakes.
But the copy will not wake.  Since I have hundreds of files to copy
I'd like to set them all off, do some other work, and then wait for
them to complete (rather than wait for them one at a time with
upload!) and then do the other work.


Any help would be appreciated... should I cleanup the "sftp.connect"?
How?  When (if it is asynchronous)?


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] Writing a plugin: Need to get including class's name. Help?

2009-04-27 Thread Chris Johnson

Hello.

For reference, here is some sample code that exemplifies what I am
trying to do:
http://gist.github.com/102816

I am trying to dynamically defined a class, whose name is either passed
in as a parameter or based on the including class name.

So if I had something like this:
class Green; acts_as_duck; end

I would expect the generated class to be called "GreenDuck", and to be
defined within the "Green" class.

The problem is that no matter what I do, the dynamically referenced
class name is always just "Class".

Any suggestions here?

Thanks.
Chris
-- 
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: validators.rb breaks after update from Rails 2.2.2 to 2.3.2

2009-04-27 Thread Matt Jones

My guess would be some change to the load order - you'd be better off
loading your custom validations in an initializer, so that
ActiveRecord is loaded.

--Matt Jones


On Apr 26, 5:22 am, John Mackin  wrote:
> I just updated my rails application from 2.2.2 to 2.3.2 and the
> following message is displayed while trying to start with ./script/
> server:
>
> [code]
> => Booting Mongrel
> => Rails 2.3.2 application starting 
> onhttp://0.0.0.0:3000/opt/local/lib/ruby/gems/1.8/gems/activesupport-2
> active_support/core_ext/module/aliasing.rb:33:in `alias_method':
> undefined method `valid?' for class `ActiveRecord::Base' (NameError)
>   from /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
> active_support/core_ext/module/aliasing.rb:33:in `alias_method_chain'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/callbacks.rb:224:in `send'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/callbacks.rb:224:in `included'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/callbacks.rb:223:in `each'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/callbacks.rb:223:in `included'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/base.rb:3143:in `include'
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/base.rb:3143
>   from /opt/local/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/
> active_record/base.rb:3137:in `class_eval'
>    ... 11 levels...
>   from /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/commands/
> server.rb:84
>   from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `gem_original_require'
>   from /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:
> 31:in `require'
>   from ./script/server:3
> [/code]
>
> I figured out that if I comment out "require 'validators.rb'" inside
> my environment.rb than it'll work fine. Validators.rb (http://
> pastie.org/457289) handles some special validations and sits in my lib
> directory.
>
> I am wondering what has changed from 2.2.2 to 2.3.2 that all the
> sudden this rather simple extension wouldn't work anymore.
>
> Does any have an idea?
>
> JM
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Submit form through GET requets

2009-04-27 Thread Cisco Ri

Cisco Ri wrote:
> I'm going ahead with:
> 
> @link = @user.links.create!("url" => params[:url])
> 
> I also changed my routes.rb file to include these lines:
>   # map.resources :links
>   map.resources :users, :has_many => :links
> 
> It works, but I'm still having some trouble.  With these lines
> 
> @link = @user.links.create!("url" => params[:url])
> @link.title = title=(Hpricot(open(@link.url))/"title").inner_text
> 
> the action just repeats the URL as the title.  Also, is there a way that 
> I can reuse the code from my create action:
> 
>   def create
> @user = current_user
> @link = @user.links.create!(params[:link])
> @link.title = title=(Hpricot(open(@link.url))/"title").inner_text 
> 

Whoops, it actually doesn't repeat the URL as the title -- it works 
correctly.  But is there a way that I can reuse the code from the create 
action?
-- 
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] Different links after refresh

2009-04-27 Thread Cisco Ri

I have a couple of links that appear via Ajax.

<%= link_to 'Edit', url_for(:controller => :links,
:action => "edit", :id => link.id) %> | <%= link_to 'Destroy',
url_for(:controller => :links, :action => "destroy", :id => link.id)
%>

After their appearance, they go to
http://localhost:3000/users/1/links/110/edit and
http://localhost:3000/users/1/links/110.

If I refresh the page, they go to http://localhost:3000/links/edit/110
and http://localhost:3000/links/destroy/110.

Can somebody let me know what causes this, and if there is a better way
to create these links than to use url_for.

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: Submit form through GET requets

2009-04-27 Thread Cisco Ri

I'm going ahead with:

@link = @user.links.create!("url" => params[:url])

I also changed my routes.rb file to include these lines:
  # map.resources :links
  map.resources :users, :has_many => :links

It works, but I'm still having some trouble.  With these lines

@link = @user.links.create!("url" => params[:url])
@link.title = title=(Hpricot(open(@link.url))/"title").inner_text

the action just repeats the URL as the title.  Also, is there a way that 
I can reuse the code from my create action:

  def create
@user = current_user
@link = @user.links.create!(params[:link])
@link.title = title=(Hpricot(open(@link.url))/"title").inner_text 

-- 
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] Interesting Class variable problem

2009-04-27 Thread Commander Johnson
class PostOfTheDay
  private

  def self.current_day
DateTime.now.utc.to_date
  end

  @@current_post = nil
  @@current_day = current_day

  def self.get_random_post
posts = Post.all

posts[rand(posts.size)]
  end

  public

  def self.fetch
if @@current_post.nil? || @@current_day != current_day
  @@current_post = get_random_post
  @@current_day = current_day
end

return @@current_post
  end
end

I would expect the class variables @@current_post and @@current_day to never
change when not accessed. However, in development mode, on each request, a
different Post is returned because either the Klazz has been garbage
collected (?) or the initializers

@@current_post = nil
@@current_day = current_day

have been re-run. But isn't it required to initialize a class variable
before usage?

Why is this the default behaviour? Any pointers on a different approach?

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



[Rails] Re: What is 'Representational State Transfer'?

2009-04-27 Thread David A. Black

Hi --

Robert Walker wrote:
> Amita Bhatkhande wrote:
>> I have read about REST, but never really understood meaning of
>> 'Representational State Transfer'. I tried to read Fielding's
>> dissertation, but did not understand this term and why has he used it.
>> What does it mean? Which state? What transfer?
>
> I'm not sure anyone knows why Fielding used this term. I suppose he had
> to call it something, so that's what he chose.
>
> However, I'll try to explain it as I understand it:
>
> Representational:
> The web consists of resources in the form of web pages that are
> represented using a Uniform Resource Identifier (URI). REST extends this
> definition to refer to other types of resources of an application (i.e.
> database tables). Which, can also be represented using a URI.
> http://example.com/posts/1 represents the first Post resource in the
> posts collection.

A resource in the REST sense isn't anything as concrete as a database 
table, though. It's more conceptual. As Fielding says: "The resource is 
not the storage object. The resource is not a mechanism that the server 
uses to handle the storage object."

> State:
> This is the current state of the resources.
>
> Transfer (or more precisely State Transfer):
> The act of modifying the current state of the resources. Adding a new
> one, modifying an existing one, deleting an existing one, etc.
>
> REST defines a convention of using HTTP to both represent and change the
> state of resources. That's a close as I can come to defining
> "Representational State Transfer."

My nutshell take on it is something like this:

A given system gives and receives representations of resources. A 
resource is a very high-level construct; a representation is more 
specific, and has a content-type and so forth. Resources don't. (Even 
more low-level are matters of storage, which may vary and which are not, 
themselves, either resources or representations.)

A resource is always in a given state. Resource states are altered via 
the exchange of representations. So if I want to correct the spelling of 
my name on a site, I submit a representation of my profile with the new 
spelling (probably in the form of a Web form). If I want to make sure 
it's OK, I request a representation (probably in the form of an HTML 
document) to inspect.

I've written a bit more about this on these blog posts:

http://dablog.rubypal.com/2008/3/23/splitting-hairs-over-resource
http://dablog.rubypal.com/2008/4/24/splitting-hairs-over-resource-part-2

specifically in a Rails context. (Wow, was that more than a year ago?)


David

-- 
David A. Black / Ruby Power and Light, LLC
Ruby/Rails consulting & training: http://www.rubypal.com
Now out in PDF: The Well-Grounded Rubyist (http://manning.com/black2)
"Ruby 1.9: What You Need To Know" Envycasts with David A. Black
http://www.envycasts.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] Too Many Rooms for Rubyconf

2009-04-27 Thread Marz

Booked 4 Rooms we aren’t going to use, walking distance to the
Conference. Four nights: Sunday 5-3-09 through Wednesday 5-6-09.

Willing to let them go for about HALF the price of the Hilton.

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



[Rails] Re: Passing multiple values with link_to

2009-04-27 Thread Frederick Cheung



On Apr 27, 10:57 pm, DVG  wrote:
> Okay, so I have a many-to-many relationship between Users and Groups.
> When looking at the Group, I have the user rows being rendered via a
> partial. I want to have a "Remove" link next to each user name in
> turn, which calls the "remove user from group" action, but I'm unsure
> how exactly to specify this with link_to.
>
You can pass as many url parmeters to link_to as you want, eg link_to
'Remove', :action => "remove_user_from_group", :id => @group.id, :foo
=> 'bar', :baz => '123'

Fred

> This is what I have:
>
> 
>   <%= @user.login %> (<%= link_to "Remove", :action =>
> "remove_user_from_group", :id => @group.id, :locals => {:login =>
> @user.login} %>)
> 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Passing multiple values with link_to

2009-04-27 Thread DVG

Okay, so I have a many-to-many relationship between Users and Groups.
When looking at the Group, I have the user rows being rendered via a
partial. I want to have a "Remove" link next to each user name in
turn, which calls the "remove user from group" action, but I'm unsure
how exactly to specify this with link_to.

This is what I have:


  <%= @user.login %> (<%= link_to "Remove", :action =>
"remove_user_from_group", :id => @group.id, :locals => {:login =>
@user.login} %>)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Error following the 15 minute blog with ROR Screen cast

2009-04-27 Thread Frederick Cheung

On Apr 27, 9:33 pm, Tommo  wrote:
> 1: <% div for @post do %>

You've got a typo here -  it should be div_for

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] Ruby on Rails Developers

2009-04-27 Thread irenka

Cubiware jest spółka zajmująca się tworzeniem oprogramowania dla
urządzeń interaktywnej telewizji cyfrowej oraz internetowej. Firma
współpracuje z klientami i partnerami zagranicznymi, a nasze
oprogramowanie jest używane w USA, krajach europy zachodniej oraz w
Azji. Naszymi Klientami są producenci urządzeń elektronicznych oraz
operatorzy telekomunikacyjni. www.cubiware.com

Wymagania:
- dobra znajomość języka Ruby oraz frameworku Ruby on Rails
- Znajomość języka SQL (dialekt MySQL)
- Znajomość angielskiego na poziomie umożliwiającym komunikację ws.
technicznych (w mowie i piśmie)

Mile widziane:
- znajomość środowiska Linux
- znajomość technologii AJAX, protokołu SOAP

Przykładowe zadania:
- napisanie aplikacji umożliwiającej edycję meta-danych filmów
- napisanie modułu obliczającego koszt usługi dla abonenta
- napisanie modułu generującego raporty

Oferujemy:
- możliwość rozwoju i poznawania nowych technologii w przyjaznym
środowisku pracy
- pracę przy ciekawych i innowacyjnych projektach
- atrakcyjne wynagrodzenie

adres email:car...@cubiware.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] Error following the 15 minute blog with ROR Screen cast

2009-04-27 Thread Tommo

Hello Everyone,

I was following this screen cast: 
http://media.rubyonrails.org/video/rails_blog_2.mov

and when I got to the part about making a new file, creating a
template, and then rendering the partial, I received the following
error page:

SyntaxError in Posts#show

Showing app/views/posts/_post.html.erb where line #1 raised:

compile error
C:/Documents and Settings/Tomo/ror/blog/app/views/posts/_post.html.erb:
1: syntax error, unexpected kDO_BLOCK, expecting tCOLON2 or '[' or '.'
old_output_buffer = output_buffer;post = local_assigns
[:post];object = local_assigns[:object];;@output_buffer = '';
__in_erb_template=true ;  div for @post do ; @output_buffer.concat
"\n"
 
^
C:/Documents and Settings/Tomo/ror/blog/app/views/posts/_post.html.erb:
6: syntax error, unexpected kENSURE, expecting $end
Extracted source (around line #1):

1: <% div for @post do %>
2:  <%= link_to_unless_current h(post.title), post %>
3:  <%= simple_format h(post.body) %>
4: <% end %>
Trace of template inclusion: app/views/posts/_post.html.erb, app/views/
posts/show.html.erb

RAILS_ROOT: C:/Documents and Settings/Tomo/ror/blog

Application Trace | Framework Trace | Full Trace
app/views/posts/_post.html.erb:6:in `compile!'
app/views/posts/show.html.erb:1
app/controllers/posts_controller.rb:18:in `show'
Request

Parameters:

{"id"=>"2"}
Show session dump

Response

Headers:

{"cookie"=>[],
 "Content-Type"=>"text/html",
 "Cache-Control"=>"no-cache"}


This question has been asked before but it does not seem like there
was an answer given.  Hopefully somebody will be able to help me out.
Thanks!

Tom

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

2009-04-27 Thread Freddy Andersen

Is this something that you can do with a before_filter?


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



[Rails] Re: What is 'Representational State Transfer'?

2009-04-27 Thread Commander Johnson
I for one found this post very useful.

On Mon, Apr 27, 2009 at 10:16 PM, Robert Walker <
rails-mailing-l...@andreas-s.net> wrote:

>
> Amita Bhatkhande wrote:
> > I have read about REST, but never really understood meaning of
> > 'Representational State Transfer'. I tried to read Fielding's
> > dissertation, but did not understand this term and why has he used it.
> > What does it mean? Which state? What transfer?
>
> I'm not sure anyone knows why Fielding used this term. I suppose he had
> to call it something, so that's what he chose.
>
> However, I'll try to explain it as I understand it:
>
> Representational:
> The web consists of resources in the form of web pages that are
> represented using a Uniform Resource Identifier (URI). REST extends this
> definition to refer to other types of resources of an application (i.e.
> database tables). Which, can also be represented using a URI.
> http://example.com/posts/1 represents the first Post resource in the
> posts collection.
>
> State:
> This is the current state of the resources.
>
> Transfer (or more precisely State Transfer):
> The act of modifying the current state of the resources. Adding a new
> one, modifying an existing one, deleting an existing one, etc.
>
> REST defines a convention of using HTTP to both represent and change the
> state of resources. That's a close as I can come to defining
> "Representational State Transfer."
>
> Hope that helps.
> --
> Posted via http://www.ruby-forum.com/.
>
> >
>

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



[Rails] Re: ruby jasper report

2009-04-27 Thread Gianluca Tessarolo
Tushar,

IMHO Jasper Reports and iReport are great tools.

I have built a system with rails 1.1.x and some days ago I've 
successfully ported it on Rails 2.3.2, all works well (the only gotcha 
is a little memory leak calling IO.popen (not destructive memory leak), 
I think the problem is due to Passenger 2.1.3 but the system is very 
stable).

Using jasper reports (and iReport for design) I'm able to print some 
good moderate complex reports from different db (IBM AS/400, MySQL, 
Firebird and MS-SQL) (some reports are lables images (linked from web 
site...) printed on thermal printer).

I was able to print the reports calling a bash script passing parameters 
ex.:

lib/document.rb

class Document
  def self.generate_report(report_design, output_type, jdbc_driver, 
jdbc_url, jdbc_user, jdbc_password, report_parameters)
  # params:
  # report_design: the name of jasper file containing the report design
  # output_type: one of the following: pdf, xml, rtf, xls, csv, html
  # jdbc_driver: ex. org.firebirdsql.jdbc.FBDriver for FireBird db
  # jdbc_url: ex. jdbc:firebirdsql:localhost:mydb for FireBird db
  # jdbc_user: ex. sysdba for FireBird db
  # jdbc_password: ex. masterkey for FireBird db
  # report_prarameters: param_name@@param_type@@param_value ex. 
filter_by_name@@String@@goofy
  # accepted param types:
  # java.util.Date (string formatted with dd/MM/)
  # java.lang.Boolean (string: "true", "1", "-1" are considered true)
  # boolean (same as above)
  # java.lang.String (string)
  # string (same as above)
  # java.lang.Integer (integer)
  # int (same as above)
  # java.lang.Double (double)
  # double (same as above)
  # For more info see XmlJasperInterface.java
  report_design << '.jasper' if !report_design.match(/\.jasper$/)
  params = ""
  if report_parameters != nil
report_parameters.each {|p| params << 
"-r\"#{p.name}@@#{p.java_type}@@#{p.value}\" "}
  end
  pipe = IO.popen 
"#{APP_PATH}jasper/XmlJasperInterface-#{RAILS_ENV}.sh -o#{output_type} 
-f\"#{APP_PATH}reports/#{report_design}\" -d\"#{jdbc_driver}\" 
-u\"#{jdbc_url}\" -n\"#{jdbc_user}\" -p\"#{jdbc_password}\" #{params}", "r"
  result = pipe.read
  pipe.close
  result
  end
end

Shell script:

jasper/XmlJasperInterface-production.sh
#!/bin/sh
INTERFACE_CLASSPATH=.../path_to_jar/XmlJasperInterface.jar

# Here put all jdbc libraries (jars) into classpath
for i in path_to_application/jasper/lib/*.jar; do 
INTERFACE_CLASSPATH=$INTERFACE_CLASSPATH:$i; done

java -cp "$INTERFACE_CLASSPATH" XmlJasperInterface "$@"

This is the source for XmlJasperInterface.java

/*
* Inspired by the xmldatasource sample application provided with
 * jasperreports-1.1.0
 */
 
import java.sql.Connection;
import java.sql.DriverManager;
import java.text.ParseException;
import net.sf.jasperreports.engine.JRException;
import net.sf.jasperreports.engine.JRExporterParameter;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrint;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporterParameter;
import net.sf.jasperreports.engine.export.JRRtfExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXlsExporterParameter;
import java.util.Map;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.util.HashMap;
 
/**
 * @author Jonas Schwertfeger (jonas at schwertfeger dot ch)
 * @version $Id: XmlJasperInterface.java,v 1.4 2006/06/06 11:59:48 tex 
Exp $
 * extended by Tex 2006
 */
public class XmlJasperInterface {
private static final String TYPE_PDF = "pdf";
private static final String TYPE_XML = "xml";
private static final String TYPE_RTF = "rtf";
private static final String TYPE_XLS = "xls";
private static final String TYPE_CSV = "csv";
private static final String TYPE_HTML = "html";

private String outputType;
private String compiledDesign;
private String jdbcDriver;
private String jdbcUrl;
private String jdbcUser;
private String jdbcPassword;
private Map parameters = new HashMap();

public static void main(String[] args) throws Exception {
String outputType = null;
String compiledDesign = null;
String jdbcDriver = null;
String jdbcUrl = null;;
String jdbcUser = null;;
String jdbcPassword = null;
Map parameters = new HashMap();

if (args.length < 6) {
printUsage();
return;
}

for (int k = 0; k < args.length; ++k) {
if (args[k].startsWith("-o")) {
outputType = args[k].substring(2);
} else if (args[k].startsWith("-f")) {
compiledDesign = arg

[Rails] Re: deprec problem

2009-04-27 Thread Conrad Taylor
On Mon, Apr 27, 2009 at 1:52 PM, Conrad Taylor  wrote:

> On Mon, Apr 27, 2009 at 1:37 PM, mahmoud_cs 
> wrote:
>
>>
>> i deploy my rails application with capistrano and deprec2  to  ubuntu
>> the username is 'mahmoud'
>> but when i deploy this message display
>> " connection failed for: 10.0.0.8
>> (Net::SSH::AuthenticationFailed: mahmoud) "
>> what can i do?
>
>
> You can simply verify your connection by doing the following:
>
> ssh mahmoud@
>

The above command is to be performed at the command line.


>
> If this doesn't work, then you need to check that you can connect
> to the host using SSH.  Then you'll need to verify that you're using
> the correct credentials.
>
> If it does work, then you'll need to check that you're the correct
> credentials within your Capistrano configs.
>
> Good luck,
>
> -Conrad
>
>
>>
>> >>
>>
>

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



[Rails] Re: deprec problem

2009-04-27 Thread Conrad Taylor
On Mon, Apr 27, 2009 at 1:37 PM, mahmoud_cs wrote:

>
> i deploy my rails application with capistrano and deprec2  to  ubuntu
> the username is 'mahmoud'
> but when i deploy this message display
> " connection failed for: 10.0.0.8
> (Net::SSH::AuthenticationFailed: mahmoud) "
> what can i do?


You can simply verify your connection by doing the following:

ssh mahmoud@

If this doesn't work, then you need to check that you can connect
to the host using SSH.  Then you'll need to verify that you're using
the correct credentials.

If it does work, then you'll need to check that you're the correct
credentials within your Capistrano configs.

Good luck,

-Conrad


>
> >
>

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



[Rails] deprec problem

2009-04-27 Thread mahmoud_cs

i deploy my rails application with capistrano and deprec2  to  ubuntu
the username is 'mahmoud'
but when i deploy this message display
" connection failed for: 10.0.0.8
(Net::SSH::AuthenticationFailed: mahmoud) "
what can i do?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What is 'Representational State Transfer'?

2009-04-27 Thread Robert Walker

Amita Bhatkhande wrote:
> I have read about REST, but never really understood meaning of
> 'Representational State Transfer'. I tried to read Fielding's
> dissertation, but did not understand this term and why has he used it.
> What does it mean? Which state? What transfer?

I'm not sure anyone knows why Fielding used this term. I suppose he had 
to call it something, so that's what he chose.

However, I'll try to explain it as I understand it:

Representational:
The web consists of resources in the form of web pages that are 
represented using a Uniform Resource Identifier (URI). REST extends this 
definition to refer to other types of resources of an application (i.e. 
database tables). Which, can also be represented using a URI. 
http://example.com/posts/1 represents the first Post resource in the 
posts collection.

State:
This is the current state of the resources.

Transfer (or more precisely State Transfer):
The act of modifying the current state of the resources. Adding a new 
one, modifying an existing one, deleting an existing one, etc.

REST defines a convention of using HTTP to both represent and change the 
state of resources. That's a close as I can come to defining 
"Representational State Transfer."

Hope that helps.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: git push doen't change my live application

2009-04-27 Thread Freddy Andersen

BTW here is the Capistrano group http://groups.google.com/group/capistrano

On Apr 27, 1:16 pm, Freddy Andersen  wrote:
> When you say git push? Do you mean an actual git push, or are we
> talking cap deploy ?
>
> If its cap deploy you need to make sure that your application has
> restarted. What application server is it that you are using? Thin,
> Mongrel, Apache?
>
> On Apr 27, 12:40 pm, "zelop...@gmail.com"  wrote:
>
>
>
> > I am using dreamhost. All I i want to do is make changes on my
> > application and push them live. Yes I am using capistrano with git.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: git push doen't change my live application

2009-04-27 Thread Freddy Andersen

When you say git push? Do you mean an actual git push, or are we
talking cap deploy ?

If its cap deploy you need to make sure that your application has
restarted. What application server is it that you are using? Thin,
Mongrel, Apache?

On Apr 27, 12:40 pm, "zelop...@gmail.com"  wrote:
> I am using dreamhost. All I i want to do is make changes on my
> application and push them live. Yes I am using capistrano with git.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 Instance Variables

2009-04-27 Thread Colin Law
I am having difficulty imagining why you would want an instance variable of
a controller that is not associated with an action, what else do controllers
do?  Are you sure it is not an instance variable of a model that you should
be using?
Colin

2009/4/27 djolley 

>
> > Rails does some magic to make that happen. Here is a blog post that
> > explains the basics of how this happens:
> >
> > http://www.neeraj.name/blog/articles/719-how-controller-and-view-shar...
>
> Thanks.  The blog post explains the magic that Rails uses to make the
> instance variables contained in an action visible in the view
> associated with that action.  I just need to figure out how I can set
> a value in a controller and make that value available to all of the
> views in that controller.
>
>  Thanks again.
>
>  ... doug
> >
>

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



[Rails] What is 'Representational State Transfer'?

2009-04-27 Thread Amita Bhatkhande

I have read about REST, but never really understood meaning of
'Representational State Transfer'. I tried to read Fielding's
dissertation, but did not understand this term and why has he used it.
What does it mean? Which state? What transfer?

Thanks,
Amita.
-- 
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 Instance Variables

2009-04-27 Thread djolley

> Rails does some magic to make that happen. Here is a blog post that
> explains the basics of how this happens:
>
> http://www.neeraj.name/blog/articles/719-how-controller-and-view-shar...

Thanks.  The blog post explains the magic that Rails uses to make the
instance variables contained in an action visible in the view
associated with that action.  I just need to figure out how I can set
a value in a controller and make that value available to all of the
views in that controller.

 Thanks again.

  ... doug
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: git push doen't change my live application

2009-04-27 Thread zelop...@gmail.com

I am using dreamhost. All I i want to do is make changes on my
application and push them live. Yes I am using capistrano with git.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: What is the sequential steps of installing RoR?

2009-04-27 Thread Robert Walker

Sazima wrote:
> Sheru,
> 
> Forget about Win, go for Linux over a virtual machine, for example
> Ubuntu running on Sun xVM VirtualBox. It's way easier, faster, better!
> 
> Cheers, Sazima

+1  Go Linux/UNIX and experience all the Ruby on Rails goodness without 
the hassle.
-- 
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: Submit form through GET requets

2009-04-27 Thread 7stud --

Cisco Ri wrote:
>>
>> Completely bypassing the form would be 
>> nice.
>> 

Did you try this:


> Here's something that worked for me:
> 
> 1) Create a new controller and action that the user will enter as the 
> url:
> 
> $ ruby script/generate controller direct entry
> 
> That creates a controller called DirectController with one action(=a 
> method) called entry.  Open up app/controllers/direct_controller.rb and 
> you will see this:
> 
> class DirectController < ApplicationController
>   def entry
>   end
> 
> end
> 
> 
> The name/value pairs in the url after the ? will be inserted into a 
> "params" hash, which you can access.  With the information in params, 
> you can create a new Link object like this:
> 
> Link.create("url" => params[:url])
> 
> (that assumes the links table has only one field: url)
> 
> Apparently when you assign a Link object to the variable @link, rails 
> will create a record in the database corresponding to the values in the 
> Link object.  If you look at the create method in the file 
> LinksController.rb, that is what the create method does.  This is what I 
> came up with:
> 
> @link = Link.create("url" => params[:url])
> 
> Add that line to the entry method:
> 
> class DirectController < ApplicationController
>   def entry
> @link = Link.create("url" => params[:url])
>   end
> end
> 
> Then when you enter the url:
> 
> http://localhost:3000/direct/entry?url=www.someurl.com
> 
> that will access the DirectController and call its entry method.  The 
> entry method then creates a new Link object.  Then rails enters a record 
> in the links table corresponding to the information in the Link object.



>>I'm not sure that I follow you. 

If you create a Link object, then call .save on it, the information in 
the Link object will be automatically inserted in the links table. 
There are two ways to create and save a Link object:

1)
mylink = Link.new
mylink.url = "some url"
mylink.save

You create the Link object, then you set the field names--as found in 
the links table--e.g. 'url', to the desired values.

2)  Link.create(info)

where info is a hash containing the information, e.g.:

{"field1" => val1, "field2" => val2}

In your case, I'm assuming your links table has one field named url, so 
you could create a new record in the table by writing:

Link.create("info" => "some url")

An action is called with a url.  The part after the ? in the url gets 
entered into the rail's params hash, which you can access inside the 
action.  For instance, if you enter the following url in your browser's 
address bar:

http://localhost:3000/direct/entry?url=www.someurl.com

that will call the entry method in the DirectController.  Inside the 
entry method, params[:url] will be equal to "www.someurl.com".  How 
would you enter that url in the table?  You can that url in the links 
table by writing the following inside the entry method:

Link.create("info" => params[:url])

or equivalently:

mylink = Link.new
mylink.url = params[:url]
mylink.save




-- 
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 Instance Variables

2009-04-27 Thread Robert Walker

7stud -- wrote:
> Doug Jolley wrote:
> Perhaps a more basic question is: why is the template able to access the 
> private variables in the controller at all?  In other words, if you 
> define a ruby class like this:

Rails does some magic to make that happen. Here is a blog post that 
explains the basics of how this happens:

http://www.neeraj.name/blog/articles/719-how-controller-and-view-share-instance-variables

> then all the other methods in class A can access @var, but an object of 
> class B cannot access @var.  I think a template is over in class B 
> somewhere.

Yes, you are correct about this in the general case, but as you can see 
above Rails performs some additional work to simplify template 
development by coping ivars from the controller into the views.

>> (2) Is there some way
>> (other than using a global variable) that I can set a variable in a
>> controller and have its value available to all templates associated
>> with that controller?
>> 
> 
> Sessions?

I would think avoiding global variable would be a very smart thing to 
do. Session variables might be what you want. It really all depends on 
what you're trying to do. Generally speaking if you find yourself 
fighting against Rails you've probably got a design problem. Of course, 
there's exceptions to every rule.
-- 
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 Instance Variables

2009-04-27 Thread 7stud --

Doug Jolley wrote:
> Values of instance variables set within an action of a controller are
> available in the template associated with that action.  I was thinking
> (hoping?) that the values of instance variables set within a
> controller but outside of any action would be universally available to
> all the templates associated with that controller.  Apparently that is
> not the case.  Two questions:  (1) Why is that? 

Perhaps a more basic question is: why is the template able to access the 
private variables in the controller at all?  In other words, if you 
define a ruby class like this:

class A
  def initialize
  @var = 10
  end
end


then all the other methods in class A can access @var, but an object of 
class B cannot access @var.  I think a template is over in class B 
somewhere.



> (2) Is there some way
> (other than using a global variable) that I can set a variable in a
> controller and have its value available to all templates associated
> with that controller?
> 

Sessions?

-- 
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: Renaming a file inside a zip

2009-04-27 Thread Franco Catena

There is no method to directly rename a directory, you must use the
rename in every file between the directory like this:

Zip::ZipFile.open('my.zip') do |zipfile|
  zipfile.file.rename 'original_dir/orignal_name.txt', 'new_dir/
original_name.txt'
end

And after that you can remove the original directory.

Regards.

Franco Catena.

On Apr 27, 2:00 pm, elioncho  wrote:
> I copied a wrong code, here it is. As I say before it only works for
> renaming the file not the folder.
>
>     Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
>       parent_folder = zf.get_entry('Test/')
>       file = zf.get_entry('Test/build.yml')
>       parent_folder.name = 'Testing/'
>       file.name = 'Test/builder.yml'
>     }
>
> On Apr 27, 11:58 am, elioncho  wrote:
>
> > Hi Franco,
>
> > Thanks for your reply, but still it ain't working for. I need to
> > rename a folder not a file. It works fine for file but not for
> > folders. I tried this and it correctly renamed the file build.yml to
> > builder.yml, BUT the folder wasn't rename, instead it created a new
> > folder in the same level of the one I wanted to rename. Any clues?
>
> >     Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
> >       parent_folder = zf.get_entry('Test/')
> >       file = zf.get_entry('Prueba/build.yml')
> >       parent_folder.name = 'Prueba/testing/'
> >       file.name = 'Prueba/builder.yml'
> >     }
>
> > On Apr 27, 11:39 am, Franco Catena  wrote:
>
> > > You must require 'zip/zipfilesystem' and
>
> > > Zip::ZipFile.open('my.zip') do |zipfile|
> > >   zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
> > > end
>
> > > And this is it, for more information see the Zip::ZipFileSystem class
> > > documentation.
>
> > > Regards.
>
> > > Franco Catena.
>
> > > On Apr 27, 12:12 pm, elioncho  wrote:
>
> > > > Hello,
>
> > > > Can anyone help me or give me any clue on how to rename a file (or
> > > > folder) inside a zip file without having to unzip it first. I'm trying
> > > > to do this using the rubyzip gem without luck.
>
> > > > 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] Re: downgrade ruby from 1.8.7 to 1.8.6 under debian

2009-04-27 Thread Neal Harmon

ChangleWEi, Thank you for taking time to post this. Solved all kinds of
problems for me.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] how to get acts_as_versioned able to delete only selected version

2009-04-27 Thread oz4...@gmail.com

Hello everyone

i'm working on uploading file by using attachment_fu and
acts_as_versioned


so the problem is i can't delete only selected version


for example ;

i have file a.txt  and this file have 5 version each version is
viewable ( that mean you can view version 1 , version 2 , version
3 .. )

a.txt ( version1 )
a.txt ( version2)
a.txt ( version3 )
a.txt ( version 4)
a.txt (version 5 )  < latest version

and i would like to delete ONLY version 3  so the result after delete
should be like this

a.txt ( version 1)
a.txt ( version 2 )
a.txt ( version 4)
a.txt (version 5 )  < latest version

and if user choose delete version 5 , the result after delete should
be like this

a.txt  (version 1)
a.txt ( version 2)
a.txt (version 4)  < latest version

any suggestion ?

ps. sorry about my english

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

2009-04-27 Thread Frederick Cheung


On 27 Apr 2009, at 17:23, doug wrote:

>
> Values of instance variables set within an action of a controller are
> available in the template associated with that action.  I was thinking
> (hoping?) that the values of instance variables set within a
> controller but outside of any action would be universally available to
> all the templates associated with that controller.  Apparently that is
> not the case.  Two questions:  (1) Why is that? (2) Is there some way
> (other than using a global variable) that I can set a variable in a
> controller and have its value available to all templates associated
> with that controller?
>
it might clear things up if you pastied what you've been trying.

Fred
> Thanks for any input.
>
>... doug
> >


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

2009-04-27 Thread LaughingNinja

What do you recommend for reports using Rub?. I looked into ruport and
it seems very clunky and from what I read is dying.


On Apr 27, 7:00 am, InventoryTrackers 
wrote:
> Tushar,
> I spent about a month trying to get iReport and JasperReports working
> with Rails and it is just a ridiculous fit.
> Firstly, I identified ONE PERSON who had actually got this working in
> Helena Montana and he strongly cautioned me to avoid this approach at
> all costs.
>
> Secondly, in the reports I developed I found that only simply one
> level reports are possible. If you are not using JDBC you can only
> access the simplest data structures.
>
> The person who wrote the "Rails with JasperReports" never really got
> it to work in the first place.
>
> The guy who wrote iReports has moved onto greener pastures and the
> company that promotes it is hoping that someone believes their claims
> and becomes so stuck in a mess that they hire them for consulting.
>
> DANGER...don't go there.
> David
>
> On Apr 27, 1:57 am, Tushar Gandhi 
> wrote:
>
> > Hi,
> > I am trying to create a pdf using ruby jasper.
> > For this I  am referring  this url:-
>
> >http://oldwiki.rubyonrails.org/rails/pages/howtointegratejasperreports
>
> > I have done everything whatever is in that link.
> > Still I am not able to get the pdf. I am not getting any error in log
> > file. My log file is:-
> > "Processing AccountController#customer_report (for 127.0.0.1 at
> > 2009-04-27 13:19:34) [GET]
> >    [4;36;1mSQL (0.0ms) [0m    [0;1mSET NAMES 'utf8' [0m
> >    [4;35;1mSQL (0.0ms) [0m    [0mSET SQL_AUTO_IS_NULL=0 [0m
> >    [4;36;1mCustomer Load (0.0ms) [0m    [0;1mSELECT * FROM `customers`
> >  [0m
> > Rendering account/customer_list
> >    [4;35;1mCustomer Columns (0.0ms) [0m    [0mSHOW FIELDS FROM
> > `customers` [0m
> > Rendering account/customer_list
> > Sending data CustomerReport.pdf
> > Completed in 422ms (View: 0, DB: 0) | 200 OK
> > [http://localhost/account/customer_report]";
>
> > But I am getting an error in "XmlJasperInterface.log" like this
>
> > "java.io.EOFException
> >   at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
> >   at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown
> > Source)
> >   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
> >   at java.io.ObjectInputStream.(Unknown Source)
> >   at
> > net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
> >   at
> > net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager. 
> > java:342)
> >   at XmlJasperInterface.report(XmlJasperInterface.java:74)
> >   at XmlJasperInterface.main(XmlJasperInterface.java:58)
>
> > NESTED BY :
> > net.sf.jasperreports.engine.JRException: Error loading object from file
> > : E:\Rails2.2\ruby_jasper\app\reports\custrep.jasper
> >   at
> > net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:89)
> >   at
> > net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager. 
> > java:342)
> >   at XmlJasperInterface.report(XmlJasperInterface.java:74)
> >   at XmlJasperInterface.main(XmlJasperInterface.java:58)
> > Caused by: java.io.EOFException
> >   at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
> >   at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown
> > Source)
> >   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
> >   at java.io.ObjectInputStream.(Unknown Source)
> >   at
> > net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
> >   ... 3 more
> > "
> > Is there anyone faced this issue before?
>
> > Any help is appreciated.
>
> > Thanks,
> > Tushar
> > --
> > 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: routes, controllers, and intentions

2009-04-27 Thread Ar Chron

With default routing in place, it would seem to me to be something on 
the order of the following, given courses, students, and rosters:

course
   has_many rosters
   has_many students through rosters

student
  has_many rosters
  has_many courses through rosters

roster
  belongs_to course
  belongs_to student

-
You need to pass the course_id to the roster in a param, like:

http://localhost:3000/rosters?course_id=1

which would allow a roster to determine which course it was for, and 
retrieve all the appropriate students.

def show
   @rosters = Roster.find(:all, :conditions => ['course_id = ?', 
params[:course_id]])
end

There are many other ways to organize and get at this information, such 
as a partial for the course 'show' form, like 
'_course_students.html.erb', which could just loop through the 
@course.students collection to display the list of students.
-- 
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: Renaming a file inside a zip

2009-04-27 Thread elioncho

I copied a wrong code, here it is. As I say before it only works for
renaming the file not the folder.

Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
  parent_folder = zf.get_entry('Test/')
  file = zf.get_entry('Test/build.yml')
  parent_folder.name = 'Testing/'
  file.name = 'Test/builder.yml'
}


On Apr 27, 11:58 am, elioncho  wrote:
> Hi Franco,
>
> Thanks for your reply, but still it ain't working for. I need to
> rename a folder not a file. It works fine for file but not for
> folders. I tried this and it correctly renamed the file build.yml to
> builder.yml, BUT the folder wasn't rename, instead it created a new
> folder in the same level of the one I wanted to rename. Any clues?
>
>     Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
>       parent_folder = zf.get_entry('Test/')
>       file = zf.get_entry('Prueba/build.yml')
>       parent_folder.name = 'Prueba/testing/'
>       file.name = 'Prueba/builder.yml'
>     }
>
> On Apr 27, 11:39 am, Franco Catena  wrote:
>
> > You must require 'zip/zipfilesystem' and
>
> > Zip::ZipFile.open('my.zip') do |zipfile|
> >   zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
> > end
>
> > And this is it, for more information see the Zip::ZipFileSystem class
> > documentation.
>
> > Regards.
>
> > Franco Catena.
>
> > On Apr 27, 12:12 pm, elioncho  wrote:
>
> > > Hello,
>
> > > Can anyone help me or give me any clue on how to rename a file (or
> > > folder) inside a zip file without having to unzip it first. I'm trying
> > > to do this using the rubyzip gem without luck.
>
> > > 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] Re: Renaming a file inside a zip

2009-04-27 Thread elioncho

Hi Franco,

Thanks for your reply, but still it ain't working for. I need to
rename a folder not a file. It works fine for file but not for
folders. I tried this and it correctly renamed the file build.yml to
builder.yml, BUT the folder wasn't rename, instead it created a new
folder in the same level of the one I wanted to rename. Any clues?

Zip::ZipFile.open('/home/elioncho/Desktop/MyApp.zip'){|zf|
  parent_folder = zf.get_entry('Test/')
  file = zf.get_entry('Prueba/build.yml')
  parent_folder.name = 'Prueba/testing/'
  file.name = 'Prueba/builder.yml'
}

On Apr 27, 11:39 am, Franco Catena  wrote:
> You must require 'zip/zipfilesystem' and
>
> Zip::ZipFile.open('my.zip') do |zipfile|
>   zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
> end
>
> And this is it, for more information see the Zip::ZipFileSystem class
> documentation.
>
> Regards.
>
> Franco Catena.
>
> On Apr 27, 12:12 pm, elioncho  wrote:
>
> > Hello,
>
> > Can anyone help me or give me any clue on how to rename a file (or
> > folder) inside a zip file without having to unzip it first. I'm trying
> > to do this using the rubyzip gem without luck.
>
> > 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] how to get acts_as_versioned able to delete only selected ve

2009-04-27 Thread Preeda Payattakool

Hello everyone

i'm working on uploading file by using attachment_fu and
acts_as_versioned


so the problem is i can't delete only selected version


for example ;

i have file a.txt  and this file have 5 version each version is viewable
( that mean you can view version 1 , version 2 , version 3
.. )

a.txt ( version1 )
a.txt ( version2)
a.txt ( version3 )
a.txt ( version 4)
a.txt (version 5 )  < latest version

and i would like to delete ONLY version 3  so the result after delete
should be like this

a.txt ( version 1)
a.txt ( version 2 )
a.txt ( version 4)
a.txt (version 5 )  < latest version

and if user choose delete version 5 , the result after delete should be
like this

a.txt  (version 1)
a.txt ( version 2)
a.txt (version 4)  < latest version

any suggestion ?

ps. sorry about my english
-- 
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: Renaming a file inside a zip

2009-04-27 Thread Franco Catena

You must require 'zip/zipfilesystem' and

Zip::ZipFile.open('my.zip') do |zipfile|
  zipfile.file.rename 'orignal_name.txt', 'new_name.txt'
end

And this is it, for more information see the Zip::ZipFileSystem class
documentation.

Regards.

Franco Catena.

On Apr 27, 12:12 pm, elioncho  wrote:
> Hello,
>
> Can anyone help me or give me any clue on how to rename a file (or
> folder) inside a zip file without having to unzip it first. I'm trying
> to do this using the rubyzip gem without luck.
>
> 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] Controller Instance Variables

2009-04-27 Thread doug

Values of instance variables set within an action of a controller are
available in the template associated with that action.  I was thinking
(hoping?) that the values of instance variables set within a
controller but outside of any action would be universally available to
all the templates associated with that controller.  Apparently that is
not the case.  Two questions:  (1) Why is that? (2) Is there some way
(other than using a global variable) that I can set a variable in a
controller and have its value available to all templates associated
with that controller?

Thanks for any input.

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

2009-04-27 Thread Vapor ..

Colin Law wrote:
> Do you need /abc.:format in routes.rb for this?

Great, 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: Serving formats at named route?

2009-04-27 Thread Colin Law
Do you need /abc.:format in routes.rb for this?

2009/4/27 Vapor .. 

>
> I am using a named route, like /abc.
> I have put...
>
> respond_to do |format|
> format.html
> format.json (render :json => @variable)
> end
>
> in method.
>
> But when I do /abc.json, it doesn't work.
> Any hints?
> 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] Serving formats at named route?

2009-04-27 Thread Vapor ..

I am using a named route, like /abc.
I have put...

respond_to do |format|
format.html
format.json (render :json => @variable)
end

in method.

But when I do /abc.json, it doesn't work.
Any hints?
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: Legacy encryption function...

2009-04-27 Thread Alex

Works. Thank you for your help!

On Apr 27, 11:23 am, Frederick Cheung 
wrote:
> On Apr 27, 4:02 pm, Alex  wrote:
>
>
>
>
>
> > Hello everyone, I have an old Java authentication web service that I
> > must use in my rails development. The service takes a username and an
> > encrypted password. I'm having trouble reproducing the same encryption
> > algorithm.
>
> > Here is the Java encryption function:
> >   public static String digest(String text)
> >   {
> >     MessageDigest mDigest = null;
> >     try
> >     {
> >       mDigest = MessageDigest.getInstance("SHA");
>
> >       mDigest.update(text.toUpperCase().getBytes("UTF-8"));
> >     } catch (NoSuchAlgorithmException nsae) {
> >       nsae.printStackTrace();
> >     } catch (UnsupportedEncodingException uee) {
> >       uee.printStackTrace();
> >     }
> >     byte[] raw = mDigest.digest();
> >     return new BASE64Encoder().encode(raw);
> >   }
>
> > Here is the Ruby encryption function:
> > ...
> > require 'digest/sha1'
> > Base64.encode64(Digest::SHA1.hexdigest('ruby'))
>
> this outputs the digest as hex (before base64ing it), ie a string
> containing the characters "0" through "9", "A" through "F", whereas
> your java code outputs the raw data, ie if the first 2 bytes of the
> digest were 53 the ruby code would output
>
> 53
>
> but the java code would output
>
> S (the ascii code for S is 53).
>
> Digest::SHA1.digest('ruby') would be the same behaviour as your java
> code (don't forget to convert the text to upper case)
>
> Fred.
>
> Fred
>
>
>
> > ...
>
> > Now here is the resulting String calling the Java function with the
> > string 'ruby':
> > "oJtN1kHfQdCCLFN7ATWgAxIH6bc="
>
> > Here is what I get with my Ruby function for the same string:
> > "MThlNDBlMTQwMWVlZjY3ZTFhZTY5ZWZhYjA5YWZiNzFmODdmZmI4MQ==\n"
>
> > So, anybody knows what I'm doing wrong?- Hide quoted text -
>
> - Show quoted text -- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Legacy encryption function...

2009-04-27 Thread Frederick Cheung



On Apr 27, 4:02 pm, Alex  wrote:
> Hello everyone, I have an old Java authentication web service that I
> must use in my rails development. The service takes a username and an
> encrypted password. I'm having trouble reproducing the same encryption
> algorithm.
>
> Here is the Java encryption function:
>   public static String digest(String text)
>   {
>     MessageDigest mDigest = null;
>     try
>     {
>       mDigest = MessageDigest.getInstance("SHA");
>
>       mDigest.update(text.toUpperCase().getBytes("UTF-8"));
>     } catch (NoSuchAlgorithmException nsae) {
>       nsae.printStackTrace();
>     } catch (UnsupportedEncodingException uee) {
>       uee.printStackTrace();
>     }
>     byte[] raw = mDigest.digest();
>     return new BASE64Encoder().encode(raw);
>   }
>
> Here is the Ruby encryption function:
> ...
> require 'digest/sha1'
> Base64.encode64(Digest::SHA1.hexdigest('ruby'))

this outputs the digest as hex (before base64ing it), ie a string
containing the characters "0" through "9", "A" through "F", whereas
your java code outputs the raw data, ie if the first 2 bytes of the
digest were 53 the ruby code would output

53

but the java code would output

S (the ascii code for S is 53).

Digest::SHA1.digest('ruby') would be the same behaviour as your java
code (don't forget to convert the text to upper case)

Fred.


Fred


> ...
>
> Now here is the resulting String calling the Java function with the
> string 'ruby':
> "oJtN1kHfQdCCLFN7ATWgAxIH6bc="
>
> Here is what I get with my Ruby function for the same string:
> "MThlNDBlMTQwMWVlZjY3ZTFhZTY5ZWZhYjA5YWZiNzFmODdmZmI4MQ==\n"
>
> So, anybody knows what I'm doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Renaming a file inside a zip

2009-04-27 Thread elioncho

Hello,

Can anyone help me or give me any clue on how to rename a file (or
folder) inside a zip file without having to unzip it first. I'm trying
to do this using the rubyzip gem without luck.

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] Legacy encryption function...

2009-04-27 Thread Alex

Hello everyone, I have an old Java authentication web service that I
must use in my rails development. The service takes a username and an
encrypted password. I'm having trouble reproducing the same encryption
algorithm.

Here is the Java encryption function:
  public static String digest(String text)
  {
MessageDigest mDigest = null;
try
{
  mDigest = MessageDigest.getInstance("SHA");

  mDigest.update(text.toUpperCase().getBytes("UTF-8"));
} catch (NoSuchAlgorithmException nsae) {
  nsae.printStackTrace();
} catch (UnsupportedEncodingException uee) {
  uee.printStackTrace();
}
byte[] raw = mDigest.digest();
return new BASE64Encoder().encode(raw);
  }

Here is the Ruby encryption function:
...
require 'digest/sha1'
Base64.encode64(Digest::SHA1.hexdigest('ruby'))
...

Now here is the resulting String calling the Java function with the
string 'ruby':
"oJtN1kHfQdCCLFN7ATWgAxIH6bc="

Here is what I get with my Ruby function for the same string:
"MThlNDBlMTQwMWVlZjY3ZTFhZTY5ZWZhYjA5YWZiNzFmODdmZmI4MQ==\n"

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



[Rails] Creating & Validating w/ has_many :through

2009-04-27 Thread Eric Milford

I don't have a full grasp on has_many :through associations.  I've
detailed my models below and am trying to figure out how to do the
following in the proper manner.

1. Add the selected software (only one selectable) to the current
ticket.  I have @ticket.software << @software working just fine.
2. Validate that A) 1 or more systems have been selected, B) A
:software_status has been selected.  I'm not sure where these
validations should go.
3. Create the software to system association (w/ sofware_status value)
through the join model
4. How to setup the new/edit form to manage all of this.

Thanks in advance.

Ticket.rb

has_and_belongs_to_many :software

Software.rb

has_many :system_software
has_many :systems, :through => :system_software

System.rb

has_many :system_software
has_many :software, :through => :system_software

SystemSoftware.rb

belongs_to :system
belongs_to :software
belongs_to :software_status

SoftwareStatus.rb

has_many :system_software
-- 
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] Adding and validating with has_many :through

2009-04-27 Thread ericindc

I don't have a full grasp on has_many :through associations.  I've
detailed my models below and am trying to figure out how to do the
following in the proper manner.

1. Add the selected software (only one selectable) to the current
ticket.  I have @ticket.software << @software working just fine.
2. Validate that A) 1 or more systems have been selected, B)
A :software_status has been selected.  I'm not sure where these
validations should go.
3. Create the software to system association (w/ sofware_status value)
through the join model
4. How to setup the new/edit form to manage all of this.

Thanks in advance.

Ticket.rb

has_and_belongs_to_many :software

Software.rb

has_many :system_software
has_many :systems, :through => :system_software

System.rb

has_many :system_software
has_many :software, :through => :system_software

SystemSoftware.rb

belongs_to :system
belongs_to :software
belongs_to :software_status

SoftwareStatus.rb

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

2009-04-27 Thread Colin Law
Possibly you could do it by changing the secret on starting the server up
rather than when killing it off.
Colin

2009/4/27 vimal 

>
> I have tried it before and got the same as you said.
>
> >You can
> >invalidate it by changing your session's secret (make sure you deal
> >with the exception that gets raised in those cases if you don't want
> >to confuse your users). Pretty much a manual process which ever store
> >you use.
>
> Anyway the above suggested solution is only possible if Ctrl-c
> interrupt is trapped
> and then routed to the proceedure
>
> Regards,
> Vimal Das
> >
>

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

2009-04-27 Thread Tim Lowrimore
You'll probably want to have a look at this:
http://github.com/alloy/complex-form-examples/tree/master

The code is fairly straight-forward, and it was written by the guy who
introduced the new accepts_nested_attributes_for functionality into rails.

Cheers,
Tim

On Mon, Apr 27, 2009 at 6:43 AM, DVG  wrote:

>
> Does anyone have a link to a good, modern, tutorial on using forms
> other than the form_for helper? Basically, I'm looking for a good How
> To on setting up a Ajax form that sits at the bottom of a list members
> of a group for adding new users to that group.
> >
>


-- 
Tim Lowrimore
Coroutine LLC
2034 Harbert Ave.
Memphis, TN 38104
901.490.5325
http://www.coroutine.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: Find eager loads correct records but generates excess queries (Rails 2.1)

2009-04-27 Thread Frederick Cheung



On Apr 27, 3:18 pm, davidy  wrote:
> Models:
>   S :has_many F; F :belongs_to P; S :has_many P :through F.
>
> Query looks like this:
>   S.find_all_by_key([array of keys], :include => [:F, :P])
>
> This produces the correct and expected result, but very slowly. On the
> log:
> SELECT * FROM S WHERE KEY IN (keys)
> SELECT * FROM F WHERE S_ID IN (S.ids from first query)
> SELECT * FROM F WHERE S_ID IN (S.ids from first query) [same query
> twice]
> SELECT * FROM P WHERE ID IN (ids from second query)
>
> At this point all the required data has been retrieved and Rails is
> looking good. Time to quit. However:
> SELECT * FROM P WHERE ID = first id from second query
> SELECT * FROM P WHERE ID = second id from second query
> ... [typically about 50-200 queries, one query per P.ID]

That's odd. is that from your eager loading or from your subsequent
use of the data ( also anonymising the table names to S, F, P makes it
rather hard to read than if there were meaningful names) (in
particular eager loading is unidirectional - if person has_many posts,
then Person.find(:all, :include => :posts) doesn't eager load
post.person

Fred
>
> Q1. Why so many extraneous queries?
> Q2. Is there an easy fix, or is this just too hard for Rails?
> Q3. In general, is it possible to control eager loading at a per-query
> level?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 do I properly create a menu with optgroup labels?

2009-04-27 Thread Jim Burgess

In case this helps anyone else, I now have:

form_controller.rb:

def index
@members_group =
[
["Molecular Neuroscience", [["Prof. Dr. Denise Manahan-Vaughan", "1"], 
["Prof. Dr. Lutz Pott", "2"]]],
["Developmental Neuroscience", [["Prof. Dr. Petra Wahle", "3"], ["Prof. 
Dr. Andreas Faissner", "4"], ["Dr. Alexander von Holst", "5"]]],
["Systems Neuroscience", [["Prof. Dr. Dr. Hanns Hatt", "6"], ["Prof. Dr. 
Klemens Stoertkuhl", "7"]]],
["Cognitive Neuroscience", [["Prof. Dr. Dr. h.c. Onur Guentuerkuen", 
"8"], ["Prof. Dr. Irene Daum", "9"], ["Prof. Dr. Oliver T. Wolf", 
"10"]]],
["Clinical Neuroscience", [["Prof. Dr. Martin Tegenthoff", "11"]]],
["Computational  Neuroscience", [["Prof. Dr. Gregor Schoener", "12"], 
["Jun. Prof. Dr. Christian Igel", "13"], ["Dr. Rolf Wuertz", "14"]]],
]

@applicant = Applicant.new(params[:applicant])
if(request.post? and @applicant.save)
  @name = "public/pdfs/#...@applicant.last_name}.pdf"
  redirect_to :action => "success"
else
  @member_1 = @applicant.member_1
  render :action=> "index"
end
end

In form.html.erb:
...
<%= select_tag "applicant[member_1]", 
grouped_options_for_select(@members_group, selected_key = @member_1, 
prompt = " ") %>

This works perfectly.

-- 
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] Find eager loads correct records but generates excess queries (Rails 2.1)

2009-04-27 Thread davidy

Models:
  S :has_many F; F :belongs_to P; S :has_many P :through F.

Query looks like this:
  S.find_all_by_key([array of keys], :include => [:F, :P])

This produces the correct and expected result, but very slowly. On the
log:
SELECT * FROM S WHERE KEY IN (keys)
SELECT * FROM F WHERE S_ID IN (S.ids from first query)
SELECT * FROM F WHERE S_ID IN (S.ids from first query) [same query
twice]
SELECT * FROM P WHERE ID IN (ids from second query)

At this point all the required data has been retrieved and Rails is
looking good. Time to quit. However:
SELECT * FROM P WHERE ID = first id from second query
SELECT * FROM P WHERE ID = second id from second query
... [typically about 50-200 queries, one query per P.ID]

Q1. Why so many extraneous queries?
Q2. Is there an easy fix, or is this just too hard for Rails?
Q3. In general, is it possible to control eager loading at a per-query
level?

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

2009-04-27 Thread Robert Anderson
I said start here, no finish here :)

--
Robert Anderson Nogueira de Oliveira
_
Tribunal de Justiça do Estado de Sergipe
Graduando em Sistemas de Informação - UNIT
MSN: ranophoe...@hotmail.com

"Ausência de evidência não é evidência de ausência." (Carl Sagan)



On Mon, Apr 27, 2009 at 11:04 AM, Jarl Friis  wrote:

>
> Robert Anderson  writes:
>
> > 1.  (*) text/plain  ( ) text/html
> >
> > Start here:
> >
> > http://en.wikipedia.org/wiki/A*_search_algorithm
>
> This algorithm finds shortest path from initial node to goal node. TSP
> (Traveling SalesMan) is aobut visiting all nodes in a graph.
>
> Solving the TSP problem is not one of these problems for which there
> eists a well known best algorithm. It belongs to the class NP [1],
> well actuall it is known to be NPC [2], but you have read the section
> regarding "Solving NP-complete problems" I suggest you read something
> about branch-and-bound algorithms[3], and eventually use the A* search
> algorithm as part of your BnB implementation.
>
> Jarl
>
>
> Footnotes:
> [1]  
> http://en.wikipedia.org/wiki/NP_(complexity)
>
> [2]  http://en.wikipedia.org/wiki/NP-complete
>
> [3]  http://en.wikipedia.org/wiki/Branch_and_bound
>
>
>
> >
>

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

2009-04-27 Thread Jarl Friis

Robert Anderson  writes:

> 1.  (*) text/plain  ( ) text/html   
>
> Start here:
>
> http://en.wikipedia.org/wiki/A*_search_algorithm

This algorithm finds shortest path from initial node to goal node. TSP
(Traveling SalesMan) is aobut visiting all nodes in a graph.

Solving the TSP problem is not one of these problems for which there
eists a well known best algorithm. It belongs to the class NP [1],
well actuall it is known to be NPC [2], but you have read the section
regarding "Solving NP-complete problems" I suggest you read something
about branch-and-bound algorithms[3], and eventually use the A* search
algorithm as part of your BnB implementation.

Jarl


Footnotes: 
[1]  http://en.wikipedia.org/wiki/NP_(complexity)

[2]  http://en.wikipedia.org/wiki/NP-complete

[3]  http://en.wikipedia.org/wiki/Branch_and_bound



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

2009-04-27 Thread InventoryTrackers

Tushar,
I spent about a month trying to get iReport and JasperReports working
with Rails and it is just a ridiculous fit.
Firstly, I identified ONE PERSON who had actually got this working in
Helena Montana and he strongly cautioned me to avoid this approach at
all costs.

Secondly, in the reports I developed I found that only simply one
level reports are possible. If you are not using JDBC you can only
access the simplest data structures.

The person who wrote the "Rails with JasperReports" never really got
it to work in the first place.

The guy who wrote iReports has moved onto greener pastures and the
company that promotes it is hoping that someone believes their claims
and becomes so stuck in a mess that they hire them for consulting.

DANGER...don't go there.
David

On Apr 27, 1:57 am, Tushar Gandhi 
wrote:
> Hi,
> I am trying to create a pdf using ruby jasper.
> For this I  am referring  this url:-
>
> http://oldwiki.rubyonrails.org/rails/pages/howtointegratejasperreports
>
> I have done everything whatever is in that link.
> Still I am not able to get the pdf. I am not getting any error in log
> file. My log file is:-
> "Processing AccountController#customer_report (for 127.0.0.1 at
> 2009-04-27 13:19:34) [GET]
>    [4;36;1mSQL (0.0ms) [0m    [0;1mSET NAMES 'utf8' [0m
>    [4;35;1mSQL (0.0ms) [0m    [0mSET SQL_AUTO_IS_NULL=0 [0m
>    [4;36;1mCustomer Load (0.0ms) [0m    [0;1mSELECT * FROM `customers`
>  [0m
> Rendering account/customer_list
>    [4;35;1mCustomer Columns (0.0ms) [0m    [0mSHOW FIELDS FROM
> `customers` [0m
> Rendering account/customer_list
> Sending data CustomerReport.pdf
> Completed in 422ms (View: 0, DB: 0) | 200 OK
> [http://localhost/account/customer_report]";
>
> But I am getting an error in "XmlJasperInterface.log" like this
>
> "java.io.EOFException
>   at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
>   at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown
> Source)
>   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
>   at java.io.ObjectInputStream.(Unknown Source)
>   at
> net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
>   at
> net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:342)
>   at XmlJasperInterface.report(XmlJasperInterface.java:74)
>   at XmlJasperInterface.main(XmlJasperInterface.java:58)
>
> NESTED BY :
> net.sf.jasperreports.engine.JRException: Error loading object from file
> : E:\Rails2.2\ruby_jasper\app\reports\custrep.jasper
>   at
> net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:89)
>   at
> net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:342)
>   at XmlJasperInterface.report(XmlJasperInterface.java:74)
>   at XmlJasperInterface.main(XmlJasperInterface.java:58)
> Caused by: java.io.EOFException
>   at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
>   at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown
> Source)
>   at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
>   at java.io.ObjectInputStream.(Unknown Source)
>   at
> net.sf.jasperreports.engine.util.JRLoader.loadObject(JRLoader.java:84)
>   ... 3 more
> "
> Is there anyone faced this issue before?
>
> Any help is appreciated.
>
> Thanks,
> Tushar
> --
> 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: How do I properly create a menu with optgroup labels?

2009-04-27 Thread Jim Burgess

> you need to tell grouped_options_for_select what the value of the
> selected option is
> 
> Fred

Wonderful.
I checked the documenttation for grouped_options_for_select again, and 
you are completely right. It's done with the use of selected_key.

The code now reads:
<%= select_tag "applicant[member_3]", 
grouped_options_for_select(@grouped_options, selected_key = "Canada") %>

And works perfectly.

Thanks very much for your help.

P.S. Hopefully I can now give all of the options an ID and pass this 
back in from the controller so it would read "selected_key = @sel_key"


-- 
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 do I properly create a menu with optgroup labels?

2009-04-27 Thread Frederick Cheung



On Apr 27, 2:28 pm, Jim Burgess 
wrote:
> Thanks for that.
> I have now changed the code thus:
>
> <%= select_tag "applicant[member_1]",
> grouped_options_for_select(@grouped_options) %>
>
> and now I can pick up :member_1 in the params.
> Hooray.
>
> One last thing though, when I submit the form the select menu always
> springs back to its initial value (in this case "United States"),
> regardless of what was previously selected.
>
you need to tell grouped_options_for_select what the value of the
selected option is

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] Rails on amazon EC2

2009-04-27 Thread Joshua Partogi

Dear all,

Is there anyone that deploys their Rails apps on amazon EC2? I read
from AWS website that they have Rails on EC2. Can anyone that use
Amazon services share their experience with Rails on EC2?


Thank you very much

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow us on twitter: http://twitter.com/scrum8

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



[Rails] Re: Submit form through GET requets

2009-04-27 Thread Cisco Ri

7stud -- wrote:
> 7stud -- wrote:
>> 7stud -- wrote:
>>> 
>>> Link.create("url" => params[:url])
>>> 
>>> (that assumes the links table has only one field: url)
>>> 
>>> Apparently when you assign a Link object to the variable @link, rails 
>>> will create a record in the database corresponding to the values in the 
>>> Link object.  If you look at the create method in the file 
>>> LinksController.rb, that is what the create method does.  This is what I 
>>> came up with:
>>> 
>>> @link = Link.create("url" => params[:url])
>>> 
>> 
>> After some more testing, I discovered that you don't have to assign the 
>> Link object to @link.  I think that when you create a Model object(e.g. 
>> a Link object) and the Model is hooked up to a database, then as soon as 
>> you create the object, rails inserts a record corresponding to that 
>> object in the table.
> 
> That isn't quite right either.  You have to save an object for rails to 
> enter it into a table:
> 
> mylink = Link.new
> mylink.url = "www.somepage.com"
> mylink.save
> 
> However, rails provides a convenience method, create(), that both 
> instantiates a new object and inserts a record into the table.  create() 
> takes a hash of name/value pairs as an argument, where each name is a 
> field in the table.
> 
> (Or, you can pass create() an array of hashes, where each hash 
> represents one record, and create() will insert multiple records at the 
> same time.)

I'm not sure that I follow you.  Completely bypassing the form would be 
nice.

I changed the new method to:
  def new
@link = Link.create("url" => params[:url])

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @link }
end
  end

and it didn't get written to the database.  When I changed it to:

  def new
@link = Link.new("url" => params[:url])

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @link }
end
  end

it goes to the form page with the correct URL in the textfield.  This 
was actually what I originally wanted, but it would be better to bypass 
the form entirely.

Thanks for the help so far.
-- 
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 do I properly create a menu with optgroup labels?

2009-04-27 Thread Jim Burgess

Thanks for that.
I have now changed the code thus:

<%= select_tag "applicant[member_1]", 
grouped_options_for_select(@grouped_options) %>

and now I can pick up :member_1 in the params.
Hooray.

One last thing though, when I submit the form the select menu always 
springs back to its initial value (in this case "United States"), 
regardless of what was previously selected.

Is there any way to alter this? I tried using :selected => "Canada" for 
example, but that didn't work.

Thanks very much for your help so far.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: What is the sequential steps of installing RoR?

2009-04-27 Thread Sazima

Sheru,

Forget about Win, go for Linux over a virtual machine, for example
Ubuntu running on Sun xVM VirtualBox. It's way easier, faster, better!

Cheers, Sazima

On Apr 26, 3:06 pm, sheru  wrote:
> Hi,
> I am Sheru & am completely new for this web framework. I am really
> really enthusiastic to know the Ruby on Rails & possibly try to use
> this framework near future.
>
> But at the start up, I don't have idea on installing RoR on Windows
> XP.
>
> 1. What is the sequential intalling components of RoR?
> 2. How easily could I get the RoR website hosting server?
>
> Hope that I will get response.
>
> Thank you all.
> Sheru
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Engines VS rails3

2009-04-27 Thread James Adam

On Apr 27, 5:16 am, "rails.n...@gmail.com" 
wrote:
> What is planned for Rails3 that is preferable over Engines?  Would not
> moving to Engines now make it easier to adapt to Rails3 anyway?

I think the idea is that Rails 3 will be more modular and have more
stable APIs for plugging in engine-like functionality. The engines
support in Rails 2.3 (at the moment, at least) is really just the
simplest possible to support an app directory and loading routes.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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: Travel Salesman Problem

2009-04-27 Thread Robert Anderson
Start here:

http://en.wikipedia.org/wiki/A*_search_algorithm

Regards,

--
Robert Anderson Nogueira de Oliveira
_
Tribunal de Justiça do Estado de Sergipe
Graduando em Sistemas de Informação - UNIT
MSN: ranophoe...@hotmail.com

"Ausência de evidência não é evidência de ausência." (Carl Sagan)



On Mon, Apr 27, 2009 at 9:46 AM, Arthur Chan <
rails-mailing-l...@andreas-s.net> wrote:

>
> Hi Guys,
>
> I am going to solve the Travel Salesman problem:
> http://en.wikipedia.org/wiki/Travelling_salesman_problem
>
> I wanna find out the shortest path to visit all cities in my site.
> But... I don't know even where to start for it... (I am able to find out
> any distance between two cities.)
>
> Any clue?
> Arthur
> --
> 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] Travel Salesman Problem

2009-04-27 Thread Arthur Chan

Hi Guys,

I am going to solve the Travel Salesman problem:
http://en.wikipedia.org/wiki/Travelling_salesman_problem

I wanna find out the shortest path to visit all cities in my site.
But... I don't know even where to start for it... (I am able to find out
any distance between two cities.)

Any clue?
Arthur
-- 
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 do I properly create a menu with optgroup labels?

2009-04-27 Thread Frederick Cheung



On Apr 27, 12:17 pm, Jim Burgess 
wrote:
> Hi Fred,
> Well that worked :-)
> I changed
> <%= f.select :member_1
> into
> <%= select_tag :member_1
> and got 100% the desired result.
>
> Only problem is, is that I am using
> <% form_for :applicant, :url=> {:action => "index"} do |f| %>
> to create my form and removing the reference to the applicant object
> ("f"), means that the value for "member_1" does not get passed when I
> submit the form.
>
> Is there any way around this?

You need to specify the right name for select_tag. Easiest way to do
that is to switch back to f.select, look at the html and use the name
it generated for the select tag.

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] Modern Form Tutorials?

2009-04-27 Thread DVG

Does anyone have a link to a good, modern, tutorial on using forms
other than the form_for helper? Basically, I'm looking for a good How
To on setting up a Ajax form that sits at the bottom of a list members
of a group for adding new users to that group.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] routing: Unescape urls

2009-04-27 Thread Eduard Bondarenko

Hello All,

How to make rails unescape incoming urls? I want to use russian chars
in routes, like:

map.city URI.escape("/Карта--:title--:id"), :controller =>
"cities", :action => "show" It seems to works (page loads) but all
links on page looks like this:
http://localhost/%25D0%259A%25D0%25B0%25D1%2580%25D1%2582%25D0%25B0--%D0%9A%D0%B8%D0%B5%D0%B2--30295?page=4

Rails double escapes url?

Also I tried url_for( :escape => false), it doesn't help.

Thanks in advance,
Eduard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send 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 do I properly create a menu with optgroup labels?

2009-04-27 Thread Jim Burgess

Hi Fred,
Well that worked :-)
I changed
<%= f.select :member_1
into
<%= select_tag :member_1
and got 100% the desired result.

Only problem is, is that I am using
<% form_for :applicant, :url=> {:action => "index"} do |f| %>
to create my form and removing the reference to the applicant object 
("f"), means that the value for "member_1" does not get passed when I 
submit the form.

Is there any way around this?
sort of "f.select_tag" (which obviously doesn't work)


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

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



[Rails] Re: Using same user credentials across multiple connected apps

2009-04-27 Thread Frederick Cheung



On Apr 27, 10:03 am, sahil  wrote:
> On Apr 27, 12:37 pm, Frederick Cheung 
> wrote:
>
> > Check that the cookie that contains the session is actually being set
> > under the right domain (and in development you'll need to fakeup some
> > domains eg app1.mydomain.local, app2.mydomain.local).
>
> i checked the cookies on my browser one is set under localhost.com and
> other under blog.localhost.com, i have set these in /etc/hosts.
> Also, :session_domain => ".localhost.com"
>
> But there is one difference between the 2.
> localhost.com has 2 cookies(one of which is named user_credentials),
> while blog.localhost.com has just 1 cookie, whose name is same as the
> 1st cookie under localhost.com

Maybe authlogic sets it own cookies. I'd delve into authlogic and see
how it decides which domain to use for its cookies.

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] ActiveRecord::Errors best practices?

2009-04-27 Thread Joachim Glauche

I'm currently reviewing some old code from Rails 1.x times and found
this:

  ActiveRecord::Errors.default_error_messages = {
:inclusion => "inclusion|",
:exclusion => "exclusion|",
:invalid => "invalid|",
:confirmation => "confirmation|",
:accepted => "accepted|",
:empty => "empty|",
:too_long => "too_long|",
:too_short => "too_short|",
:wrong_length => "wrong_length|",
:taken => "taken|",
:not_a_number => "not_a_number|",
  }

Used on controller code to check if a specific error happens, like this:

if @user.errors.on("email").to_s.include? "taken|"
  ...
end

Are there better practices for doing 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] [Rake] Parse XML File, recursive function

2009-04-27 Thread Mickaël Allain
Hi everybody,

I'm taking time to post message here because, i have a problem which making
me crazy.

I'm trying to design a Rake Task which parse XML file and create some drill
down on products categories.

To begin my explanation, some file and function.

First, my XML file


> 
> Voitures
> 
> Débutant
> 
> 211
> 
> 
> 
> Intermédiaires
> 
> 418
> 
> 
> 
> Dnano
> 
> 769
> 
> 
> 
> Mini Z
> 
> 710
> 
> 
> 
> Mini Z Drift
> 
> 783
> 
> 
> 
> 
> 
> Expérimenté
> 
> 419
> 
> 
> 
> Monster Truck
> 
> 420
> 
> 
> 
> 


Pastie link : http://pastie.org/459107


Second, my main Rake Task

# Affichage d un message
> p '### Creation Fil ariane root'
>
> # Creation du fil d ariane root
> root = Taxonomy.create(
> :name => 'fxmodelrc'
> )
>
> # Creation des categories dites mere (Products)
> categorie_mere_root = Taxon.create(
>   :taxonomy_id => root.id,
>   :name => 'Catégories',
>   :position => 0
> )
>
> # Definition du fichier XML d FXModel
> xml_file = "#{RAILS_ROOT}/lib/tasks/fxmodel/products/menuFXModel.xml"
>
> # Si le fichier xml est present
> if File.exist?(xml_file)
>   # Lecture du fichier XML
>   xml = File.read(xml_file)
>
>   # Parse du fichier XML
>   doc = Hpricot::XML(xml)
>
>   # Recuperation de toutes les categories
>   (doc/:root).each do |categories|
> # Pour chaque categorie
> taxon_menu = Array.new
>
> (categories/:categorie).each_with_index do |categorie, index_menu|
>   # On est dans une categorie (Helicoptere, Voitures, etc...)
>
>   # Preparation variable
>   taxon_sous_menu = Array.new
>
>   # Recuperation du nom de la categorie
>   taxon_menu_name = categorie.at("name").inner_html.to_s
>
>   # Concatenation pour l affichage
>   message = '### Creation Menu ' + taxon_menu_name + ' / '
>
>   # Affichage d un message
>   p message
>
>   # Creation de la categorie mere en cours
>   taxon_menu[index_menu] = Taxon.create(
> :taxonomy_id => root.id,
> :name => taxon_menu_name,
> :parent_id => categorie_mere_root.id,
> :position => index_menu
>   )
>
>   # Recuperation de l'ID mere
>   taxon_menu_id = taxon_menu[index_menu].id
>
> # Recursive sub menu
> recursive_sous_menu_creation(categorie, message, taxon_menu_id,
> root)
>
>
> end
>
>   end
> end


Pastie link : http://pastie.org/459108


Third, Recursive function "recursive_sous_menu_creation"

 def recursive_sous_menu_creation(xml, message, taxon_mother_id, root)
>
>   (xml/:'sous_menu').each_with_index do |sous_menu, index_sous_menu|
> # Recuperation du nom du sous menu
> sous_menu_name = sous_menu.at("name").inner_html.to_s
>
> # Concatenation du message
> message += sous_menu_name + ' / '
>
> # Affichage d un message
> p message
>
> # Creation de la Taxon
> taxon_sous_menu_mother = Taxon.create(
>   :taxonomy_id => root.id,
>   :name => sous_menu_name,
>   :parent_id => taxon_mother_id,
>   :position => index_sous_menu
> )
>
> p taxon_sous_menu_mother.id.to_s + " " +
> taxon_sous_menu_mother.name  + " " + taxon_sous_menu_mother.parent_id.to_s
>
> # Recuperation des pages s il y en a
> if sous_menu.find_element('page')
>   # Instanciation d un tableau pour la concatenation des pages
>   array_page = Array.new
>
>   # Pour chaque page
>   (sous_menu/:page).each_with_index do |page, index|
> # On insert l ID dans le tableau
> array_page[index] = Integer page.at("id").inner_html.to_s
>   end
>   # Apres creation du tableau des pages
>   # Lancement de l import
>
> import_article_from_categorie_id_and_set_taxons(array_page,taxon_sous_menu_mother)
> end
>
> # Test si il y a des sous menus
> if sous_menu.find_element('sous_menus')
>   # Traitement sous-menus
>   (sous_menu/:'sous_menus').each_with_index do |sous_sous_menu,
> index_sous_sous_menu|
> recursive_sous_menu_creation(sous_sous_menu, message,
> taxon_sous_menu_mother.id, root)
>   end
> end
>
>
>   end
>
>
>   end
>

Pastie link : http://pastie.org/459110

And, the end, the result

"#"
> "#  create_products 

[Rails] routes, controllers, and intentions

2009-04-27 Thread soldier.coder

I have the following tables: courses, students, and rosters.  The
rosters table references the courses and students tables.  With
default routes in place, to list the students in a course I would use:
http://localhost:3000/rosters/list

but this lists the rosters for all courses.

if I use http://localhost:3000/rosters/list/1

rails looks in the rosters table for entry with the id =1.  How do I
tell it I want all the entries where course_id = 1?

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



[Rails] How to integration test forms with multiple models

2009-04-27 Thread Jarl Friis

Hi.

I try to create an integration test for a form that updates two models
(order and floorplan), Creating a functional test for this situation
works fine, however I cannot build an equivalent integration test.

My master model (order) contains
 has_many :floorplans
 accepts_nested_attributes_for :floorplans

that makes it possible to assign floorplans directly to order

then I have a form (new.html.erb) containing 
<% form_for(@order, :html => {:multipart => true}) do |f| %>
<% f.fields_for :floorplans do |floorplan_fields| %>
  <%= floorplan_fields.file_field :file_upload %>
<% end %>
<% end %>

I only want my form to contain one floorplan object to be created, so
in the controller I have
  def new
@order = Order.new
@order.floorplans.build
  end

In the functional test I can now verify what I see in the browser:

  test "should create order" do
assert_difference('Order.count') do
  post :create, {
:order => {
  :floorplans_attributes => 
  [{:file_upload => fixture_file_upload('files/empty', 'image/png')}
  ]
}}
end

This works fine, but if I try to test this in an integration test I
can't test this, I have tried both

post "orders/create", {:order => {
:floorplans_attributes => 
[ {:file_upload => fixture_file_upload('files/empty', 'image/png')} ]
  }}

and

post "orders/create", {:order => {
:floorplans_attributes_0_file_upload => 
fixture_file_upload('files/empty', 'image/png')
  }}

but it doesn't work.

The first attempt just serialises the list [ {:file_upload =>
fixture_file_upload('files/empty', 'image/png')} ] into a string when
creating the HTTP POST request and produces 

Hash or Array expected, got String 
("file_upload#")

The second one fails with 

unknown attribute: floorplans_attributes_0_file_upload

What to do?

Jarl


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



[Rails] routing: Unescape urls

2009-04-27 Thread edbond

Hello All,

How to make rails unescape incoming urls? I want to use russian chars
in routes, like:

map.city URI.escape("/Карта--:title--:id"), :controller =>
"cities", :action => "show" It seems to works (page loads) but all
links on page looks like this:
http://localhost/%25D0%259A%25D0%25B0%25D1%2580%25D1%2582%25D0%25B0--%D0%9A%D0%B8%D0%B5%D0%B2--30295?page=4

Rails double escapes url?

Also I tried url_for( :escape => false), it doesn't help.

Thanks in advance,
Eduard

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