[Rails] Re: How to pass data to Javascript variable from Ruby on Rails

2009-04-07 Thread Chris Kottom
The most straightforward way of doing what you want is: <%= my_var %>

On Wed, Apr 8, 2009 at 7:31 AM, SpringFlowers AutumnMoon <
rails-mailing-l...@andreas-s.net> wrote:

>
> I wonder on RoR, will there be a need sometimes to pass some data from
> Ruby to Javascript?
>
> 1)   var title = __ ;
>
> What is the proper way to do it (fill in the code for  __ )
> if title can have newline character, or single / double quote or any
> weird character.  and what's more, what if the title from database can
> have 

[Rails] Re: How to use Net::SSH

2009-04-07 Thread Conrad Taylor
On Tue, Apr 7, 2009 at 10:27 PM, Shripad  wrote:

>
> Hi all,
>
> I am having following code in ruby
>
> require 'net/ssh'
>  require 'net/sftp'
>  begin
>Net::SSH.start
> ('132.147.161.159',:password=>'k',:port=>1234,:username=>'k') do |ssh|
>  ssh.sftp.connect do |sftp|
>Dir.foreach('.') do |file|
>puts file
>end
>end
> end
> rescue Exception=> Ex
> puts Ex.message
> end
>
> After executing the above code it is giving me following error
>
> Bad file descriptor - connect(2)
>
> username, password, and ipaddress are fine
>
> What I want is to take data from remote machine to server.
>
> Please Help me out.
>
>
> Thanks and Regards,
> Shri


What are you wanting to do?  SFTP or SSH?  From the code,
it appears that you're trying to move a file from point A to B.
Thus, here's a brief outline of the things that you can do with
SFTP:

require 'net/sftp'

  Net::SFTP.start('host', 'username', :password => 'password') do |sftp|
# upload a file or directory to the remote host
sftp.upload!("/path/to/local", "/path/to/remote")

# download a file or directory from the remote host
sftp.download!("/path/to/remote", "/path/to/local")

# grab data off the remote host directly to a buffer
data = sftp.download!("/path/to/remote")

# open and write to a pseudo-IO for a remote file
sftp.file.open("/path/to/remote", "w") do |f|
  f.puts "Hello, world!\n"
end

# open and read from a pseudo-IO for a remote file
sftp.file.open("/path/to/remote", "r") do |f|
  puts f.gets
end

# create a directory
sftp.mkdir! "/path/to/directory"

# list the entries in a directory
sftp.dir.foreach("/path/to/directory") do |entry|
  puts entry.longname
end
  end

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] Validate file format: not by extension

2009-04-07 Thread Brijesh Shah

Hi All,

I want to validate a file format before uploaded on server.

I know it can be validate by content-type or using regex.
But I wonder if someone change the extension of file and then uploaded
it

I have to validate only two format: 1) wav 2) gsm

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: Understand rails 2.0 and above

2009-04-07 Thread Jaryl Sim

http://guides.rubyonrails.org/

On Apr 8, 1:25 pm, Tushar Gandhi 
wrote:
> Hi,
> I worked on rails 1.2.3 for one and half year.
> Right now, I started to work on the rails 2.2.
> Is there any tutorial project available on any site ?
> So that I will understand the rails 2.0 in more details.
> I think there are lot of changes in rails 2.0.
> Any help is appreciated.
> 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: Getting the associated model in a join table

2009-04-07 Thread Jaryl Sim

I don't think a delegate would work. Okay, just to recap on the
database structure:

products
| id | name | price |
|  1 | a   |  2.50 |
|  2 | b   |  1.50 |

suppliers
| id | name |
|  1 |  s_a  |
|  2 |  s_b  |

products_suppliers
| id | supplier_id | product_id | supplier_type |
| 1  |   1 | 1  |   "vendor"  |
| 2  |   1 |  2 | "manufacturer"|

Firstly, I don't think that 'products_suppliers' is a good name since
this form is only a requirement for HABTM to work. It should be more
descriptive of the relationship, but your call.

Okay, so I believe that you want to do something like this:

p = Product.first

p.vendors # => [#< Supplier id: 1, name: "s_a">, #]
p.manufacturer # => #< Supplier id: 1, name: "s_a">

You might want to try this:

class Product < ActiveRecord::Base
  has_many :products_suppliers
  has_many suppliers, :through => products_suppliers

  named_scope :vendors, :conditions => ["supplier_type = ?", "vendor"]
  named_scope :manufacturer, :conditions => ["supplier_type = ?",
"manufacturer"]
end

This does not restrict the manufacturer to a one-to-many relationship,
so you will have to ensure that each product will have only one
manufacturer (you can do this pretty easily with some validations).

On Apr 8, 11:14 am, Matt Jones  wrote:
> On Apr 7, 1:28 pm, Marcelo de Moraes Serpa 
> wrote:
>
>
>
>
>
> > So let's take this code
>
> > p = Product.find(1)
>
> > What I need is a specific products_suppliers related to specific combo of
> > (supplier_id,product_id) keys, so I can get the supplier_type data related
> > to this product+supplier. However, I the has_many relationship in Supplier
> > reaturns all the products_suppliers that has supplier_id == the id of this
> > supplier -- To get the specific products_supplier I would also need the id
> > of the product that owns this supplier, but I can't get it. So, the first
> > thing I though was something like has_one :through. That's why I said, a
> > has_one relationship through a link table. The thing is, I need the
> > product_id that owns this supplier from the supplier model. I might as well
> > just leave AR and do some raw SQL, or maybe use sql :select statemente in
> > the association to fetch the type from the link table into the association.
>
> > Does that make sense?
>
> Maybe this is too obvious, but given the example above, couldn't you
> just use:
>
> p.products_suppliers.find_by_supplier_id(some_supplier_id)
>
> That will give you the supplier that you're looking for.
>
> BTW, I'd recommend a different name for the supplier_type column -
> that pattern (same as the foreign key, with _type instead of _id) is
> the Rails convention for single table inheritance, which is NOT what
> you're looking for here. It shouldn't cause a problem, but the AR
> association code is known to sometimes get really weird indigestion
> from that situation...
>
> Hope this helps,
>
> --Matt Jones
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Conditionally respond with HTTP redirect for xml_http_request

2009-04-07 Thread Ram

Hi all,

I have select box in one of my views which lists a few contacts.
I also have an option in this select box to add a new contact.
There is also an observe_field hook to this select box that Ajax
requests further info about the selected contact from the controller
and displays it in an adjacent "info" div.

Now, I need to redirect the user to the New Contact page from the
controller if the selected value from the select box is "new contact".

This is the controller code I have now

if request.xml_http_request?
  if !...@contact.blank?
render :partial => "show", :layout => false
  elsif params[:id] == "new contact"
redirect_to new_contact_path
  else
render :text => "Please select a contact"
  end
end

This renders the New Contact page in the "info" div. Whereas, I want
the user to be completely redirected to the New Contact page like a
HTTP response would.
Any thoughts on how I can handle this? Any ideas welcome..
Thanks!


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



[Rails] Re: Alternative to render :update

2009-04-07 Thread Jaryl Sim

If that's the case, then you should split it up into multiple
requests. I believe that you can only send back one response per
request, so that is an inherent problem.

Perhaps you may try sending a request once the a valid file is
selected in the file upload field.

On Apr 7, 10:04 pm, Jack Bauer 
wrote:
> Hi Jaryl, thanks.
>
> That would work, but it has a slightly different behavior than what I'm
> looking for. I want it to begin the upload of the multiple images, let's
> say 3, and when one finishes being processed (resized, etc.) it's
> inserted into the page and then the second image starts being processed
> and inserted, then the third. Your solution would process all three and
> after it finishes processing it'll dump all 3 of them out at essentially
> the same time.
>
> It's a relatively unimportant difference, but I was wondering if there's
> a way to pull that off.
> --
> 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] How to pass data to Javascript variable from Ruby on Rails

2009-04-07 Thread SpringFlowers AutumnMoon

I wonder on RoR, will there be a need sometimes to pass some data from
Ruby to Javascript?

1)   var title = __ ;

What is the proper way to do it (fill in the code for  __ )
if title can have newline character, or single / double quote or any
weird character.  and what's more, what if the title from database can
have 

[Rails] How to use Net::SSH

2009-04-07 Thread Shripad

Hi all,

I am having following code in ruby

require 'net/ssh'
 require 'net/sftp'
 begin
Net::SSH.start
('132.147.161.159',:password=>'k',:port=>1234,:username=>'k') do |ssh|
  ssh.sftp.connect do |sftp|
Dir.foreach('.') do |file|
puts file
end
end
end
rescue Exception=> Ex
puts Ex.message
end

After executing the above code it is giving me following error

Bad file descriptor - connect(2)

username, password, and ipaddress are fine

What I want is to take data from remote machine to server.

Please Help me out.


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



[Rails] Understand rails 2.0 and above

2009-04-07 Thread Tushar Gandhi

Hi,
I worked on rails 1.2.3 for one and half year.
Right now, I started to work on the rails 2.2.
Is there any tutorial project available on any site ?
So that I will understand the rails 2.0 in more details.
I think there are lot of changes in rails 2.0.
Any help is appreciated.
Tushar
-- 
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] JRuby on Rails on Google App Engine

2009-04-07 Thread Ola Bini

Hi friends,

As you might have heard, Google has released support for Java on App Engine.

I've been part of a preview, and know that JRuby, Ruby on Rails and Merb
works very well on it.

More information here:
http://olabini.com/blog/2009/04/java-on-google-app-engine/
http://olabini.com/blog/2009/04/dynamic-languages-on-google-app-engine-an-overview/
http://olabini.com/blog/2009/04/jruby-on-rails-on-google-app-engine/

Cheers

-- 
Ola Bini (http://olabini.com)
Ioke creator (http://ioke.org)
JRuby Core Developer (http://jruby.org)
Developer, ThoughtWorks Studios (http://studios.thoughtworks.com)
Practical JRuby on Rails (http://apress.com/book/view/9781590598818)

"Yields falsehood when quined" yields falsehood when quined.





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



[Rails] export to excel

2009-04-07 Thread Sijo Kg

Hi
 I have some data to be exported as well as imported to/from my
rails application to Excel.Could anybody please point me some good
advise on how to do this..Also expect some good links on the same

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

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



[Rails] Re: Multi Model Forms and Validations

2009-04-07 Thread sshefer

Sure.

My scenario is a bit different.

I have an application form that needs to be filled in by a user.  If
the user is not registered on my site I have a few fields that allow
the user to quickly enter name and email and their account will be
created when the application is submitted.  At the same time, the
application allows a user to pick from a list of documents they've
uploaded.  However, I also have fields incase a user would like to
upload a document that is not on the list (to save them the hassle of
going back, uploading and returning to the application).

Therefore, my application will always have a new @application and
sometimes a new @user or @document.  The document model is
polymorphic.  The application belongs_to the user and has a field for
document_id but I did not create an explicit relationship in the
model.

Thanks for any help.

On Apr 8, 1:03 am, Ram  wrote:
> Hmmm.. Are Cat and Dog associated to the Person model?
>
> > there may not always be a @cat or @dog
>
> Meaning the parameters for these models will be passed in from the
> form but they will be empty? In which case you can have a
> before_validation callback and check if all the params for these
> models are blank. If they are, then return false. This will still
> throw a "Cat/Dog is invalid" validation error. That can be handled by
> hacking into error_messages_for. Its all quite ugly but it works.
> I can tell you more if you can explain the context better.
>
> On Apr 7, 2:26 pm, sshefer  wrote:
>
>
>
> > Jim Neath's walkthru (http://jimneath.org/2008/09/06/multi-model-forms-
> > validations-in-ruby-on-rails/) talks about validating multiple objects
> > before saving.  His example is below:
>
> > if @person.valid? & @cat.valid? & @dog.valid?
> >   Person.transaction do
> >     @person.save!
> >     @cat.save!
> >     @dog.save!
> >   end
> > else
> >   FAIL
> > end
>
> > I am trying to do something similar but in my situation there may not
> > always be a @cat or @dog (there will always be a @person though).
> > Does anyone know of a way that I can run the same validation but allow
> > for the conditional presence of the 2 objects?
>
> > 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] update page with results as they are scraped

2009-04-07 Thread Adam Akhtar

Hi,

Im creating a screenscraper app that takes a users search term, scrapes
several 3rd party sites and returns the aggregated results after a few
seconds.

Rather than wait for all the sites scraping to be completed before
showing the results, I want to show the results as they are scraped, ie.
when one sites results have been scraped and prepared, they are shown
immediately whilst the next set are being done.

Initially I thought id just make a scraper function like so

def scrape_sites

sites.each do |a_site|
   a_sites_results = scrape_and_parse_this_site(a_site)
   yield a_sites_results
end
end

Then in my controllers js response I could take the results and render
them
but then i found out htat you cant make multiple render calls in one go.

How do i go about doing this? Does this behaviour have a name like say
"live search" etc
-- 
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: Multi Model Forms and Validations

2009-04-07 Thread Ram

Hmmm.. Are Cat and Dog associated to the Person model?
> there may not always be a @cat or @dog

Meaning the parameters for these models will be passed in from the
form but they will be empty? In which case you can have a
before_validation callback and check if all the params for these
models are blank. If they are, then return false. This will still
throw a "Cat/Dog is invalid" validation error. That can be handled by
hacking into error_messages_for. Its all quite ugly but it works.
I can tell you more if you can explain the context better.

On Apr 7, 2:26 pm, sshefer  wrote:
> Jim Neath's walkthru (http://jimneath.org/2008/09/06/multi-model-forms-
> validations-in-ruby-on-rails/) talks about validating multiple objects
> before saving.  His example is below:
>
> if @person.valid? & @cat.valid? & @dog.valid?
>   Person.transaction do
>     @person.save!
>     @cat.save!
>     @dog.save!
>   end
> else
>   FAIL
> end
>
> I am trying to do something similar but in my situation there may not
> always be a @cat or @dog (there will always be a @person though).
> Does anyone know of a way that I can run the same validation but allow
> for the conditional presence of the 2 objects?
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: initializing collection_select

2009-04-07 Thread Ram

ive come across this problem and as far as my searching took me,
collection_select does not support the :selected option.
you can handle this by initializing the "selected" value in the
controller for the appropriate attribute before rendering the partial.

The code you have shown above is slightly flawed in the syntax of
collection_select as Fred has already pointed out. I think you want

<%= f.collection_select :observation_category_id,
ObservationCategory.find(:all), :id, :name %>

So in your case, the problem really was the syntax. The above should
work for your edit form ie. the correct option will be selected based
on the existing value (built into collection_select).

The lack of support for the :selected option in collection_select
however, is a side issue. Anyone know if there's a fix for it? Besides
initializing the value for it in the controller before rendering the
partial?

On Apr 7, 12:43 pm, Frederick Cheung 
wrote:
> On Apr 7, 5:21 am, LukeG  wrote:
>
> > I'm a noob. I've trolled the web and groups for help, but I just don't
> > know enough Rails to apply the solutions to my particular problem. I
> > even got the screencast from Pragmatic Programmers, but still no dice.
>
> > I'm having a problem getting my collection_select to initialize with a
> > previously stored value. I have items and categories, with many items
> > to one category. When I edit an item, the category list populates
> > correctly, but I cannot figure out how to set the default to whatever
> > category was already stored for that item.
>
> collection_select is like the various model helpers in that you do
> collection_select 'instance_variable_name', 'method_name', ...
> ie in this instance collection_select 'observation',
> 'category_id', ...
>
> Seeing as how you've already got a form_for setup, you should be able
> to do f.collection_select 'category_id', ...
> Calling it on the form builder means you don't need to tell rails
> which object you are working with.
>
> Fred
>
>
>
> > Running Rails 2.3.2, here is the code:
>
> > *controller:*
> >   def edit
> >     @observation = Observation.find(params[:id])
> >   end
>
> > *view:*
> >         <%= f.label "Category" %>
> >         <%=
> >                 collection_select(:observation_category_id,
> >                                                 @category_id,
> >                                                 
> > ObservationCategory.find(:all),
> >                                                 :id,
> >                                                 :name,
> >                                                 {:selected => 
> > @observation.observation_category_id})
> >         %>
>
> > *models:*
> > class Observation < ActiveRecord::Base
> >   attr_accessible :name, :icon_url, :observation_catategory_id
> >   belongs_to :observation_category
> > end
>
> > class ObservationCategory < ActiveRecord::Base
> >   has_many :observations
> > end
>
> > *html:*
> >         Category
> >         exercise
> > finance
> > nutrition
> > mood
> > energy
>
> > focus
> > sleep
> > junk_cat
> > satiation
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] font selection

2009-04-07 Thread ewo

Hi all,

I need to create a form that allows the user to select a font,
including style and color. Anybody have any pointers on this? I would
like to do the usual thing of having a list of font names, sizes,
italic/bold check boxes, and color selector along with a sample. I was
unable to find anything obvious to get me started, so any help is
appreciated.

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



[Rails] Re: Adding image in pdf using pdf writer

2009-04-07 Thread Tushar Gandhi

Jack Bauer wrote:
> Pretty straightforward error. You need to make sure you're using a PNG 
> without alpha-transparency (24-bit uses them, 8-bit doesn't.)

Hi,
Is there no way to support those images?
Thanks,
Tushar
-- 
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] Ajax & Rails

2009-04-07 Thread esdevs

ok - I am trying to do something seemingly straight forward.
Essentially I want to list out a bunch of items and for each item
individually, if the user clicks on it, the corresponding web link
will appear underneath -- if the user clicks on the item again, then
the weblink disappears.  This should work for each item in the list.
I have tried but to no avail - below is a vid clip of what is
happening as well as the code that I am using -- any help is greatly
appreciated

http://www.screentoaster.com/watch/stU0 … BeQlVeXV5e

(partial _post.html.erb)
<%= link_to_remote("#{post.title}", :after => "$('link').next
(1).toggle()") %>

  <%= post.link %>

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

2009-04-07 Thread xabriel

Hi all,

I have the following on a controller method:

  render :text => "A string message"

I want that response body to be converted to US-ASCII. (BTW, Ruby
seems to default to UTF-8)

Any ideas? I know theres a 'response.charset', but that seems to only
change the response's charset header. I need the actual body string to
be changed to US-ASCII.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Displaying 'ticked' check boxes

2009-04-07 Thread Daniel Bush
2009/4/7 Helen Smith 

>
> I need to display check boxes as 'ticked' in my edit function where
> there is a corresponding value for them in the database.
>
> In my new function a user can select between 1 and 4 tick boxes and I
> need these ticked check boxes displayed back to them when they go in to
> the edit function for that database item.
>
> Most appreciated if anyone out there can help please?
>
> Here's the code from the new function that sets up the database fields
> from the check boxes - so I just need to display these as 'ticked' in my
> edit function.
>
> tr>
> Agreement Type    href="javascript:openNewWindow('
> http://security/transfers/transfer_help.htm'
> )"> src="http://security/transfers/images/info.jpg"; width="10" height="10"
> border="0">
> 
> Contract
>    
> Data
> Transfer Agreement    
> Data
> Destruction Agreement   
>  value="Y">Non-Disclosure Agreement   
> 
> 
>
> Currently my edit function is as below but I'm missing the bit to get
> the boxes ticked.
>
> 
> Agreement Type    href="javascript:openNewWindow('
> http://security/transfers/transfer_help.htm'
> )"> src="http://security/transfers/images/info.jpg"; width="10" height="10"
> border="0">
> 
>  @transfers.agreement_1 if @transfers.agreement_1 %>">Contract  
>  
>  @transfers.agreement_2 %>"">Data Transfer Agreement    
>  @transfers.agreement_3 %>"">Data Destruction Agreement   
>  @transfers.agreement_4%>"">Non-Disclosure Agreement   
> 
> 
> --
>

Hi Helen,
Had a bit of trouble reading the last section.
To check a checkbox, you have to say:
  
The "value" attribute can be whatever you set it, but maybe use the rails
default which is 0 and 1 for not-ticked and ticked respectively.  Bear in
mind that the html spec says that if you don't tick the box, it won't get
sent back to the server so other things being equal, your server won't get
to see 0.

You should read
http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html as a
starting point for what rails can do to help you build forms and in
particular check out the 'check_box' function which employs a little hack to
get round the html spec so that you do see '0'.

Ideally, you want something a little like this:
<% form_for :transfer do |f| %>
...
<%= f.checkbox 'agreement_1' %>
...
<% end %>
I'm assuming you have a @transfer model or object which is created in your
controller action with an 'agreement_1' method that returns a boolean or
something like that.

You can of course create the checkbox manually, but you'll need to write
code to test the boolean and insert the checked attribute/value pair into
your tag:
  <%
  checked=""i
  checked = %{checked="checked"} if agreement_1
  %>
   />

-- 
Daniel Bush

http://blog.web17.com.au
http://github.com/danielbush/sifs/tree/master
http://github.com/danielbush

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



[Rails] AR.find :include is adding stuff I don't want

2009-04-07 Thread Greg Willits

In this code below, ActiveRecord returns data from associations I don't
want.

class Article < ActiveRecord::Base

  has_many  :extras
  has_many  :pages, :order => 'sortOrder'
  has_many  :assets

  def get_list
return self.find(:all,
  :include=> :extras,
  :conditions => ["publishable='Y'"])
  end
end

Without the :include statement, we get the usual lazy load, and no
associations are loaded, only the attributes of the Article.

However, I want data from the :extras association and not the others.

When I use the code above, I get data from Article (good), Extras
(good), and Assets (bad), and nothing from Pages (curious).

I don't understand why Assets is being included, and I don't know how to
keep that data out of the results.

What am I missing? Thx.

-- gw
-- 
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] Multipart REST post, XML body with file

2009-04-07 Thread e deleflie

Hi,

Can anyone shed light on how to do a classic RAILS REST POST (i.e.
post an XML structure representing an ActiveResource) ... whilst at
the same time posting a file?

My current code (working) is below. It does not have a file associated
with the post.

I know I have to do a multipart, but what I cant work out is that in a
multipart, each value has a key ... what would be the key for the main
XML body? Because, see, in the example below, the XML _is_ the body
... it has no key associated with it.

Etienne

--
body = "true3456"

uri = URI.parse("http://#{$SITE_URL}/my_object.xml";)
http = Net::HTTP.new(uri.host, uri.port)
headers={}
headers['Content-Type'] = "application/xml"

begin
  http.start do
req = Net::HTTP::Post.new(uri.request_uri, headers)
req.basic_auth($name, $pword)
resp = http.request(req, body)

if resp.is_a?(Net::HTTPSuccess)
  return true
else
  return false
end

  end
rescue Exception => e
  debug "Exception with submitting using net:http #{ e } (#{ e.class })!"
  return false
end

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



[Rails] Re: Use a Time Zone without setting Time.zone?

2009-04-07 Thread Danimal

Rick,

You are _THE MAN!_. Thank you!

For some reason, I was getting all confused with all the various Time,
Date, TimeZone, TimeWithZone, etc. objects.

I hacked together something that worked, but it was a bit more complex
than what you had. I didn't realized that you could pass a TimeZone
object to in_time_zone. I'm gonna clean it up according to what you
suggested.

Whew!

Thanks,

-Danimal

On Apr 7, 9:50 pm, Rick Schumeyer  wrote:
> Either I'm not understanding what you want, or this is real easy.
>
> Let's say I have a class Event with a field edate, which is stored in
> UTC:
>
> >> e = Event.find(1)
>
> => #>> e.edate
>
> => Mon, 30 Mar 2009 12:00:00 UTC +00:00>> e.edate.class
>
> => ActiveSupport::TimeWithZone
>
> Now Let's say you want the time in "America New York" zone.  First,
> create a new TimeZone object:
>
> >> ze = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)")
>
> => # @name="Eastern Time (US & Canada)", @tzinfo=# America/New_York>>
>
> Then:>> e.edate.in_time_zone(ze)
>
> => Mon, 30 Mar 2009 08:00:00 EDT -04:00
>
> So in summary, I think you just need this:
>
> local_zone = ActiveSupport::TimeZone.new("name_of_time_zone")
> local_time = time_in_utc.in_time_zone(local_zone)
>
> You will need to see the documentation for TimeZone for the names of
> all the zones.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Read remote zip

2009-04-07 Thread Phlip

RobR wrote:

> I'd like to decompress the contents of:
> http://host.com/file.zip
> 
> in memory without having to download the file (e.g. `wget`) first.
> Suggestions?

"Without having to download the file first" is an example of "premature 
optimization". It is the root of all evil.

On any OS configured to be a server (as opposed to a wrist watch, for example) 
all memory and files map each other virtually. If you Net::HTTP read() that 
file 
to a file location, the OS will generally reserve a slot on the hard drive, 
then 
put the file into its matching memory location.

In the next split microsecond, your code reads that file and unzips it, using 
only the memory image. If you then delete the file, it may never reach the hard 
drive.

By that analysis, if you write simple code that downloads the file and hits it 
with common tools, you can finish your feature faster. However, there are also 
situations where you _don't_ know which option is faster.

Write the simpler code anyway, and then profile it to identify the real 
bottlenecks. They are invariably _not_ the places you would have guessed.


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



[Rails] Re: Use a Time Zone without setting Time.zone?

2009-04-07 Thread Rick Schumeyer

Either I'm not understanding what you want, or this is real easy.

Let's say I have a class Event with a field edate, which is stored in
UTC:

>> e = Event.find(1)
=> #
>> e.edate
=> Mon, 30 Mar 2009 12:00:00 UTC +00:00
>> e.edate.class
=> ActiveSupport::TimeWithZone

Now Let's say you want the time in "America New York" zone.  First,
create a new TimeZone object:

>> ze = ActiveSupport::TimeZone.new("Eastern Time (US & Canada)")
=> #>

Then:
>> e.edate.in_time_zone(ze)
=> Mon, 30 Mar 2009 08:00:00 EDT -04:00

So in summary, I think you just need this:

local_zone = ActiveSupport::TimeZone.new("name_of_time_zone")
local_time = time_in_utc.in_time_zone(local_zone)

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



[Rails] Re: STI Problem When Using Same Controller

2009-04-07 Thread chenillen

Thanks Freddy,

So rails doesn't support association inheritance, I know what you
mean, but I don't like to put the sub-model association into user
model,

because i have about 10 sub-models like credit_card in Account,

I found a plugin called "has_many_polymorphs", this plugin allow you
access all the association between two parent model.

One other question, if I want to use one controller to create all the
sub models, how could i write all the controller actions?

Thanks again,

Allen

On Apr 8, 1:50 am, Freddy Andersen  wrote:
> The user does not know what creditcards are in your user model. You
> have to have an association in the user model if you want to do
> User.first.creditcards.new
>
> has_many :creditcards
>
> or get the users account and then check the creditcard.. Since a user
> has_many accounts you would have to get an account before you could
> create a creditcard.
>
> So something like User.first.accounts.first.creditcard.new would
> explain better...
>
> Or you could use has_many through and use the accounts model as the
> through...
>
> has_many :accounts
> has_many :creditcards, :through => :accounts
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails 2.3 Upgrade Issue with MemCache

2009-04-07 Thread Steve Odom

I'm having the same issue as Tom, but I'm not using Starling. I'm
using spawn. I don't have anything in an initializer to wrap in a
after_initialize.

Any ideas how to get workling to work in 2.3?

Steve

On Apr 7, 7:14 pm, Freddy Andersen  wrote:
> I'm not sure why this happens, BUT in rails 2.3.2 you have to wrap
> your Workling loader a after_init like so:
>
> config.after_initialize do
>   Workling::Remote.dispatcher =
> Workling::Remote::Runners::StarlingRunner.new
> end
>
> On Mar 20, 6:42 am, TomRossi7  wrote:
>
> > One of the plugins I use is Workling.  It throws the following error
> > when I try to run it under 2.3:
>
> > /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
> > dependencies.rb:443:in `load_missing_constant': uninitialized 
> > constantMemCache(NameError)
>
> > The offending line is:
>
> >       @@memcache_client_class ||= ::MemCache
>
> > I don't know a lot aboutmemcache, so I'm not sure what changed with
> > 2.3 that could cause the error.  Anyone have some ideas?
>
> > 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: Getting the associated model in a join table

2009-04-07 Thread Matt Jones



On Apr 7, 1:28 pm, Marcelo de Moraes Serpa 
wrote:

>
> So let's take this code
>
> p = Product.find(1)
>
> What I need is a specific products_suppliers related to specific combo of
> (supplier_id,product_id) keys, so I can get the supplier_type data related
> to this product+supplier. However, I the has_many relationship in Supplier
> reaturns all the products_suppliers that has supplier_id == the id of this
> supplier -- To get the specific products_supplier I would also need the id
> of the product that owns this supplier, but I can't get it. So, the first
> thing I though was something like has_one :through. That's why I said, a
> has_one relationship through a link table. The thing is, I need the
> product_id that owns this supplier from the supplier model. I might as well
> just leave AR and do some raw SQL, or maybe use sql :select statemente in
> the association to fetch the type from the link table into the association.
>
> Does that make sense?
>

Maybe this is too obvious, but given the example above, couldn't you
just use:

p.products_suppliers.find_by_supplier_id(some_supplier_id)

That will give you the supplier that you're looking for.

BTW, I'd recommend a different name for the supplier_type column -
that pattern (same as the foreign key, with _type instead of _id) is
the Rails convention for single table inheritance, which is NOT what
you're looking for here. It shouldn't cause a problem, but the AR
association code is known to sometimes get really weird indigestion
from that situation...

Hope this helps,

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



[Rails] Re: Easy way to convert URL back to route name?

2009-04-07 Thread Matt Jones

One final thing - you can also pass extra params in :requirements -
thus:

map.resource :foos, :requirements => { :extra => 'foo' }

will add :extra => 'foo' to the incoming params. I'm not 100% sure if
this works on map.connect style routes, but if it doesn't, it's
probably a bug.

--Matt Jones

On Apr 6, 10:18 pm, Dave Cantrell 
wrote:
> pharrington wrote:
> > Alternatively, you can just use the current_page? method:
>
> > if current_page? foo_url
> >   #do some ish
> > elsif current_page? bar_url
> >   # other stuff...
>
> Hey, I like that too -- thanks!
>
> -dave
> --
> 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] Use a Time Zone without setting Time.zone?

2009-04-07 Thread Danimal

Hello!

Is there an easy way to get a time in a particular time zone without
calling Time.zone = some_zone ?

I store events in UTC in the DB, and I also store a string
representation of the time zone as an attribute on the event.

What works is to do:

Time.zone = event.time_zone
start_time = event.start.in_time_zone
# and now I have the start time in the appropriate time zone

The problem, however, is that Time.zone = event.time_zone sets it
across the whole application, as best as I can tell. And I don't want
that!!

I could grab the Time.zone value, change it as above, then change it
back, but that's so ugly. What would be wonderful is if there was
something like:

start_time = event.start.in_time_zone(event.time_zone)

*sigh*

Anything like that? Any advice? This isn't an issue with a user's
local time zone, but rather just trying to show a PST time as 8am PST
and an EST time as 11am EST even if both are stored as 15:00:00 (in
UTC)

Thoughts?

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



[Rails] Re: Disable routing?

2009-04-07 Thread Brendon

You don't have to worry.  Rails runs as the 404 handler, so only
handles files that do not exist in the normal web server html area.
So, if the php file exists, it should take precedence over rails.
Think of how the index.html file has to be removed from a new rails
app to get it started.

I'd set a catchall route so that Rails would notice missing files in
those applications.

Brendon.

On Apr 5, 8:37 am, Chris Benson  wrote:
> Thanks Fred, but it's a shared hosting environment, and I don't have
> access to anything outside my /home area.
>
> I'm looking for a way to tell Rails routing, "Ignore these two
> directories."
>
> On Apr 5, 7:07 am, Frederick Cheung 
> wrote:
>
> > On Apr 5, 8:03 am, Chris Benson  wrote:> I have a 
> > Rails application that a couple of folders in the root (of
> > > public) for Wordpress and Mediawiki that I want to completely exclude
> > > from Rails routing.  How do I have the routing function of my Rails
> > > app ignore anything in the /blog or /wiki directories?
>
> > > Example:
>
> > > When someone types inhttp://mydomain.com/blog, I want the Rails app's
> > > routing to ignore it.
>
> > Typically you don't do this inside rails, you do this in apache, nginx
> > etc. by telling it to only proxy through to rails what you want to
> > through (so normally you would let nginx or apache handle static
> > files)
>
> > Fred
>
> > > Thanks,
> > > Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: setup method in functional tests and instance variables

2009-04-07 Thread Mitchell Gould

David Knorr wrote:
> On 6 Apr., 17:18, Mitchell Gould 
> wrote:
>> ActiveSupport::TestCase
>>
>> from
>>
>> ActionController::TestCase
>>
>> works like a charm.
>>
>> Why don't they fix this?
> 
> What do mean when saying "fix this". Did you run the rails:update rake
> task?
> 
> --
> Best regards,
> David Knorr.
> http://twitter.com/rubyguy

I did run rails:update rake.  And I updated rails.  But even now when I 
run script/generate controller someController I have to edit the test 
file so that it is changed from ActionController::Testcase to 
ActiveSupport::TestCase.

Should I update something else so I don't have to do this everytime? And 
it does this only for the functionals not the unit test skeletons.

Mitch
-- 
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: Association and validation

2009-04-07 Thread Tiago Z.C
i'm sorry, forget my question, i found the awnser.

class Comment < ActiveRecord::Base

  validates_presence_of(:post)

  belongs_to :post, :validate => true

end

:)

On Tue, Apr 7, 2009 at 10:03 PM, Tiago Z.C  wrote:

> Hi
> I'm having some issues with models that i don't know which is the best way
> of doing that.
>
> I have Post model...
>
> class Post < ActiveRecord::Base
>
>   validates_presence_of :name, :title
>
>   has_many :comments
>
> end
>
>
> and the Comment model.
>
>
>  class Comment < ActiveRecord::Base
>
>   validates_presence_of(:post)
>
>   belongs_to :post
>
> end
>
>
> If I open the console, and start write some lines:
>
> c = Comment.new
>
> p = post.new
>
> c.post = p
>
> c.save
>
>
> I receive the true feedback but, what about the presence of name and title
> on post???
>
>
> Thank you...
>
>
> --
> Tiago Zortéa de Conto
> Mac User - MAC OS X Leopard
> MSN: tiag...@pop.com.br
>



-- 
Tiago Zortéa de Conto
Mac User - MAC OS X Leopard
MSN: tiag...@pop.com.br

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



[Rails] Read remote zip

2009-04-07 Thread RobR

I'd like to decompress the contents of:
http://host.com/file.zip

in memory without having to download the file (e.g. `wget`) first.
Suggestions?


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



[Rails] Association and validation

2009-04-07 Thread Tiago Z.C
Hi
I'm having some issues with models that i don't know which is the best way
of doing that.

I have Post model...

class Post < ActiveRecord::Base

  validates_presence_of :name, :title

  has_many :comments

end


and the Comment model.


class Comment < ActiveRecord::Base

  validates_presence_of(:post)

  belongs_to :post

end


If I open the console, and start write some lines:

c = Comment.new

p = post.new

c.post = p

c.save


I receive the true feedback but, what about the presence of name and title
on post???


Thank you...


-- 
Tiago Zortéa de Conto
Mac User - MAC OS X Leopard
MSN: tiag...@pop.com.br

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



[Rails] Re: Anyone know a way to create html comments with the names of the views?

2009-04-07 Thread Emanuele Tozzato

I'm using it and it's cool, but it should probably check if any layout
statement is present on the controller: if layout is nil then I
probably don't need/want any comment in the template :)

(found this with the :tex view of instiki clone)

thanks 4 the plugin!

On Fri, Apr 3, 2009 at 10:50 AM, Frederick Cheung
 wrote:
> For what it's worth i've pluginised this: 
> http://github.com/fcheung/tattler/tree/master


-- 
Emanuele Tozzato
+1 (619) 549 3230
1985 Sherington Place, #E302
Newport Beach, CA 92663
http://mekdigital.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 version of a gem loaded?

2009-04-07 Thread RobR

Is there an easy way to tell what version of a gem was loaded?  For
example, ActiveRecord?

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



[Rails] Re: Rails or separate packages, RedHat

2009-04-07 Thread RobR

I tried that and this is what happened.  The system Ruby is 1.8.7.

[~/] gem install rails
ERROR:  While executing gem ... (Errno::EACCES)
Permission denied - /var/lib/gems/1.8/cache/rake-0.8.4.gem


On Apr 7, 5:40 pm, Freddy Andersen  wrote:
> If you install the gems as a non root user it will be installed in
> ~/.gems
>
> gem install rails
>
> will install it in ~/.gems
>
> On Apr 7, 3:44 pm,RobR wrote:
>
>
>
> > Good point.  Ok, a dumb question.
>
> > I found I can run "gem install -i install_dir -d bin_dir"
>
> > Where do people usually install such things in their user spaces?
> > /home/user/var/lib/gems
>
> > What about the "-d bin_dir"?  What kind of things go in there?  .so
> > libraries like mysql.so?  What default location do those usually end
> > up in?  Where is a usual place to put them in my home space?
>
> > What environment variables do I need to work with to make my installed
> > gems are used instead of older system installed gems?
>
> > Regards,
>
> > Rob
>
> > On Apr 6, 2:07 am, Roderick van Domburg 
> > s.net> wrote:
> > > Rob Redmon wrote:
> > > > So, do I ask the IT department to install Ruby on Rails or continue
> > > > asking for particular packages?  I'd rather just get the whole thing.
> > > > If so, will an install of "rails" override or interfere with already
> > > > installed rails libraries?  They will only install RedHat 5 managed
> > > > packages without a huge fight.  Other packages, I have to compile and
> > > > install in my own user space (/home).
>
> > > RHEL doesn't carry a lot of gems, and certainly not recent versions.
> > > Installing them yourself is the way to go.
>
> > > --
> > > Roderick van Domburghttp://www.railscluster.nl
> > > --
> > > 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: Rails 2.3 Upgrade Issue with MemCache

2009-04-07 Thread Freddy Andersen

I'm not sure why this happens, BUT in rails 2.3.2 you have to wrap
your Workling loader a after_init like so:

config.after_initialize do
  Workling::Remote.dispatcher =
Workling::Remote::Runners::StarlingRunner.new
end


On Mar 20, 6:42 am, TomRossi7  wrote:
> One of the plugins I use is Workling.  It throws the following error
> when I try to run it under 2.3:
>
> /Library/Ruby/Gems/1.8/gems/activesupport-2.3.2/lib/active_support/
> dependencies.rb:443:in `load_missing_constant': uninitialized 
> constantMemCache(NameError)
>
> The offending line is:
>
>       @@memcache_client_class ||= ::MemCache
>
> I don't know a lot aboutmemcache, so I'm not sure what changed with
> 2.3 that could cause the error.  Anyone have some ideas?
>
> 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: [JOBS]Opportunity for a ROR lead programmer as co-founder

2009-04-07 Thread Master Chief

Not necessarily. Boeing. GM. Ford. - companies in Specific domains but
household names still.

I believe you might be thinking google,  ebay, yahoo. - general
purpose, search/aggregation sites. We will not be that.

Good question though.


On Apr 7, 4:02 pm, Kevin Elliott  wrote:
> On Apr 7, 2009, at 3:58 PM, Master Chief wrote:
>
> > The RoR guru will help launch the company and be a part of this from
> > the beginning. This is your chance to be part of something which can
> > become a household name. It will be a web based product, heavily
> > reliant on data visualization, with a social networking interface. It
> > is not general purpose. It is targetted towards a specific domain.
>
> How do you plan on becoming a "household name" if it's "not general  
> purpose" and is "targetted towards a specific domain". To me this  
> sounds contradictory.
>
> -Kevin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Rails or separate packages, RedHat

2009-04-07 Thread Freddy Andersen

If you install the gems as a non root user it will be installed in
~/.gems

gem install rails

will install it in ~/.gems

On Apr 7, 3:44 pm, RobR  wrote:
> Good point.  Ok, a dumb question.
>
> I found I can run "gem install -i install_dir -d bin_dir"
>
> Where do people usually install such things in their user spaces?
> /home/user/var/lib/gems
>
> What about the "-d bin_dir"?  What kind of things go in there?  .so
> libraries like mysql.so?  What default location do those usually end
> up in?  Where is a usual place to put them in my home space?
>
> What environment variables do I need to work with to make my installed
> gems are used instead of older system installed gems?
>
> Regards,
>
> Rob
>
> On Apr 6, 2:07 am, Roderick van Domburg 
>
>
> s.net> wrote:
> > Rob Redmon wrote:
> > > So, do I ask the IT department to install Ruby on Rails or continue
> > > asking for particular packages?  I'd rather just get the whole thing.
> > > If so, will an install of "rails" override or interfere with already
> > > installed rails libraries?  They will only install RedHat 5 managed
> > > packages without a huge fight.  Other packages, I have to compile and
> > > install in my own user space (/home).
>
> > RHEL doesn't carry a lot of gems, and certainly not recent versions.
> > Installing them yourself is the way to go.
>
> > --
> > Roderick van Domburghttp://www.railscluster.nl
> > --
> > 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] Problems with in_place_editor_field

2009-04-07 Thread Sergey Potapov

Hi guys!
I try to use with in_place_editor_field method, but something is wrond.
After editing data in form, when I press OK it show "Saving...". Data
itself doesn't change. My console shows me following:

127.0.0.1 - - [08/Apr/2009:02:20:39 EEST] "POST /admin/set_song_lyrics/6
HTTP/1.1" 422 9800
http://localhost:3000/admin/show_song/6 -> /admin/set_song_lyrics/6

Method set_song_lyrics exists, but it's not called.
-- 
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: Problem with MYSQL after re-installing rails

2009-04-07 Thread Gavin

Hmmm - have downloaded and re-installed MYSQL 5.1.33

Still getting the same issue.
In pref pane it shows that mysql is running.

Can anybody think of anything else I can check/do?

Really need to get my database back up and running soon :S

Thanks

On Apr 7, 8:31 pm, Frederick Cheung 
wrote:
> On Apr 7, 7:36 pm, Dean Richardson 
> wrote:
>
> > Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7
> > for inspection.
> > Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
>
> > Any suggestions for diagnosing my mistake here?
>
> That sounds like a different issue  ( in Gavin's case it just the
> headers/libs for mysql it can't locate) - maybe you don't have all of
> the stuff from the Dev tools you need ?
>
> Fred
>
> > Thanks!
>
> > Dean Richardson
> > --
> > 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] slashdot: twitter on scala

2009-04-07 Thread Tim

I suspect this is old news to many but I just picked it up on slashdot
today, so in case you missed it:

http://developers.slashdot.org/article.pl?sid=09/04/07/1928218&art_pos=4
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: [JOBS]Opportunity for a ROR lead programmer as co-founder

2009-04-07 Thread Kevin Elliott


On Apr 7, 2009, at 3:58 PM, Master Chief wrote:

> The RoR guru will help launch the company and be a part of this from
> the beginning. This is your chance to be part of something which can
> become a household name. It will be a web based product, heavily
> reliant on data visualization, with a social networking interface. It
> is not general purpose. It is targetted towards a specific domain.

How do you plan on becoming a "household name" if it's "not general  
purpose" and is "targetted towards a specific domain". To me this  
sounds contradictory.

-Kevin

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



[Rails] [JOBS]Opportunity for a ROR lead programmer as co-founder

2009-04-07 Thread Master Chief

We a re a prefunding stage company working on a prototype, looking for
a RoR expert.

The RoR guru will help launch the company and be a part of this from
the beginning. This is your chance to be part of something which can
become a household name. It will be a web based product, heavily
reliant on data visualization, with a social networking interface. It
is not general purpose. It is targetted towards a specific domain.

Ideal person would be passionate about this company's vision and
contribute to it, RoR expert and able to work without financial
support in the near term. It is obvious why we cant disclose any
more.
The person needs to be based in the South Bay Area (around San Jose,
CA) for further discussions.

No outsourcing firm enquiries please.

It is in prefunding stage so only equity is offered.
Please respond at   master.chief01 AT yahoo dot com .


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



[Rails] Re: Rails or separate packages, RedHat

2009-04-07 Thread RobR

Good point.  Ok, a dumb question.

I found I can run "gem install -i install_dir -d bin_dir"

Where do people usually install such things in their user spaces?
/home/user/var/lib/gems

What about the "-d bin_dir"?  What kind of things go in there?  .so
libraries like mysql.so?  What default location do those usually end
up in?  Where is a usual place to put them in my home space?

What environment variables do I need to work with to make my installed
gems are used instead of older system installed gems?

Regards,

Rob

On Apr 6, 2:07 am, Roderick van Domburg  wrote:
> Rob Redmon wrote:
> > So, do I ask the IT department to install Ruby on Rails or continue
> > asking for particular packages?  I'd rather just get the whole thing.
> > If so, will an install of "rails" override or interfere with already
> > installed rails libraries?  They will only install RedHat 5 managed
> > packages without a huge fight.  Other packages, I have to compile and
> > install in my own user space (/home).
>
> RHEL doesn't carry a lot of gems, and certainly not recent versions.
> Installing them yourself is the way to go.
>
> --
> Roderick van Domburghttp://www.railscluster.nl
> --
> 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: Alternative to render :update

2009-04-07 Thread Ar Chron

Google for a Rails version of swfupload... in the Rails code it updates 
the thumbnails as it processes the files.
-- 
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: More Complex Join with Rails/ActiveRecord

2009-04-07 Thread Peter Laurens

This is awesome - exactly what I was after and I learned some SQL as 
well (which is clearly my weakness here).

Thanks for taking the time to type that up, you've really helped me out.

- N
-- 
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: "gem install mysql" fails

2009-04-07 Thread Greg Donald

On Mon, Apr 6, 2009 at 5:00 PM, Frederick Cheung
 wrote:
> I think version.h disappeared in ruby 1.9. Looks like it's trying to
> build a version of the mysql gem that isn't compatible with ruby 1.9
> (the other errors indicate that too) - i think ruby 1.9.1 needs  2.8.1
> (http://rubyforge.org/frs/?group_id=4550)


That's not building yet either, at least not for me:


> cd /usr/src/mysql-ruby-2.8.1

> make clean; make
gcc -I. -I/usr/local/include/ruby-1.9.1/i686-linux
-I/usr/local/include/ruby-1.9.1/ruby/backward
-I/usr/local/include/ruby-1.9.1 -I. -DHAVE_MYSQL_SSL_SET
-DHAVE_RB_STR_SET_LEN -DHAVE_MYSQL_MYSQL_H -I/usr/local/include
-D_FILE_OFFSET_BITS=64  -fPIC  -O2 -g -Wall -Wno-parentheses  -o
mysql.o -c mysql.c
gcc -shared -o mysql.so mysql.o -L. -L/usr/local/lib
-Wl,-R/usr/local/lib -L/usr/local/lib -Wl,-R/usr/local/lib -L.
-rdynamic -Wl,-export-dynamic-lmysqlclient  -lpthread -lrt-ldl
-lcrypt -lm   -lc
/usr/bin/ld: cannot find -lmysqlclient
collect2: ld returned 1 exit status
make: *** [mysql.so] Error 1

It doesn't find a packaged MySQL provided by my distro nor one
compiled from source by me.



-- 
Greg Donald
http://destiney.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] Rails paths when loading a Java applet

2009-04-07 Thread Greg Donald

I've built a Java applet and now I'm trying to load it using Rails,
it's failing to load.

The problem seems to be that Rails is changing the dots in my
classpath to forward slashes which then cause my applet's dependencies
to not load.  Here's an example dependency from the logs that's
failing:

ActionController::RoutingError (No route matches
"/com/objex/panywhere/Pedigree_RS_Bundle.class" with {:method=>:get}):


So how can I tell Rails that I'm loading a Java applet and to not mess
with anything in my  and  tags?

Here's my embed code that works perfectly outside of Rails:







  No Java Support.





Surely I don't have to make custom routes for every single one of my
applet dependencies ?


Thanks,


-- 
Greg Donald
http://destiney.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] Initializers not available in controllers...

2009-04-07 Thread Neal L

Hi all,

I have a file in config/initializers that specifies plan types.  The
file is:

==
APP_PLANS = [
  {
"id" => 0,
"name"   => 'free',
"Price"  => 0,
"Users"  => 1,
"Storage"=> 0,
"SSL"=> true
  }, {
"id" => 1,
"name"   => 'basic',
"Price"  => 24,
"Users"  => 1,
"Storage"=> 1,
"SSL"=> true
  }
]
==

In my account signup controller, I call:

  @plan_cost = app_plan...@plan_name]["Price"]

but I get an error:

  uninitialized constant ClientsController::APP_PLANS


So what am I doing wrong here? Why can't I get to the variable I
initialized???

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



[Rails] Re: Best practice for passing vars etc...

2009-04-07 Thread Frederick Cheung

On Apr 7, 8:24 pm, elliottg  wrote:
> In order for the products_controller actions to operate they all need
> access to params[:category]. Currently I am passing that attribute
> around thru a combination of hidden for_for fields and stuff like
> this:
> link_to 'Edit', edit_product_path(product, :category =>params
> [:category])
>
> I am running into a lot of issues keeping track of passing this info
> around through the various views and actions that are in play. It
> feels sloppy and prone to problems. It's like I'm working in PHP
> again.
>
You might want to read up on nested resources

> Should I use global varibles or sessions to solve these kinds of
> problems?

I really wouldn't - that's definitely grungy (both server side and
from the point of view of the user)

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



[Rails] Re: NO METHOD ERROR!!!

2009-04-07 Thread Jim Schiel

The reason it worked is because form_for was trying to resolve a  
RESTful route because it was passed a variable and not a constant. By  
either changing the variable to a constant, or creating the  
map.resources entry to create the RESTful routes, the problem is solved.

I hope that helps!

Jim Schiel


On Apr 7, 2009, at 4:25 PM, Mace Windu wrote:

>
> Colin Law wrote:
>> 2009/4/7 Mace Windu 
>>
>>>
>>> Jim Schiel wrote:
 Just a quick thought -- try :employ, instead of @employ in the
 form_for statement.
>>>
>>> This worked thank you.
>>
>>
>> Can someone explain why please?  I have both form_for(@blah) and
>> form_for
>> :blah and both appear to work ok for me.
>> Colin
>
> good question I don't know. I'm new to rails
> -- 
> Posted via http://www.ruby-forum.com/.
>
> >


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



[Rails] Re: Problem with MYSQL after re-installing rails

2009-04-07 Thread Dean Richardson

All:

I'm encountering similar errors and difficulties.  When I enter:

sudo env ARCHFLAGS="-arch i386" gem install mysql -- 
--with-mysql-config=/usr /local/mysql/bin/mysql_config

as many have suggested, I still get the same "can't find header files 
for ruby" error message:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 
extconf.rb install mysql -- 
--with-mysql-config=/usr/local/mysql/bin/mysql_config
can't find header files for ruby.


Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7 
for inspection.
Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out

Any suggestions for diagnosing my mistake here?

Thanks!

Dean Richardson
-- 
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: NO METHOD ERROR!!!

2009-04-07 Thread Mace Windu

Colin Law wrote:
> 2009/4/7 Mace Windu 
> 
>>
>> Jim Schiel wrote:
>> > Just a quick thought -- try :employ, instead of @employ in the
>> > form_for statement.
>>
>> This worked thank you.
> 
> 
> Can someone explain why please?  I have both form_for(@blah) and 
> form_for
> :blah and both appear to work ok for me.
> Colin

good question I don't know. I'm new to rails
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] rails assumption about getting new thread on each request

2009-04-07 Thread buddycat

hi all,

i am wondering if there is consensus around whether it is an
assumption of the rails core that each request will be served by a
new, clean thread? i ask because i am using Thread.current hash and
while mongrel seems to handle each request with a new thread and so
Thread.current is clean, passenger serves the same thread each time.

besides my own selfish uses, this seems to be pertinent to several
places in rails core where Thread.current is set with ||=

ror/vendor/rails/activesupport/lib/active_support/vendor/i18n-0.1.3/
lib/i18n.rb:40:  Thread.current[:locale] ||= default_locale
ror/vendor/rails/activesupport/lib/active_support/core_ext/time/
zones.rb:15:Thread.current[:time_zone] || zone_default
ror/vendor/rails/activerecord/lib/active_record/base.rb:2189:
Thread.current[:"#{self}_scoped_methods"] ||= self.default_scoping.dup

so, what is the expected behavior for a webserver?


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



[Rails] Re: NO METHOD ERROR!!!

2009-04-07 Thread Mace Windu

Gavin wrote:
> do you have "map.resources :employs "
> 
> in your routes.rb file?
> 
> If so, is it namespaced?
> 
> can you run "rake/routes" and copy/paste it's contents here?
> 
> 
> 
> On Apr 7, 8:56�pm, Mace Windu 

This worked aswell thank you.
I originally had map.resources :emp_app which is the name of my 
controller.

but when I changed it to: map.resources :employs

and changed my new.html.erb back to: <% form_for(@employs) do |f| %>

it work fine just like the previous suggestion
-- 
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: NO METHOD ERROR!!!

2009-04-07 Thread Colin Law
2009/4/7 Mace Windu 

>
> Jim Schiel wrote:
> > Just a quick thought -- try :employ, instead of @employ in the
> > form_for statement.
>
> This worked thank you.


Can someone explain why please?  I have both form_for(@blah) and form_for
:blah and both appear to work ok for me.
Colin


>
> --
> 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: NO METHOD ERROR!!!

2009-04-07 Thread Mace Windu

Jim Schiel wrote:
> Just a quick thought -- try :employ, instead of @employ in the
> form_for statement.

This worked thank you.
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: More Complex Join with Rails/ActiveRecord

2009-04-07 Thread Maurício Linhares

Just a quick try (you haven't showed up your database schema):

@articles = Article.all( :conditions => ["start_date >= ? AND id NOT
IN ( SELECT m.article_id from moderations m WHERE m.user_id = ? )",
today, current_user.id], :order => 'start_date')

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



On Tue, Apr 7, 2009 at 4:53 PM, Peter Laurens
 wrote:
>
> Hi,
>
> I have an Articles model.
> And a Moderations model.
> And a Users model.
>
> Articles have many Users (moderators) through Moderations.
> Users have many Articles (moderated articles) through Moderations.
>
> This works fine so far. I can link up a user with all their moderated
> articles etc.
>
> But, I'd like a find which would select all the Articles, except it
> hides (does not return) the articles the current user has moderated. I
> am currently doing this in Ruby in two stages like this:
>
> @articles_list = Article.find(:all, :conditions => ["start_date >= ?",
> today], :order => 'start_date')
> @articles_list -= current_user.moderated_articles if current_user
>
> And then displaying the articles list.
>
> This works, but I fully suspect it is cripplingly slow, and I'd also
> like to paginate these articles and all the pagination tutorials seem to
> warn against fetching everything in one go. This seems like good advice.
>
> So I am seeking guidance on a join condition that would do what I want.
> I'm guessing I need an inner join on the article_id on the moderations
> table, but need to make sure that the user_id of those records are the
> same as the current user only. So this is confusing me a bit.
>
> Many thanks for any help you may offer!
>
> - N
> --
> 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: NO METHOD ERROR!!!

2009-04-07 Thread Gavin

do you have "map.resources :employs "

in your routes.rb file?

If so, is it namespaced?

can you run "rake/routes" and copy/paste it's contents here?



On Apr 7, 8:56 pm, Mace Windu 
wrote:
> Its driving me crazy!! I searched online for the answer and there are no
> clear explanations for the NO METHOD ERROR.
>
> in my new.html.erb file I have something like this:
>
> EmpApp#new
> Find me in app/views/emp_app/new.html.erb
>
> <%= error_messages_for :employ %>
>
> <% form_for(@employ) do |f| %>
>
>    
>   <%= f.label :EmployDateFrom %>
>   <%= f.text_field :EmployDateFrom %>
>   
>
> 
> <%= f.submit "Create" %>
> 
> <% end %>
>
> and in my controller I have something like this:
>
>   def new
>   @employ = Employ.new
>
>   respond_to do |format|
>   format.html # new.html.erb
>   format.xml {render :xml => @employ }
>     end
>   end
>
> and this is the kind of error I get no matter what I do. No matter what
> I do do I get the same damn error I need TO KNOW WHY CAN ANYONE HELP ME
> DOES ANYONE KNOW!!
>
>  NoMethodError in Emp_app#new
>
> Showing app/views/emp_app/new.html.erb where line #6 raised:
>
> undefined method `employs_path' for #
>
> Extracted source (around line #6):
>
> 3:
> 4: <%= error_messages_for :employ %>
> 5:
> 6: <% form_for(@employ) do |f| %>
> 7:
> 8:
> 9:    
>
> RAILS_ROOT: C:/Users/MaceWindu/Documents/Ruby/railsprojects/employeeApp
> Application Trace | Framework Trace | Full Trace
>
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
> `__send__'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
> `polymorphic_url'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:119:in
> `polymorphic_path'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:269:in
> `apply_form_for_options!'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:248:in
> `form_for'
> app/views/emp_app/new.html.erb:6
> app/controllers/emp_app_controller.rb:8:in `new'
>
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
> `__send__'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
> `polymorphic_url'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:119:in
> `polymorphic_path'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:269:in
> `apply_form_for_options!'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:248:in
> `form_for'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in
> `render_template'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in
> `render_for_file'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:905:in
> `render_without_benchmark'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in
> `realtime'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in
> `custom'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in
> `call'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in
> `respond'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in
> `each'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in
> `respond'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:107:in
> `respond_to'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
> `perform_action_without_filters'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
> `call_filters'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
> `perform_action_without_benchmark'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
> `perform_action_without_rescue'
> c:/ruby/lib/ruby/1.8/benchmark

[Rails] Re: NO METHOD ERROR!!!

2009-04-07 Thread Jim Schiel

Just a quick thought -- try :employ, instead of @employ in the  
form_for statement.

On Apr 7, 2009, at 3:56 PM, Mace Windu wrote:

>
> Its driving me crazy!! I searched online for the answer and there  
> are no
> clear explanations for the NO METHOD ERROR.
>
>
> in my new.html.erb file I have something like this:
>
> EmpApp#new
> Find me in app/views/emp_app/new.html.erb
>
> <%= error_messages_for :employ %>
>
> <% form_for(@employ) do |f| %>
>
>
>   
>  <%= f.label :EmployDateFrom %>
>  <%= f.text_field :EmployDateFrom %>
>  
>
>
>
> 
> <%= f.submit "Create" %>
> 
> <% end %>
>
> and in my controller I have something like this:
>
>  def new
>  @employ = Employ.new
>
>  respond_to do |format|
>  format.html # new.html.erb
>  format.xml {render :xml => @employ }
>end
>  end
>
> and this is the kind of error I get no matter what I do. No matter  
> what
> I do do I get the same damn error I need TO KNOW WHY CAN ANYONE HELP  
> ME
> DOES ANYONE KNOW!!
>
>
> NoMethodError in Emp_app#new
>
> Showing app/views/emp_app/new.html.erb where line #6 raised:
>
> undefined method `employs_path' for #
>
> Extracted source (around line #6):
>
> 3:
> 4: <%= error_messages_for :employ %>
> 5:
> 6: <% form_for(@employ) do |f| %>
> 7:
> 8:
> 9:
>
> RAILS_ROOT: C:/Users/MaceWindu/Documents/Ruby/railsprojects/ 
> employeeApp
> Application Trace | Framework Trace | Full Trace
>
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:112:in
> `__send__'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:112:in
> `polymorphic_url'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:119:in
> `polymorphic_path'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> helpers/form_helper.rb:269:in
> `apply_form_for_options!'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> helpers/form_helper.rb:248:in
> `form_for'
> app/views/emp_app/new.html.erb:6
> app/controllers/emp_app_controller.rb:8:in `new'
>
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:112:in
> `__send__'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:112:in
> `polymorphic_url'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/polymorphic_routes.rb:119:in
> `polymorphic_path'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> helpers/form_helper.rb:269:in
> `apply_form_for_options!'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> helpers/form_helper.rb:248:in
> `form_for'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> renderable.rb:39:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> renderable.rb:39:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> template.rb:73:in
> `render_template'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/ 
> base.rb:256:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/base.rb:1174:in
> `render_for_file'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/base.rb:905:in
> `render_without_benchmark'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/benchmarking.rb:51:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/ 
> active_support/core_ext/benchmark.rb:8:in
> `realtime'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/benchmarking.rb:51:in
> `render'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:135:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:135:in
> `custom'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:164:in
> `call'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:164:in
> `respond'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:158:in
> `each'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:158:in
> `respond'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/mime_responds.rb:107:in
> `respond_to'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/base.rb:1253:in
> `send'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/base.rb:1253:in
> `perform_action_without_filters'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/filters.rb:617:in
> `call_filters'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/filters.rb:610:in
> `perform_action_without_benchmark'
> c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/ 
> action_controller/benchma

[Rails] NO METHOD ERROR!!!

2009-04-07 Thread Mace Windu

Its driving me crazy!! I searched online for the answer and there are no
clear explanations for the NO METHOD ERROR.


in my new.html.erb file I have something like this:

EmpApp#new
Find me in app/views/emp_app/new.html.erb

<%= error_messages_for :employ %>

<% form_for(@employ) do |f| %>


   
  <%= f.label :EmployDateFrom %>
  <%= f.text_field :EmployDateFrom %>
  




<%= f.submit "Create" %>

<% end %>

and in my controller I have something like this:

  def new
  @employ = Employ.new

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

and this is the kind of error I get no matter what I do. No matter what
I do do I get the same damn error I need TO KNOW WHY CAN ANYONE HELP ME
DOES ANYONE KNOW!!


 NoMethodError in Emp_app#new

Showing app/views/emp_app/new.html.erb where line #6 raised:

undefined method `employs_path' for #

Extracted source (around line #6):

3:
4: <%= error_messages_for :employ %>
5:
6: <% form_for(@employ) do |f| %>
7:
8:
9:

RAILS_ROOT: C:/Users/MaceWindu/Documents/Ruby/railsprojects/employeeApp
Application Trace | Framework Trace | Full Trace

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
`polymorphic_url'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:119:in
`polymorphic_path'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:269:in
`apply_form_for_options!'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:248:in
`form_for'
app/views/emp_app/new.html.erb:6
app/controllers/emp_app_controller.rb:8:in `new'

c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
`__send__'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:112:in
`polymorphic_url'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/polymorphic_routes.rb:119:in
`polymorphic_path'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:269:in
`apply_form_for_options!'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/helpers/form_helper.rb:248:in
`form_for'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/renderable.rb:39:in
`render'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/template.rb:73:in
`render_template'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_view/base.rb:256:in
`render'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1174:in
`render_for_file'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:905:in
`render_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in
`render'
c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/core_ext/benchmark.rb:8:in
`realtime'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:51:in
`render'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:135:in
`custom'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in
`call'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:164:in
`respond'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in
`each'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:158:in
`respond'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/mime_responds.rb:107:in
`respond_to'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`send'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:617:in
`call_filters'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'
c:/ruby/lib/ruby/gems/1.8/gems/actionpack-2.2.2/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'
c:/ruby/lib/ruby/gems/1.8/gems/act

[Rails] More Complex Join with Rails/ActiveRecord

2009-04-07 Thread Peter Laurens

Hi,

I have an Articles model.
And a Moderations model.
And a Users model.

Articles have many Users (moderators) through Moderations.
Users have many Articles (moderated articles) through Moderations.

This works fine so far. I can link up a user with all their moderated
articles etc.

But, I'd like a find which would select all the Articles, except it
hides (does not return) the articles the current user has moderated. I
am currently doing this in Ruby in two stages like this:

@articles_list = Article.find(:all, :conditions => ["start_date >= ?",
today], :order => 'start_date')
@articles_list -= current_user.moderated_articles if current_user

And then displaying the articles list.

This works, but I fully suspect it is cripplingly slow, and I'd also
like to paginate these articles and all the pagination tutorials seem to
warn against fetching everything in one go. This seems like good advice.

So I am seeking guidance on a join condition that would do what I want.
I'm guessing I need an inner join on the article_id on the moderations
table, but need to make sure that the user_id of those records are the
same as the current user only. So this is confusing me a bit.

Many thanks for any help you may offer!

- N
-- 
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] Application Release Tracking & Version Numbers

2009-04-07 Thread Kevin Elliott

Forgive me if this has been solved in its entirety, although I've only  
seen bits and pieces of this solved in various ways. I'm hoping a few  
of you have figured out an elegant solution to this problem.

Over time I've noticed that it would be immensely helpful if we were  
able to easily correlate which git commit version was running in all  
of our environments of our application. Capistrano is kind and stores  
this deployment version value in REVISION, and the deployment time in  
the timestamp of the deployment directory.

Seth Ladd wrote about a couple of helper methods he wrote to acquire  
these values at 
http://blog.semergence.com/2008/11/03/displaying-deployment-date-and-time-and-git-revision-number-in-rails-views

I'd like to take this up a notch and mark known good commits with  
releases (i.e. 1.0, 1.1, 1.2, 1.2.1, etc). At the footer of all pages,  
it would be excellent to be able to see something like "PROD - 1.0  
(3425)" (ENVIRONMENT - VERSION (BUILD)) where BUILD corresponds to a  
git commit hash (somehow). I'd like to be able to catalog which commit  
hash maps to which version (and do this semi-automatically, through a  
rake/cap task, aka: cap deploy:version:increment only when a major/ 
minor release occurs).

Then, I'd also like to extract all dependency version numbers, and  
combine all of this into exception reporting. So when an exception is  
thrown (gracefully to the end user with an error page), email is  
generated with:

environment (production, staging, development, etc)
particular app server hostname/ip/port
app version (1.0, 1.0.1, 1.2, 1.3, etc)
build version (3425)
git commit hash
dependent gems and plugins
versions of each gem and plugin REQUIRED for the release
versions of each gem and plugin installed

Is anyone aware of a single tool that has combined all of this  
together? There are certainly some solutions, such as  
exception_notifier, hoptoad, etc, which do the exception  
notifications, but do not handle "release management" or release  
correlation.

If not, I think this might be worthy of a plugin or gem that I'd  
consider building.

-Kevin

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



[Rails] Re: Converting a date to mysql format

2009-04-07 Thread Phlip

Chris.Mohr wrote:

> Is there an easy way to convert '13-Mar-2009 20:55 PDT' into something
> that ruby understands, so that I can output it in a format that mysql
> understands?

Does this work?

t = Time.parse('13-Mar-2009 20:55 PDT')
p t.to_s(:db)


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



[Rails] Re: Problem with MYSQL after re-installing rails

2009-04-07 Thread Gavin

@frederick

Yea - installed MYSQL from the package and it is running in the system
preferences pane- basically followed the steps on dan benjamins
tutorial on installing rails on OSX tiger.

@Eric - tried the command in terminal  - just got the same error.

Any suggestions guys?

thanks

On Apr 7, 12:11 pm, Frederick Cheung 
wrote:
> On Apr 7, 11:59 am, Ruby Rails  wrote:
>
> > Restart u'r computer or start u'r mysql server.Bassically this error occur
> > due to not running of mysql server.
>
> Hog wash.
>
>
>
> > On Tue, Apr 7, 2009 at 4:23 PM, Gavin  wrote:
>
> > > Hey all-
>
> > > Re-installed OSX yesterday and with it, Ruby and Rails
>
> > > Now when I try to run db:migrate I get the error message:
>
> > > "!!! The bundled mysql.rb driver has been removed from Rails 2.2.
> > > Please install the mysql gem and try again: gem install mysql.
> > > Rake aborted!
>
> > > no such file to load -- mysql"
>
> > > So, I try sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
>
> Sorry to ask the stupid question, but have you installed mysql itself
> along with everything else you did (and in that location)?
>
> Fred
>
> > > And get:
> > > ##
>
> > > Building native extensions.  This could take a while...
> > > ERROR:  Error installing mysql:
> > >        ERROR: Failed to build gem native extension.
>
> > > /usr/local/bin/ruby extconf.rb install mysql -- --with-mysql-dir=/usr/
> > > local/mysql
> > > checking for mysql_query() in -lmysqlclient... no
> > > checking for main() in -lm... yes
> > > checking for mysql_query() in -lmysqlclient... no
> > > checking for main() in -lz... yes
> > > checking for mysql_query() in -lmysqlclient... no
> > > checking for main() in -lsocket... no
> > > checking for mysql_query() in -lmysqlclient... no
> > > checking for main() in -lnsl... no
> > > checking for mysql_query() in -lmysqlclient... no
> > > *** extconf.rb failed ***
> > > Could not create Makefile due to some reason, probably lack of
> > > necessary libraries and/or headers.  Check the mkmf.log file for more
> > > details.  You may need configuration options.
>
> > > Provided configuration options:
> > >        --with-opt-dir
> > >        --without-opt-dir
> > >        --with-opt-include
> > >        --without-opt-include=${opt-dir}/include
> > >        --with-opt-lib
> > >        --without-opt-lib=${opt-dir}/lib
> > >        --with-make-prog
> > >        --without-make-prog
> > >        --srcdir=.
> > >        --curdir
> > >        --ruby=/usr/local/bin/ruby
> > >        --with-mysql-config
> > >        --without-mysql-config
> > >        --with-mysql-dir
> > >        --with-mysql-include
> > >        --without-mysql-include=${mysql-dir}/include
> > >        --with-mysql-lib
> > >        --without-mysql-lib=${mysql-dir}/lib
> > >        --with-mysqlclientlib
> > >        --without-mysqlclientlib
> > >        --with-mlib
> > >        --without-mlib
> > >        --with-mysqlclientlib
> > >        --without-mysqlclientlib
> > >        --with-zlib
> > >        --without-zlib
> > >        --with-mysqlclientlib
> > >        --without-mysqlclientlib
> > >        --with-socketlib
> > >        --without-socketlib
> > >        --with-mysqlclientlib
> > >        --without-mysqlclientlib
> > >        --with-nsllib
> > >        --without-nsllib
> > >        --with-mysqlclientlib
> > >        --without-mysqlclientlib
>
> > > Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/
> > > mysql-2.7 for inspection.
> > > Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/
> > > gem_make.out
>
> > > ##
>
> > > This seems to have been covered already here:
>
> > >http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...
>
> > > but I can't really follow what's happening there :S
>
> > > Could anybody advise?
>
> > > Ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin8.11.1]
> > > Rails -v: Rails 2.3.2
> > > All gems updated
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Problem with MYSQL after re-installing rails

2009-04-07 Thread Gavin

Yea - I noticed that Dean

If you work this out before me, do let me know
I'll be sure to do the same if I can get this working

:S

On Apr 7, 7:36 pm, Dean Richardson 
wrote:
> All:
>
> I'm encountering similar errors and difficulties.  When I enter:
>
> sudo env ARCHFLAGS="-arch i386" gem install mysql --
> --with-mysql-config=/usr /local/mysql/bin/mysql_config
>
> as many have suggested, I still get the same "can't find header files
> for ruby" error message:
>
> Building native extensions.  This could take a while...
> ERROR:  Error installing mysql:
>         ERROR: Failed to build gem native extension.
>
> /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
> extconf.rb install mysql --
> --with-mysql-config=/usr/local/mysql/bin/mysql_config
> can't find header files for ruby.
>
> Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7
> for inspection.
> Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
>
> Any suggestions for diagnosing my mistake here?
>
> Thanks!
>
> Dean Richardson
> --
> 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] [JOBS]Rails Developers Sought for Venture Funded Startup

2009-04-07 Thread SamH

Workstreamer LLC, a New York based startup software company pioneering
the concepts of workstreams and workstreaming, is looking to hire
additional Ruby on Rails developers to grow our engineering team.

We are currently a distributed team of US-based developers building an
enterprise-focused platform for real-time business collaboration.
We're a young and fast-paced startup, seeking motivated software and
web developers who are excited about the prospect of participating in
the growth of a ground-breaking company. Primarily, we're looking for
developers to assist in building out our web front-end, although
opportunities also exist for mobile applications, back-end
development, performance, security, and administration. We seek self-
motivated talent interested in a full-time, startup oriented job.
Location can be anywhere within the US. Occasional travel to teh New
York City area or Austin Texas may be necessary.

More on our company: Workstreamer technology combines social media,
streaming information and professional networking to enable the
creation and capture of real-time work activity between individuals
and businesses. Workstreaming technology is positioned to meet the
accelerating demands of today’s modern workforce, including
distributed collaboration, greater corporate transparency and
exponential information growth. Workstreamer has received seed funding
from Austin Ventures, a prestigious VC firm.

No firms - full time, near-full time, or interns only.

Contact Info:

i...@workstreamer.com

718.669.0001

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



[Rails] Re: Problem with MYSQL after re-installing rails

2009-04-07 Thread Frederick Cheung



On Apr 7, 7:36 pm, Dean Richardson 
wrote:
>
> Gem files will remain installed in /Library/Ruby/Gems/1.8/gems/mysql-2.7
> for inspection.
> Results logged to /Library/Ruby/Gems/1.8/gems/mysql-2.7/gem_make.out
>
> Any suggestions for diagnosing my mistake here?
>
That sounds like a different issue  ( in Gavin's case it just the
headers/libs for mysql it can't locate) - maybe you don't have all of
the stuff from the Dev tools you need ?

Fred
> Thanks!
>
> Dean Richardson
> --
> 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: Problem with MYSQL after re-installing rails

2009-04-07 Thread Frederick Cheung



On Apr 7, 7:21 pm, Gavin  wrote:
> @frederick
>
> Yea - installed MYSQL from the package and it is running in the system
> preferences pane- basically followed the steps on dan benjamins
> tutorial on installing rails on OSX tiger.
>
> @Eric - tried the command in terminal  - just got the same error.
>
> Any suggestions guys?
>
using the --with-mysql-config  option usually works for me (pass it
the location of the mysql_config thing). Also make sure you have the
32 bit version of mysql, not 64 bit.

Fred

> thanks
>
> On Apr 7, 12:11 pm, Frederick Cheung 
> wrote:
>
> > On Apr 7, 11:59 am, Ruby Rails  wrote:
>
> > > Restart u'r computer or start u'r mysql server.Bassically this error occur
> > > due to not running of mysql server.
>
> > Hog wash.
>
> > > On Tue, Apr 7, 2009 at 4:23 PM, Gavin  
> > > wrote:
>
> > > > Hey all-
>
> > > > Re-installed OSX yesterday and with it, Ruby and Rails
>
> > > > Now when I try to run db:migrate I get the error message:
>
> > > > "!!! The bundled mysql.rb driver has been removed from Rails 2.2.
> > > > Please install the mysql gem and try again: gem install mysql.
> > > > Rake aborted!
>
> > > > no such file to load -- mysql"
>
> > > > So, I try sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
>
> > Sorry to ask the stupid question, but have you installed mysql itself
> > along with everything else you did (and in that location)?
>
> > Fred
>
> > > > And get:
> > > > ##
>
> > > > Building native extensions.  This could take a while...
> > > > ERROR:  Error installing mysql:
> > > >        ERROR: Failed to build gem native extension.
>
> > > > /usr/local/bin/ruby extconf.rb install mysql -- --with-mysql-dir=/usr/
> > > > local/mysql
> > > > checking for mysql_query() in -lmysqlclient... no
> > > > checking for main() in -lm... yes
> > > > checking for mysql_query() in -lmysqlclient... no
> > > > checking for main() in -lz... yes
> > > > checking for mysql_query() in -lmysqlclient... no
> > > > checking for main() in -lsocket... no
> > > > checking for mysql_query() in -lmysqlclient... no
> > > > checking for main() in -lnsl... no
> > > > checking for mysql_query() in -lmysqlclient... no
> > > > *** extconf.rb failed ***
> > > > Could not create Makefile due to some reason, probably lack of
> > > > necessary libraries and/or headers.  Check the mkmf.log file for more
> > > > details.  You may need configuration options.
>
> > > > Provided configuration options:
> > > >        --with-opt-dir
> > > >        --without-opt-dir
> > > >        --with-opt-include
> > > >        --without-opt-include=${opt-dir}/include
> > > >        --with-opt-lib
> > > >        --without-opt-lib=${opt-dir}/lib
> > > >        --with-make-prog
> > > >        --without-make-prog
> > > >        --srcdir=.
> > > >        --curdir
> > > >        --ruby=/usr/local/bin/ruby
> > > >        --with-mysql-config
> > > >        --without-mysql-config
> > > >        --with-mysql-dir
> > > >        --with-mysql-include
> > > >        --without-mysql-include=${mysql-dir}/include
> > > >        --with-mysql-lib
> > > >        --without-mysql-lib=${mysql-dir}/lib
> > > >        --with-mysqlclientlib
> > > >        --without-mysqlclientlib
> > > >        --with-mlib
> > > >        --without-mlib
> > > >        --with-mysqlclientlib
> > > >        --without-mysqlclientlib
> > > >        --with-zlib
> > > >        --without-zlib
> > > >        --with-mysqlclientlib
> > > >        --without-mysqlclientlib
> > > >        --with-socketlib
> > > >        --without-socketlib
> > > >        --with-mysqlclientlib
> > > >        --without-mysqlclientlib
> > > >        --with-nsllib
> > > >        --without-nsllib
> > > >        --with-mysqlclientlib
> > > >        --without-mysqlclientlib
>
> > > > Gem files will remain installed in /usr/local/lib/ruby/gems/1.8/gems/
> > > > mysql-2.7 for inspection.
> > > > Results logged to /usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/
> > > > gem_make.out
>
> > > > ##
>
> > > > This seems to have been covered already here:
>
> > > >http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/...
>
> > > > but I can't really follow what's happening there :S
>
> > > > Could anybody advise?
>
> > > > Ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [i686-darwin8.11.1]
> > > > Rails -v: Rails 2.3.2
> > > > All gems updated
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: "gem install mysql" fails

2009-04-07 Thread sporkit

There is no rake file in the source directory.  I think I'm about
ready to just give up on this problem.  Maybe, upgrade my freebsd
system like i've been needing to for years and start using the ports
collection...

:(((

On Apr 7, 1:21 pm, Frederick Cheung 
wrote:
> On Apr 7, 6:14 pm,sporkit wrote:
>
> > I believe I did install gems myself at some point.  Although not after
> > installing 1.9.
>
> fine, just worried you might have installed a version of gem for 1.8
> on top of the version of gem that came with 1.9
>
>
>
> > john: find / -name gem
> > /usr/local/bin/gem
> > /usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem
> > /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem
>
> > running
>
> > /usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem list
> > /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem list
>
> > produce the same output.  neither mention mysql.  after running make
> > install on the mysql tar, that should have added it to the gems list
> > automatically?  Is there another step I'm missing?  Here's me
> > attempting to the latest version of mysql from the remote repository.
>
> make install on the mysql tar might have installed it not as a gem
> (but there might be rake files in there for building it as a gem)
>
> Fred
>
>
>
> > john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
> > gem list -r | grep mysql
> > activerecord-jdbcmysql-adapter (0.9.1)
> > dbd-mysql (0.4.2)
> > do_mysql (0.9.11)
> > jdbc-mysql (5.0.4)
> > motto-mysql (0.1.0)
> > mysql (2.7.3, 2.7)
> > mysql_replication_adapter (0.4.0)
> > mysql_retry_lost_connection (0.0.1)
>
> > john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
> > gem install mysql -v "2.7.3"
> > ERROR:  could not find gem mysql locally or in a repository
>
> > I'm totally out of ideas.  Is there a way I could clean all this up
> > and try again fresh?  Thanks for the help thus far 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] Best practice for passing vars etc...

2009-04-07 Thread elliottg

I am new to rails and I am having a hard time coming up with a clean
solution to handle passing vars to controllers and views so that they
will have the data they need to function correctly.

For instance. I have products_controller. This controller manages a
Product model, and Product belongs_to Category.

Within products_controller all CRUD actions are scoped thru the
Categories has_many association IE:

category = Category.find_by_name params[:category]
@product = category.products.find(params[:id])

In order for the products_controller actions to operate they all need
access to params[:category]. Currently I am passing that attribute
around thru a combination of hidden for_for fields and stuff like
this:
link_to 'Edit', edit_product_path(product, :category =>params
[:category])

I am running into a lot of issues keeping track of passing this info
around through the various views and actions that are in play. It
feels sloppy and prone to problems. It's like I'm working in PHP
again.

Should I use global varibles or sessions to solve these kinds of
problems?
Whats the best thing to do here?

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



[Rails] Converting a date to mysql format

2009-04-07 Thread Chris.Mohr

Is there an easy way to convert '13-Mar-2009 20:55 PDT' into something
that ruby understands, so that I can output it in a format that mysql
understands?

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



[Rails] Re: "gem install mysql" fails

2009-04-07 Thread Frederick Cheung



On Apr 7, 6:14 pm, sporkit  wrote:
> I believe I did install gems myself at some point.  Although not after
> installing 1.9.

fine, just worried you might have installed a version of gem for 1.8
on top of the version of gem that came with 1.9
>
> john: find / -name gem
> /usr/local/bin/gem
> /usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem
> /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem
>
> running
>
> /usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem list
> /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem list
>
> produce the same output.  neither mention mysql.  after running make
> install on the mysql tar, that should have added it to the gems list
> automatically?  Is there another step I'm missing?  Here's me
> attempting to the latest version of mysql from the remote repository.

make install on the mysql tar might have installed it not as a gem
(but there might be rake files in there for building it as a gem)

Fred


>
> john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
> gem list -r | grep mysql
> activerecord-jdbcmysql-adapter (0.9.1)
> dbd-mysql (0.4.2)
> do_mysql (0.9.11)
> jdbc-mysql (5.0.4)
> motto-mysql (0.1.0)
> mysql (2.7.3, 2.7)
> mysql_replication_adapter (0.4.0)
> mysql_retry_lost_connection (0.0.1)
>
> john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
> gem install mysql -v "2.7.3"
> ERROR:  could not find gem mysql locally or in a repository
>
> I'm totally out of ideas.  Is there a way I could clean all this up
> and try again fresh?  Thanks for the help thus far Fred.
>


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



[Rails] Re: STI Problem When Using Same Controller

2009-04-07 Thread Freddy Andersen

The user does not know what creditcards are in your user model. You
have to have an association in the user model if you want to do
User.first.creditcards.new

has_many :creditcards

or get the users account and then check the creditcard.. Since a user
has_many accounts you would have to get an account before you could
create a creditcard.

So something like User.first.accounts.first.creditcard.new would
explain better...

Or you could use has_many through and use the accounts model as the
through...

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



[Rails] Re: fields_for items not updating child records??

2009-04-07 Thread internetchris


Ok so I made those changes, and I am still having issues. Rather than
posting the problem on two separate forums, I will simply provide a
link to the latest problem on the railsforum. Any help is very
appreciated. Multiple models on a single form seem to be hard to
accomplish.

http://railsforum.com/viewtopic.php?id=29044

Any help is greatly appreciated.

Chris


On Apr 6, 8:43 pm, Jaryl Sim  wrote:
> You might want to try inspecting the params in the controller, add a
> "raise params.inspect" into your update action.
>
> I suspect that it is because you have not provided fields for with the
> parent form, like so:
>
> <% f.fields_for @account.owner do |i|%>
>
> If you don't put the "f." in front, rails will simply generate params
> that you can access via "params[:owner]", whereas you want something
> like "params[:account][:owner]".
>
> This is one problem, but there might be more.
>
> On Apr 7, 6:37 am, internetchris 
> wrote:
>
>
>
> > Hey everyone,
>
> > I need some help. I have an accounts controller, and am working with
> > the show view. Each account has an "owner" and a "customer". I can
> > create the accounts/owners/customers just fine, but when it comes to
> > updating I can't. I have a single account view, that uses a form, and
> > the "fields_for" command to update the customer and owners when I
> > submit the form. The account fields update just fine, but the child
> > records (owner, and customer) information does not. Here's my update
> > routine in the controller. I'm pretty new so I'm sure it's something
> > simple I'm missing.
>
> > ***account_controller
>
> > def update
>
> >   @account = Account.find(params[:id])
> >     if @account.update_attributes(params[:account])
> >       flash[:notice] = 'Account Record Saved'
> >        redirect_to(:action=>'show')
> >     else
> > flash[:warning] = 'Account Record Did Not Save!'
> >      redirect_to(:action=>'show')
> >     end
>
> >   end
>
> > ***account_"show"_view
>
> > <% form_for(:account, @account, :url => {:action => 'update'}, :html
> > => { :multipart => true, :method => :put  }) do |f|  %>
>
> > 
> > Property Information:
> > Property No:
> > <%=f.text_field :s_account_no, :size => '10'%> 
> > 
>
> > 
>
> >  
>
> > Customer Information
> >   <%fields_for @account.customer do |customer_fields|%>
> > 
> > Name:        <
> > %=customer_fields.text_field :name, :size => '48'%>
> > Address:        <
> > %=customer_fields.text_field :address, :size => '48'%>
> > City/State/Zip: <
> > %=customer_fields.text_field :city, :size => '28'%>,<
> > %=customer_fields.text_field :state, :size => '2', :maxlength => '2'%>
> > <%=customer_fields.text_field :zip, :size => '5', :maxlength => '5'%> > div>
> >  
>
> > <%end%>
>
> >   
> > 
> > 
> >  
>
> >  
>
> > Owner Information
> >   <%fields_for @account.owner do |i|%>
> > 
> > Name:        <
> > %=i.text_field :name, :size => '48'%>
> > Address:        <
> > %=i.text_field :address, :size => '48'%>
> > City/State/Zip: <
> > %=i.text_field :city, :size => '28'%>,<%=i.text_field :state, :size =>
> > '2', :maxlength => '2'%> <%=i.text_field :zip, :size =>
> > '5', :maxlength => '5'%>
> >  
>
> > <%end%>
>
> >   
>
> > <%= submit_tag "Update Account" %>
> > <%end%>
>
> > Let me know if you need more info. I'm hoping I missed something easy.
>
> > Chris
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: Getting the associated model in a join table

2009-04-07 Thread Marcelo de Moraes Serpa
Hmm, maybe I'm complicating things. Maybe a delegate to the Product class
(to get the product_id) would solve this... hmm, I will try that and let you
guys know. Well, amazing how the fact of writing to the mailing list helps
to find the solution by yourself :)

Thanks!

Marcelo.

On Tue, Apr 7, 2009 at 12:28 PM, Marcelo de Moraes Serpa <
celose...@gmail.com> wrote:

> Hello Jaryl, thanks for the reply,
>
> habtm is equivalent to has_many :through. just that the join table is not
> an entity by itself, this I know :)
>
> So, I will try to explain through an example:
>
> Let's say we have a products table:
>
> | id | name | price |
> |  1 | a   |  2.50 |
> |  2 | b   |  1.50 |
>
> A suppliers table
>
> | id | name |
> |  1 |  s_a  |
> |  2 |  s_b  |
>
> So the idea is: A product may be supplied by many different suppliers. So,
> indeed, it is a has_and_belongs_to_many relationship. The thing is, the
> relationship by itself defines the type of the supplier (if it's either a
> vendor or a manufacturer), since we have:
>
> products_suppliers table:
> | id | supplier_id | product_id | supplier_type |
> | 1  |   1 | 1  |   "vendor"  |
> | 2  |   1 |  2 | "manufacturer"|
>
> So, in tis case, supplier s_a is a "vendor" of product a and a
> "manufacturer" of product b.
>
> Product < ActiveRecord::Base
>   has_many :products_suppliers
>   has_many :suppliers, :through => :products_suppliers
> end
>
> Supplier < ActiveRecord::Base
>  has_many :products_suppliers
>  has_many :products, :through => :products_suppliers
> end
>
> ProductsSupplier < ActiveRecord::Base
>  belongs_to :product
>  belongs_to :supplier
> end
>
>
> So let's take this code
>
> p = Product.find(1)
>
>
> What I need is a specific products_suppliers related to specific combo of
> (supplier_id,product_id) keys, so I can get the supplier_type data related
> to this product+supplier. However, I the has_many relationship in Supplier
> reaturns all the products_suppliers that has supplier_id == the id of this
> supplier -- To get the specific products_supplier I would also need the id
> of the product that owns this supplier, but I can't get it. So, the first
> thing I though was something like has_one :through. That's why I said, a
> has_one relationship through a link table. The thing is, I need the
> product_id that owns this supplier from the supplier model. I might as well
> just leave AR and do some raw SQL, or maybe use sql :select statemente in
> the association to fetch the type from the link table into the association.
>
> Does that make sense?
>
> Thanks,
>
> Marcelo.
>
>
>
>
> On Mon, Apr 6, 2009 at 9:47 PM, Jaryl Sim wrote:
>
>>
>> I couldn't really get your question, but I think that what you are
>> trying to do here is to create a many to many relationship.
>>
>> Rails actually provides the has_and_belongs_to_many association for
>> this very purpose, which should help you with what you are asking (I
>> think).
>>
>>
>> http://guides.rubyonrails.org/association_basics.html#choosing-between-has-many-through-and-has-and-belongs-to-many
>>
>> On Apr 7, 6:01 am, Marcelo de Moraes Serpa 
>> wrote:
>> > Actually the question would be better put this way:
>> >
>> >  Having a has_one association via a link table (in this case
>> > products_supplier).
>> >
>> > Thanks.
>> >
>> > On Mon, Apr 6, 2009 at 3:41 PM, Marcelo de Moraes Serpa <
>> celose...@gmail.com
>> >
>> > > wrote:
>> > > Let's say we have the following models:
>> >
>> > > Product < ActiveRecord::Base
>> > >  has_many :products_suppliers
>> > >  has_many :suppliers, :through => :products_supplier
>> >
>> > > Supplier < ActiveRecord::Base
>> > >  has_many :products_suppliers
>> > >  has_many :products, :through => :products_supplier
>> >
>> > > ProductsSupplier < ActiveRecord::Base
>> > >  belongs_to :supplier
>> > >  belongs_to :product
>> > > end
>> >
>> > > Let' say we have this data in the products_suppliers table:
>> >
>> > > | supplier_id |  product_id |
>> > > |  1  |   2 |
>> > > |  1  |   1 |
>> > > |  2  |   2 |
>> > > |  2  |   1 |
>> >
>> > > So when I do this:
>> >
>> > > @suppliers = Product.find(1).suppliers, it will return an array with
>> the
>> > > suppliers with id 1 and 2.
>> >
>> > > Let's say I do this:
>> >
>> > > @supplier = @suppliers[0] #Which is the supplier with id = 1, the one
>> > > fetched from the (supplier_id = 1, product_id = 2) record in the
>> > > products_suppliers table. Ok, now I got a single instance of a
>> supplier.
>> > > **What I want is to get the product_id it was associated with in the
>> > > products_suppliers table.** (product_id = 2), might be missing
>> something
>> > > simple, but I can't seem to find a way to do that.
>> >
>> > > Any help appreciated!
>> >
>> > > Thanks,
>> >
>> > > Marcelo.
>> >>
>>
>

--~--~-~--~~~---~--~~
You received this messag

[Rails] Re: Getting the associated model in a join table

2009-04-07 Thread Marcelo de Moraes Serpa
Hello Jaryl, thanks for the reply,

habtm is equivalent to has_many :through. just that the join table is not an
entity by itself, this I know :)

So, I will try to explain through an example:

Let's say we have a products table:

| id | name | price |
|  1 | a   |  2.50 |
|  2 | b   |  1.50 |

A suppliers table

| id | name |
|  1 |  s_a  |
|  2 |  s_b  |

So the idea is: A product may be supplied by many different suppliers. So,
indeed, it is a has_and_belongs_to_many relationship. The thing is, the
relationship by itself defines the type of the supplier (if it's either a
vendor or a manufacturer), since we have:

products_suppliers table:
| id | supplier_id | product_id | supplier_type |
| 1  |   1 | 1  |   "vendor"  |
| 2  |   1 |  2 | "manufacturer"|

So, in tis case, supplier s_a is a "vendor" of product a and a
"manufacturer" of product b.

Product < ActiveRecord::Base
  has_many :products_suppliers
  has_many :suppliers, :through => :products_suppliers
end

Supplier < ActiveRecord::Base
 has_many :products_suppliers
 has_many :products, :through => :products_suppliers
end

ProductsSupplier < ActiveRecord::Base
 belongs_to :product
 belongs_to :supplier
end


So let's take this code

p = Product.find(1)


What I need is a specific products_suppliers related to specific combo of
(supplier_id,product_id) keys, so I can get the supplier_type data related
to this product+supplier. However, I the has_many relationship in Supplier
reaturns all the products_suppliers that has supplier_id == the id of this
supplier -- To get the specific products_supplier I would also need the id
of the product that owns this supplier, but I can't get it. So, the first
thing I though was something like has_one :through. That's why I said, a
has_one relationship through a link table. The thing is, I need the
product_id that owns this supplier from the supplier model. I might as well
just leave AR and do some raw SQL, or maybe use sql :select statemente in
the association to fetch the type from the link table into the association.

Does that make sense?

Thanks,

Marcelo.



On Mon, Apr 6, 2009 at 9:47 PM, Jaryl Sim  wrote:

>
> I couldn't really get your question, but I think that what you are
> trying to do here is to create a many to many relationship.
>
> Rails actually provides the has_and_belongs_to_many association for
> this very purpose, which should help you with what you are asking (I
> think).
>
>
> http://guides.rubyonrails.org/association_basics.html#choosing-between-has-many-through-and-has-and-belongs-to-many
>
> On Apr 7, 6:01 am, Marcelo de Moraes Serpa 
> wrote:
> > Actually the question would be better put this way:
> >
> >  Having a has_one association via a link table (in this case
> > products_supplier).
> >
> > Thanks.
> >
> > On Mon, Apr 6, 2009 at 3:41 PM, Marcelo de Moraes Serpa <
> celose...@gmail.com
> >
> > > wrote:
> > > Let's say we have the following models:
> >
> > > Product < ActiveRecord::Base
> > >  has_many :products_suppliers
> > >  has_many :suppliers, :through => :products_supplier
> >
> > > Supplier < ActiveRecord::Base
> > >  has_many :products_suppliers
> > >  has_many :products, :through => :products_supplier
> >
> > > ProductsSupplier < ActiveRecord::Base
> > >  belongs_to :supplier
> > >  belongs_to :product
> > > end
> >
> > > Let' say we have this data in the products_suppliers table:
> >
> > > | supplier_id |  product_id |
> > > |  1  |   2 |
> > > |  1  |   1 |
> > > |  2  |   2 |
> > > |  2  |   1 |
> >
> > > So when I do this:
> >
> > > @suppliers = Product.find(1).suppliers, it will return an array with
> the
> > > suppliers with id 1 and 2.
> >
> > > Let's say I do this:
> >
> > > @supplier = @suppliers[0] #Which is the supplier with id = 1, the one
> > > fetched from the (supplier_id = 1, product_id = 2) record in the
> > > products_suppliers table. Ok, now I got a single instance of a
> supplier.
> > > **What I want is to get the product_id it was associated with in the
> > > products_suppliers table.** (product_id = 2), might be missing
> something
> > > simple, but I can't seem to find a way to do that.
> >
> > > Any help appreciated!
> >
> > > Thanks,
> >
> > > Marcelo.
> >
>

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



[Rails] STI Problem When Using Same Controller

2009-04-07 Thread chenillen

Hi there,

I created few models with STI, parent model is Account, child models
are CreditCard, DebitCard, etc.. several sub-models, using STI.

Every model works fine individually, but I have another model user
associated with account

user has_many accounts
account belongs_to user

The problems are :

1. Cant use association to create sub-models, like
User.first.creditcards.new, but I can use User.first.accounts.new.

2. How can use same controller AccountsController to create different
sub-models, actually I hardly use Account Model.

codes are as following

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



[Rails] Re: strategies for securing attachment files from unwanted access

2009-04-07 Thread Frederick Cheung


On 7 Apr 2009, at 17:52, Alberto Perdomo wrote:

>
>> That but use X-Sendfile or X-accel-redirect: this makes apache/nginx
>> send the file, rather than funnelling it through ruby. All your rails
>> controller does (assuming the person is  authorized) is set a header
>> in the response saying 'send them this file')
>
> How does X-Sendfile behave when turned on and using mongrel for
> development on the local machine?
> Will mongrel serve the file or not?

Mongrel will ignore that. Personally I run via apache in development,  
so it all works as in production
>
> Maybe it makes sense to turn X-Sendfile off in config/environments/
> development.rb to have mongrel serve the files when developing?

Sounds reasonable if it doesn't match your development setup.

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



[Rails] Re: "gem install mysql" fails

2009-04-07 Thread sporkit

I believe I did install gems myself at some point.  Although not after
installing 1.9.

john: find / -name gem
/usr/local/bin/gem
/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem

running

/usr/local/lib/ruby/gems/1.8/gems/rubygems-update-1.3.1/bin/gem list
/usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/gem list

produce the same output.  neither mention mysql.  after running make
install on the mysql tar, that should have added it to the gems list
automatically?  Is there another step I'm missing?  Here's me
attempting to the latest version of mysql from the remote repository.


john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
gem list -r | grep mysql
activerecord-jdbcmysql-adapter (0.9.1)
dbd-mysql (0.4.2)
do_mysql (0.9.11)
jdbc-mysql (5.0.4)
motto-mysql (0.1.0)
mysql (2.7.3, 2.7)
mysql_replication_adapter (0.4.0)
mysql_retry_lost_connection (0.0.1)

john: /usr/local/lib/ruby/gems/1.9.1/gems/rubygems-update-1.3.1/bin/
gem install mysql -v "2.7.3"
ERROR:  could not find gem mysql locally or in a repository

I'm totally out of ideas.  Is there a way I could clean all this up
and try again fresh?  Thanks for the help thus far Fred.

On Apr 7, 10:53 am, Frederick Cheung 
wrote:
> On Apr 7, 4:07 pm,sporkit wrote:> Ok, I've followed 
> the instructions and compiled, installed, and tested
> > successfully.  However mysql is not showing up with the "gem list"
> > command.
>
> Did you install rubygems yourself? It was my recollection that ruby
> 1.9 shipped with rubygems built in. Might you have crushed that by
> installing it yourself ?
>
> Fred
>
> > john: gem list
>
> > *** LOCAL GEMS ***
>
> > actionmailer (2.3.2)
> > actionpack (2.3.2)
> > activerecord (2.3.2)
> > activeresource (2.3.2)
> > activesupport (2.3.2)
> > rails (2.3.2)
> > rake (0.8.4)
> > rubygems-update (1.3.1)
>
> > ---
>
> > And trying to generate a table is causing problems.
>
> > john: script/generate model TestThing name:string
> > /sporkit_data/site_data/railsProjects/jminchuk/config/boot.rb:86:in
> > `load_rubygems': undefined method `>=' for nil:NilClass
> > (NoMethodError)
>
> > On Apr 6, 5:00 pm, Frederick Cheung 
> > wrote:
>
> > > On Apr 6, 10:36 pm,sporkit wrote:> To sum this 
> > > up, gem install mysql crashes when looking for version.h.
> > > > This is happening after a fresh install of Ruby, Ruby Gems, and the
> > > > Mysql gem.  Shouldn't a fresh install of ruby create version.h and
> > > > place it in the correct directory?
>
> > > I think version.h disappeared in ruby 1.9. Looks like it's trying to
> > > build a version of the mysql gem that isn't compatible with ruby 1.9
> > > (the other errors indicate that too) - i think ruby 1.9.1 needs  2.8.1
> > > (http://rubyforge.org/frs/?group_id=4550)
>
> > > Fred
>
> > > > john: uname -a
> > > > FreeBSDsporkit.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7
> > > > 04:32:43 UTC 2006
>
> > > > john: ruby -v
> > > > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-freebsd6.1]
>
> > > > john: gem list
>
> > > > *** LOCAL GEMS ***
>
> > > > actionmailer (2.3.2)
> > > > actionpack (2.3.2)
> > > > activerecord (2.3.2)
> > > > activeresource (2.3.2)
> > > > activesupport (2.3.2)
> > > > rails (2.3.2)
> > > > rake (0.8.4)
> > > > rubygems-update (1.3.1)
>
> > > > --
> > > > john: gem install mysql
> > > > /usr/local/bin/ruby extconf.rb install mysql
> > > > checking for mysql_query() in -lmysqlclient... yes
> > > > checking for mysql_ssl_set()... yes
> > > > checking for mysql.h... no
> > > > checking for mysql/mysql.h... yes
> > > > creating Makefile
>
> > > > make
> > > > gcc -I. -I/usr/local/include/ruby-1.9.1/i386-freebsd6.1 -I/usr/local/
> > > > include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -
> > > > DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_MYSQL
> > > > _H -I/usr/local/include -fPIC -O2 -g -Wall -Wno-parentheses -omysql.o -
> > > > c mysql.c
> > > > mysql.c:6:21: version.h: No such file or directory
> > > > mysql.c: In function `make_field_obj':
> > > > mysql.c:185: warning: unused variable `hash'
> > > > mysql.c: In function `escape_string':
> > > > mysql.c:267: error: structure has no member named `len'
> > > > mysql.c:268: error: structure has no member named `len'
> > > > mysql.c:268: error: structure has no member named `ptr'
> > > > mysql.c:268: error: structure has no member named `ptr'
> > > > mysql.c:268: error: structure has no member named `len'
> > > > mysql.c: In function `real_escape_string':
>
> > > > -
>
> > > > version.h exists in the old lib directory
> > > > /usr/local/lib/ruby/1.8/i386-freebsd6.1
>
> > > > but not the new one
> > > > /usr/local/lib/ruby/1.9.1/i386-freebsd6.1
>
> > > > why is that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrail

[Rails] add record and playback sound feature

2009-04-07 Thread Zh Peng

I am working on a project that requires a feature of record and playback
voice. Does anyone have a good suggestion of approaches? The length of
voice recorded is less than ten seconds.

Thanks

Z
-- 
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: strategies for securing attachment files from unwanted access

2009-04-07 Thread Alberto Perdomo

> That but use X-Sendfile or X-accel-redirect: this makes apache/nginx
> send the file, rather than funnelling it through ruby. All your rails
> controller does (assuming the person is  authorized) is set a header
> in the response saying 'send them this file')

How does X-Sendfile behave when turned on and using mongrel for
development on the local machine?
Will mongrel serve the file or not?
Maybe it makes sense to turn X-Sendfile off in config/environments/
development.rb to have mongrel serve the files when developing?

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



[Rails] Re: Support Ruby(Rails) Growth

2009-04-07 Thread Roderick van Domburg

Charles Johnson wrote:
>> Yay for Ext JS. The concept of having a rich JavaScript client
>> application talking with a RESTful Rails application works very well for
>> back-end applications. I can heartily recommend everyone to try it.
>> SproutCore and Cappuccino are among the alternatives.
>>
>> There's this little chicken-and-egg problem between Ext JS and Rails
>> where the two have different interpretations of RESTful resources.
>> Nothing that a little customization can't fix, but following Rails
>> tradition it'd be great if Ext JS was compatible out of the box.
> 
> Of course, if the cost were the same as rails "out of the box" that 
> would be even better.

+1 on that one too. :-)

--
Roderick van Domburg
http://www.nedforce.nl
-- 
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: strategies for securing attachment files from unwanted access

2009-04-07 Thread Jack Bauer

Oddly enough, I was just reading an article about how to pull this off 
in Nginx right before coming here:

http://ramblingsonrails.com/how-to-protect-downloads-but-still-have-nginx-serve-the-files

To do so with Apache just use libxsendfile
-- 
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: Support Ruby(Rails) Growth

2009-04-07 Thread Chris Westbrook

Roderick van Domburg wrote:
> Charles Johnson wrote:
>> Of course, if the cost were the same as rails "out of the box" that 
>> would be even better.
> 
> +1 on that one too. :-)
> 
> --
> Roderick van Domburg
> http://www.nedforce.nl

It's a start, but the new beta just happens to be released as MIT 
Licensed
"Ext Core".

http://extjs.com/blog/2009/04/04/ext-core-30-beta-released/

On that same note, those of you that have a hard time with RDoc, check 
out the standard API Docs for ExtJS and Ext Core.

http://extjs.com/products/extcore/docs/

Even better, and not to hijack my own thread, but I started playing 
around with the Documentation Generator and  It works... Just find 
yourself with the Ruby (*shakes head*) "=begins" and "=end".

I would say that this is a good "RDoc Alternative" for ruby code (And 
JavaScript as well.)

http://code.google.com/p/ext-doc/
-- 
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: Partial rendering results in a blank page?

2009-04-07 Thread Neil Middleton

Neil Middleton wrote:
> I'm stuck with a bug at the moment which is puzzling me.  I have a
> layout containing some HTML and a partial (for the navigation) - there
> is nothing else there other than the yield.
> 
> 1.  If the nav is included as a partial I get nothing returned to the
> browser at all (blank page) but everything else appears normal
> 2.  If I remove the partial the page works fine
> 3.  If I put the nav code directly in the template it works fine
> 4.  if I replace the nav code in the partial with a simple string, I get
> a blank page again.
> 
> Does anyone have any ideas as to what the problem could be, or know how
> I might debug it?

Found the issue, the partial was in the layouts folder, instead of the 
relevant controller views folder.

However, Rails was throwing a ActionView::MissingTemplate Exception 
which was only visible via the debugger which is probably a bug.
-- 
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] File created using Spreadsheet Excel can't read on linux

2009-04-07 Thread Salil Gaikwad

Hi All,
  Created xls file using spreadsheet Excel is not read on linux.

I am creating an xls file are as follows

workbook = Spreadsheet::Excel.new("Filepath")
worksheet = workbook.add_worksheet("Sheet1")
   |
   |
   |
workbook.close


but when i am trying to download this it not get download.
-- 
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] Partial rendering results in a blank page?

2009-04-07 Thread Neil Middleton

I'm stuck with a bug at the moment which is puzzling me.  I have a
layout containing some HTML and a partial (for the navigation) - there
is nothing else there other than the yield.

1.  If the nav is included as a partial I get nothing returned to the
browser at all (blank page) but everything else appears normal
2.  If I remove the partial the page works fine
3.  If I put the nav code directly in the template it works fine
4.  if I replace the nav code in the partial with a simple string, I get
a blank page again.

Does anyone have any ideas as to what the problem could be, or know how
I might debug it?
-- 
Posted via http://www.ruby-forum.com/.

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



[Rails] Re: strategies for securing attachment files from unwanted access

2009-04-07 Thread Matthew MacLeod

On 7 Apr 2009, at 16:43, apm wrote:

> 2. Store attachments outside of public and serve them using a
> controller and send_file. I think this works for download links but
> what about embedding images?

There shouldn't be any reason that you can't get this to work for  
images.

One of the other possible approaches, if it suits, is to server the  
images from Amazon S3. This allows you to generate an expiring URL for  
downloading the image.

-Matt


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

2009-04-07 Thread Freddy Andersen

Lets have a look at your store controller...

The nil happens here app/controllers/store_controller.rb:9:in
`add_to_cart'

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



[Rails] Re: "gem install mysql" fails

2009-04-07 Thread Frederick Cheung



On Apr 7, 4:07 pm, sporkit  wrote:
> Ok, I've followed the instructions and compiled, installed, and tested
> successfully.  However mysql is not showing up with the "gem list"
> command.
>
Did you install rubygems yourself? It was my recollection that ruby
1.9 shipped with rubygems built in. Might you have crushed that by
installing it yourself ?

Fred
> john: gem list
>
> *** LOCAL GEMS ***
>
> actionmailer (2.3.2)
> actionpack (2.3.2)
> activerecord (2.3.2)
> activeresource (2.3.2)
> activesupport (2.3.2)
> rails (2.3.2)
> rake (0.8.4)
> rubygems-update (1.3.1)
>
> ---
>
> And trying to generate a table is causing problems.
>
> john: script/generate model TestThing name:string
> /sporkit_data/site_data/railsProjects/jminchuk/config/boot.rb:86:in
> `load_rubygems': undefined method `>=' for nil:NilClass
> (NoMethodError)
>
> On Apr 6, 5:00 pm, Frederick Cheung 
> wrote:
>
> > On Apr 6, 10:36 pm,sporkit wrote:> To sum this up, 
> > gem install mysql crashes when looking for version.h.
> > > This is happening after a fresh install of Ruby, Ruby Gems, and the
> > > Mysql gem.  Shouldn't a fresh install of ruby create version.h and
> > > place it in the correct directory?
>
> > I think version.h disappeared in ruby 1.9. Looks like it's trying to
> > build a version of the mysql gem that isn't compatible with ruby 1.9
> > (the other errors indicate that too) - i think ruby 1.9.1 needs  2.8.1
> > (http://rubyforge.org/frs/?group_id=4550)
>
> > Fred
>
> > > john: uname -a
> > > FreeBSDsporkit.com 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May 7
> > > 04:32:43 UTC 2006
>
> > > john: ruby -v
> > > ruby 1.9.1p0 (2009-01-30 revision 21907) [i386-freebsd6.1]
>
> > > john: gem list
>
> > > *** LOCAL GEMS ***
>
> > > actionmailer (2.3.2)
> > > actionpack (2.3.2)
> > > activerecord (2.3.2)
> > > activeresource (2.3.2)
> > > activesupport (2.3.2)
> > > rails (2.3.2)
> > > rake (0.8.4)
> > > rubygems-update (1.3.1)
>
> > > --
> > > john: gem install mysql
> > > /usr/local/bin/ruby extconf.rb install mysql
> > > checking for mysql_query() in -lmysqlclient... yes
> > > checking for mysql_ssl_set()... yes
> > > checking for mysql.h... no
> > > checking for mysql/mysql.h... yes
> > > creating Makefile
>
> > > make
> > > gcc -I. -I/usr/local/include/ruby-1.9.1/i386-freebsd6.1 -I/usr/local/
> > > include/ruby-1.9.1/ruby/backward -I/usr/local/include/ruby-1.9.1 -I. -
> > > DHAVE_MYSQL_SSL_SET -DHAVE_MYSQL_MYSQL
> > > _H -I/usr/local/include -fPIC -O2 -g -Wall -Wno-parentheses -omysql.o -
> > > c mysql.c
> > > mysql.c:6:21: version.h: No such file or directory
> > > mysql.c: In function `make_field_obj':
> > > mysql.c:185: warning: unused variable `hash'
> > > mysql.c: In function `escape_string':
> > > mysql.c:267: error: structure has no member named `len'
> > > mysql.c:268: error: structure has no member named `len'
> > > mysql.c:268: error: structure has no member named `ptr'
> > > mysql.c:268: error: structure has no member named `ptr'
> > > mysql.c:268: error: structure has no member named `len'
> > > mysql.c: In function `real_escape_string':
>
> > > -
>
> > > version.h exists in the old lib directory
> > > /usr/local/lib/ruby/1.8/i386-freebsd6.1
>
> > > but not the new one
> > > /usr/local/lib/ruby/1.9.1/i386-freebsd6.1
>
> > > why is that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~--~~~~--~~--~--~---



[Rails] Re: strategies for securing attachment files from unwanted access

2009-04-07 Thread Frederick Cheung



On Apr 7, 4:43 pm, apm  wrote:
> Hi,
>
> So, what can you do to protect people form accessing file they should
> not? I have compiled a list of possible strategies we have thought
> about or read about on the internet:
>

> 2. Store attachments outside of public and serve them using a
> controller and send_file. I think this works for download links but
> what about embedding images?
>
That but use X-Sendfile or X-accel-redirect: this makes apache/nginx
send the file, rather than funnelling it through ruby. All your rails
controller does (assuming the person is  authorized) is set a header
in the response saying 'send them this file')

Fred

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



[Rails] strategies for securing attachment files from unwanted access

2009-04-07 Thread apm

Hi,

we are developing an app for a company and their data has to be
private. There will be different stakeholders with different roles
accesing the application and there will be lots of attachments.

We are using paperclip to upload attachments, which are stored in the
filesystem within the public directory.

Right now, the image_tags are only rendered if you are logged in and
your role allows you to, but you can copy the URL and access the image
any time, even without logging in, because the images are served
directly and there is no controller involved. Also the URLs of images
are pretty simple like "APP_PATH/attachments/8/report.pdf" or
something like that, which makes it easy to guess other file URLs.

So, what can you do to protect people form accessing file they should
not? I have compiled a list of possible strategies we have thought
about or read about on the internet:

1. Generate random names for directories and put the files inside.
Regenerate the random directory names periodically, so attachments are
harder to hit by trying randomly and the URLs have an expiry date/
time. Seems a bit messy, IMHO.

2. Store attachments outside of public and serve them using a
controller and send_file. I think this works for download links but
what about embedding images?

3. Store attachments in DB? Similar to the previous, i guess you would
need a controller to serve the files.

Any suggestions? Any experiences, good or bad?

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

2009-04-07 Thread Jack Bauer

This feels like a mistyped variable to me. Post the controller code for 
that action though, it's probably a very simple little solution.
-- 
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: setup method in functional tests and instance variables

2009-04-07 Thread David Knorr



On 6 Apr., 17:18, Mitchell Gould 
wrote:
> Just found the answer
>
> it's worth noting that R2.0.2 subclasses ActionController::TestCase
> for functional tests (i.e. UserControllerTest), not
> ActiveSupport::TestCase. You need to explicitly change the skeleton
> test files for (user|spec|etc)_controller_test.rb files to subclass
> ActiveSupport::TestCase.
>
> So I had to change the test file skeleton class definition to
>
> ActiveSupport::TestCase
>
> from
>
> ActionController::TestCase
>
> works like a charm.
>
> Why don't they fix this?

What do mean when saying "fix this". Did you run the rails:update rake
task?

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



[Rails] Re: Adding image in pdf using pdf writer

2009-04-07 Thread Jack Bauer

Pretty straightforward error. You need to make sure you're using a PNG 
without alpha-transparency (24-bit uses them, 8-bit doesn't.)
-- 
Posted via http://www.ruby-forum.com/.

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



  1   2   >