[Rails] Re: RSpec / Cucumber painfully slow Rails 3 OSX

2011-01-22 Thread adam
Strangely - I am not getting this error when running seperate
features, only when running just "cucucmber --drb"

On Jan 23, 6:39 am, adam  wrote:
> Thank you, but I still get the same error - "uninitialized constant
> FactoryGirl (NameError)"
>
> I have also posted on the FactoryGirl 
> list:https://groups.google.com/group/factory_girl/browse_thread/thread/8de...
> (see bottom of the thread)
>
> Regards
> Adam
>
> On Jan 22, 4:05 pm, Peter Vandenabeele  wrote:
>
>
>
> > adam wrote in post #976772:
>
> > > Now to get it working properly with Cucumber and Factory Girl
> > > ("uninitialized constant Factory") ...
>
> > That could be a confusion between version 1.3 and 2.
>
> > Compare this:
>
> >https://github.com/thoughtbot/factory_girl#readmehttps://github.com/t...
>
> > You could be looking at the 1.3 documentation (telling you to
> > use the Factory class), but installed version 2.0
> > (that has the FactoryGirl class).
>
> > HTH,
>
> > Peter
>
> > --
> > 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: RSpec / Cucumber painfully slow Rails 3 OSX

2011-01-22 Thread adam
Thank you, but I still get the same error - "uninitialized constant
FactoryGirl (NameError)"

I have also posted on the FactoryGirl list:
https://groups.google.com/group/factory_girl/browse_thread/thread/8de21a97486?hl=en
(see bottom of the thread)

Regards
Adam

On Jan 22, 4:05 pm, Peter Vandenabeele  wrote:
> adam wrote in post #976772:
>
> > Now to get it working properly with Cucumber and Factory Girl
> > ("uninitialized constant Factory") ...
>
> That could be a confusion between version 1.3 and 2.
>
> Compare this:
>
> https://github.com/thoughtbot/factory_girl#readmehttps://github.com/thoughtbot/factory_girl/tree/1.3.x#readme
>
> You could be looking at the 1.3 documentation (telling you to
> use the Factory class), but installed version 2.0
> (that has the FactoryGirl class).
>
> HTH,
>
> Peter
>
> --
> 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: hot selling fashionable clothes and shoes

2011-01-22 Thread Sandy Zhu
fashion  is information era now, there are popular about online 
business.

Today,let us introduce A good company to 
everyone.http://www.newstar2010.com/

You just open it to find many good items that you are interested in.

They are generally a Web site with lots of products And the price for 
your choosing. These products are very beautiful with fashinable style 
and cheap price. The most important is that are very good quality.

Because they are factory direct sales, so the price are very 
competitive.

More choice you can browse their own pictures'albums, such as

clothes: http://www.qiqifushi.com/default-ln-en.htm
shoes: http://www.ptygmy.com/en/
underwears: http://www.dq0594.com/default-ln-en.htm
caps:  http://www.caps.com/default-ln-en.htm
sunglasses and others:  http://www.yj0594.com/Home.aspx
shoes again: http://naitashoes.v.yupoo.com/
basketball shoes: http://www.v.yupoo.com/photos/jiudingxieye/albums/
jackets: http://cnoutdoor.v.yupoo.com/

If you like, you can use the PAYPAL payment, shipment will be made 
within 24 hours after full payment. Then give you a tracking number for 
confirmation, through this tracking number you can always know where 
your goods located.

The ways of transport generally have EMS, DHL, also according to your 
needs in other ways.
EMS track website: http://www.ems.com.cn/english-main.jsp
DHL track website: http://www.dhl.com/en.html
By EMS, it will take 5 to 7 working days to arrive. By DHL, it will be 
just 3 to 4 working
days.
Open a look, make yourself a fashion penson too.
Any questions, please add the following MSN or email.

Contact MSN: newstarsa...@hotmail.com   newstara...@hotmail.com
Contact Email: newstarsa...@hotmail.com  newstara...@hotmail.com

Website: www.newstar2010.com

-- 
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.



Re: [Rails] How I do to run Rails on Apache?

2011-01-22 Thread Walter Lee Davis


On Jan 22, 2011, at 7:31 PM, Fernando wrote:


Scenario: Windows Vista - Rails 3.0.3 - Rub(ies)1.9.2-p136 & 1.8.7p330
- MySQL5.5 - Apache2.2 - git/cygwin -everything setup and working, BUT
WEBrick is becoming temperamental. I want to run Rails on Apache.

Is it possible? What should I do.

I made some simple tests like build applications with Ruby 1.9.2 and
after with 1.8.7. Rails on WEBrick set the tables and makes the  
models/

migrations and tables at MySQL.

When I use 1.9.2 everything is well, but when I do the same
application with 1.8.7, I can only access the index page made by the
controller if I change the environment to 1.9.2.

WEBrick starts, but when I call http://localhost:3000 on browser, it
keeps rotating the cursor for ages&eons till the eternity arrives and
nothing loads. If I change tha environment to 1.9.2 and make the same
call index page appears.

Anyone can give any idea on what's happening?


Well, for starters, each Ruby has its own set of gems, so you might  
want to go through your dependencies and make sure that you have the  
same set of gems installed in 1.8.7 as you do in 1.9.2. And what says  
your log in all this? When you start your application in Webrick, it  
should tell you quite explicitly what is going on, well before you try  
hitting your URL in a browser and after, too.


Walter


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



[Rails] hot selling fashionable clothes and shoes

2011-01-22 Thread Sandy Zhu
fashion  is information era now, there are popular about online
business.

Today,let us introduce A good company to
everyone.http://www.newstar2010.com/

You just open it to find many good items that you are interested in.

They are generally a Web site with lots of products And the price for
your choosing. These products are very beautiful with fashinable style
and cheap price. The most important is that are very good quality.

Because they are factory direct sales, so the price are very
competitive.

More choice you can browse their own pictures'albums, such as

clothes: http://www.qiqifushi.com/default-ln-en.htm
shoes: http://www.ptygmy.com/en/
underwears: http://www.dq0594.com/default-ln-en.htm
caps:  http://www.caps.com/default-ln-en.htm
sunglasses and others:  http://www.yj0594.com/Home.aspx
shoes again: http://naitashoes.v.yupoo.com/
basketball shoes: http://www.v.yupoo.com/photos/jiudingxieye/albums/
jackets: http://cnoutdoor.v.yupoo.com/

If you like, you can use the PAYPAL payment, shipment will be made
within 24 hours after full payment. Then give you a tracking number for
confirmation, through this tracking number you can always know where
your goods located.

The ways of transport generally have EMS, DHL, also according to your
needs in other ways.
EMS track website: http://www.ems.com.cn/english-main.jsp
DHL track website: http://www.dhl.com/en.html
By EMS, it will take 5 to 7 working days to arrive. By DHL, it will be
just 3 to 4 working
days.
Open a look, make yourself a fashion penson too.
Any questions, please add the following MSN or email.

Contact MSN: newstarsa...@hotmail.com   newstara...@hotmail.com
Contact Email: newstarsa...@hotmail.com  newstara...@hotmail.com

Website: www.newstar2010.com

-- 
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.



Re: [Rails] Update params in 2 models

2011-01-22 Thread Luke Cowell

> I have used something like this but it does not works:
> @current_teacher.update_attributes(:last_project_created=>params[:code])


If this isn't working, the first place I'd look is in params[:code]. What's in 
that at the time this runs ? 

Also don't forget you could use update_attribute in a situation like this eg:
@current_teacher.update_attribute(:last_project_created, params[:code])

update_attributes iterates over each key in the hash and calls update_attribute 
on it, so you're saving rails a step or 2.

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



[Rails] Update params in 2 models

2011-01-22 Thread Kostas L.
Hi there,
i have a form with some fields where i put info about a university
project like "name","title","code" etc.
I create this project successfully but i want to update a specific
attribute from the model teacher too. I have a field in there with the
name "last_project_created" and i want to update it with the "code"
parameter from this form.

I have used something like this but it does not works:
@current_teacher.update_attributes(:last_project_created=>params[:code])

I put this line into the create method after the @project.save line.

Any ideas what i can do???

Thanks
Kostas

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



[Rails] How I do to run Rails on Apache?

2011-01-22 Thread Fernando
Scenario: Windows Vista - Rails 3.0.3 - Rub(ies)1.9.2-p136 & 1.8.7p330
- MySQL5.5 - Apache2.2 - git/cygwin -everything setup and working, BUT
WEBrick is becoming temperamental. I want to run Rails on Apache.

Is it possible? What should I do.

I made some simple tests like build applications with Ruby 1.9.2 and
after with 1.8.7. Rails on WEBrick set the tables and makes the models/
migrations and tables at MySQL.

When I use 1.9.2 everything is well, but when I do the same
application with 1.8.7, I can only access the index page made by the
controller if I change the environment to 1.9.2.

WEBrick starts, but when I call http://localhost:3000 on browser, it
keeps rotating the cursor for ages&eons till the eternity arrives and
nothing loads. If I change tha environment to 1.9.2 and make the same
call index page appears.

Anyone can give any idea on what's happening?

Thanks a lot in anticipation.

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



Re: [Rails] Re: Relationship modelling problem

2011-01-22 Thread David Kahn
On Sat, Jan 22, 2011 at 10:29 AM, Craig Leppan  wrote:

> I think I am going to try this:
>
> Create the model Company: name:string
> Create Client: company_id:integer
> Create Supplier: company_id:integer
> Create Product: name:string
> Create Clientship: company_id:integer, product_id:integer
> Create Suppliership: company_id:integer, product_id:integer
>
> Company
> has many :clients
> has many suppliers
> has many supplierships
> has many products through supplierships
>
> Client
> belongs to :company
> has many :clientships
> has many :products, through clientship
>
> Supplier
> belongs to :company
> has many :supplierships
> has many :products through supplierships
>
> Product
> has many supplierships
> has many companies through supplierships
> has many clientship
> has many companies through clientships
>
> Suppliership
> belongs to company
> belongs to product
>
> Clientship
> belongs to company
> belongs to product
>

PS... these (Suppliership and Clientship) I think are going in a strange
direction. Object oriented should refer to actual things and these are like
modifiers or adverbs? or something

More than one model can have one or many objects, i.e.:

A Client can have many products
A Supplier can have many products
A Company can have many products

So you dont need 'Suppliership'... you can ask for:

Company.Supplier.Products for example (this is pseudocode, but you get the
picture).

I think you are over-analyzing.


>
> Generate a Controller for Clients, Products and Supplier
> Then I can use:
> Company.supierships to get suppliers (company names)
> Company.clientships to get the clients (company names)
>
> So I still have one place storing companies and they are then not split
>
> I will let everyone know where I get to : if you have any pointers or if
> there is a better way of doing it let me know
> Polymorphic can be used as its used I think to draw relations to a model
> however in this case the model is based on a relationship: If it has a
> product issues as client or supplier.
>
> --
> 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.
>
>

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



Re: [Rails] Relationship modelling problem

2011-01-22 Thread David Kahn
On Sat, Jan 22, 2011 at 4:25 AM, Craig Leppan  wrote:

> I have battled with this for ages and would love some guidance
>
> I am building an app that has:
> Companies
> Products
>
> A product belongs to a company and a company has many products and
> hence: this company is a supplier
>
> A company has many products and hence is a client
>
> Every-time I give all relationships in the models it breaks and I think
> its due to the fact that the logic is broken as the separation of
> weather I am calling for clients or suppliers is not there and the model
> as I see it is broken because of the ambiguity
>
> My models look as follows:
>
> Company
> has many products
> has many assignments
> has many products through assignments
>
> Products
> belongs to company
> has many assignments
> has many companies through assignments
>
> Assignments
> belongs to company
> belongs to product
>
> What is the best way to implement this and what controller do I use to
> call what relationship and how do I separate the difference of calling
> clients or suppliers (both being companies)
>
> I have been at this for ages and am at my bitter end in terms of trying
> to work it out myself
>

I would highly recommend you try to work this out in a test-driven manner.
That lets you start from simple to more complex and getting each piece
working before you go further. That way, when you do hit the part where you
start having problems, you have a laser focus on the problem and if it gets
fixed (and if the fix breaks something else!) I find that whatever the
issue is, going about it this way makes it much easier to solve the problem.

That said, if you do not go this route, you should probably post your
pertinent code and error messages concretely. Otherwise the person reading
your message has to go and do the same background work in their head to
reconstruct what you have already done.


>
> --
> 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.
>
>

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



Re: [Rails] Installation

2011-01-22 Thread Fernando Kosh
Justin,

"RVM is a command line tool which allows us to easily install, manage and
work with multiple ruby environments from interpreters to sets of gems. "

This post explains how install RVM on Snow Leopard:
http://www.blog.bridgeutopiaweb.com/post/how-to-install-rvm-and-rails-3-on-snow-leopard/

More info: http://rvm.beginrescueend.com/rvm/install/

Hope it can help you.

-- 
[ ]'s,


Fernando Kosh

2011/1/22 Justin C. 

> Hi All,
> I am trying to install ruby on rails using the tutorial here:
>
> http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard
>
> I am trying to compile and install Ruby but it fails. My terminal says
> make: *** [do-install-nodoc] Error 1
>
> Any help would be appreciated.
>
> --
> Posted via http://www.ruby-forum.com/.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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



[Rails] ANN: drifter and drifter-rails

2011-01-22 Thread Ahmed Adam
Hi everyone.  I've just released my first two gems, drifter and
drifter-rails. Drifter is a simple geocoding library for ruby and
drifter-rails provides distance based finders for ActiveRecord 3
(supports postgresql and mysql at present).  Each project#s readme
file has usage instructions and examples:

https://github.com/ahmedrb/drifter
https://github.com/ahmedrb/drifter-rails

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



[Rails] Installation

2011-01-22 Thread Justin C.
Hi All,
I am trying to install ruby on rails using the tutorial here:
http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard

I am trying to compile and install Ruby but it fails. My terminal says
make: *** [do-install-nodoc] Error 1

Any help would be appreciated.

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

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



[Rails] table of contents in RDiscount

2011-01-22 Thread JimB
I'm using RDiscount  with the generate_toc (generate table of
contents) option for a wiki on my site.  But I have no idea how to
coax a TOC out of a wiki page.   Can someone give me a clue?

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



Re: [Rails] libxml-ruby sax parsing open-uri

2011-01-22 Thread Jeffrey L. Taylor
Quoting Chris Armstrong :
> Hi there,
> 
> I need to connect to an url to download and process an XML document.
> Then run through the XML document and save elements in the database.
> 
> There are many howto's on the internet regarding parsing xml files with
> SAX opening a file on the filesystem and reading through it. But I could
> not find an example of how to read an URL while processing the xml.
> 

The Ruby wrapper around the libxml2 C library (libxml-ruby) supports the DOM
(parse whole file into a data structure that can be searched, editted, written
back out), SAX, and Reader models.  All will handle any IO like class.  They
don't have to have the whole input in memory, but can repeated call IO#read to
parse data as read rather than all at once.  Unless you have a hard
requirement to use SAX, look at the Reader model.  IMHO, it is easier to use.
The documentation (http://libxml.rubyforge.org/rdoc/index.html) is very good.
Better than libxml2's documentation, IMHO.

HTH,
  Jeffrey

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



[Rails] rendering json for a child model with multiple parent models

2011-01-22 Thread Charles Bedrosian
I am trying to render json for a child model that belongs_to two parent
models.  The models represent a college course offering. Given a course,
I want to show what sections (instances of a course) are offered, and
during what terms (ie semester)

Model:
  Course
has_many sections

  Term
has_many sections

  Section
belongs_to course
belongs_to section

I want to render the single course's details along with all sections. As
such:

  render :json => @course.to_json(:include => :sections)

However, I would also like to include the term data above sections as a
means to group the sections.

  courseA
term1
  section_a
  section_b
term2
  section_c
  section_d

Course is aware of Term only through Section

How can I go about doing this in the controller or the model?  Can I
accomplish this through to_json or must I override to_json?  Perhaps my
model associations need to be adjusted?

Thanks in advance!

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

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



Re: [Rails] libxml-ruby sax parsing open-uri

2011-01-22 Thread Walter Lee Davis


On Jan 22, 2011, at 12:39 PM, Chris Armstrong wrote:


Hi there,

I need to connect to an url to download and process an XML document.
Then run through the XML document and save elements in the database.

There are many howto's on the internet regarding parsing xml files  
with
SAX opening a file on the filesystem and reading through it. But I  
could

not find an example of how to read an URL while processing the xml.

SAX will be useless if the content from the URL has to be downloaded
completely before processing it. The RAM will still fill up.


Not sure if this will help, but if you use the open-uri gem, you can  
open a file from a URL. I use it in a converter I'm working on right  
at this moment:


require 'rubygems'
require 'nokogiri'
require 'open-uri'

#here I'm loading the xsd from W3 directly
xsd = 
Nokogiri::XML::Schema(open('http://www.w3.org/2002/08/xhtml/xhtml1-strict.xsd'))

...etc...

I'm not at all sure that this will save you on RAM, I'm loading temp  
files in another part of this script (from the filesystem) and ripping  
through them with regular expressions one line at a time, but after  
all that's done, I open the partially-transformed file with Nokogiri  
in one large bite and do all sorts of things to it. Some of these  
files are 10 - 20MB of XML text. It's currently working fine inside a  
hard limit of 2GB of RAM. I wouldn't be surprised if Nokogiri does  
some very clever things to manage its memory footprint, because it  
certainly works much more efficiently than the previous generation of  
this system, which used XSLT and Saxon, and crapped out over 6MB of  
input.


Walter



Is there somebody that has a solution for this problem or maybe a  
sample
snippet on how to deal with this in Ruby or Rails? I don't care if  
it is

libxml, rexml or something else as long less RAM will be used.

Thanks for your help.
Chris

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

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




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



[Rails] libxml-ruby sax parsing open-uri

2011-01-22 Thread Chris Armstrong
Hi there,

I need to connect to an url to download and process an XML document.
Then run through the XML document and save elements in the database.

There are many howto's on the internet regarding parsing xml files with
SAX opening a file on the filesystem and reading through it. But I could
not find an example of how to read an URL while processing the xml.

SAX will be useless if the content from the URL has to be downloaded
completely before processing it. The RAM will still fill up.

Is there somebody that has a solution for this problem or maybe a sample
snippet on how to deal with this in Ruby or Rails? I don't care if it is
libxml, rexml or something else as long less RAM will be used.

Thanks for your help.
Chris

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

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 18:15, Colin Law  wrote:

> That is interesting, I guess it is because you have already loaded
> user and have not told it that its deliveries have changed under its
> feet so to speak.  I suspect that if you did user = Ruser.first again
> it would be ok.  If you use the << or build methods then you should
> not have that problem.  You said previously that you had problems
> finding tutorials with the through construct, if you work through some
> just using has_many and belongs_to you will get the basic principles
> and the through bit should not be a problem.

Thanks for your help.

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 16:58, Mauro  wrote:
> On 22 January 2011 17:51, Colin Law  wrote:
>> On 22 January 2011 16:42, Mauro  wrote:
>>> On 22 January 2011 17:39, Colin Law  wrote:
>>>
 Can you post the complete console output please.
>>>
>>> It works if I close and restart console.
>>
>> Closed and restarted after doing what?
>
> I do:
>
>
> irb(main):001:0> user=Ruser.first
> => # "zz.", birthdate: nil, homeaddress: "x", homepostalcode:
> "1", homelocality: "", fiscalcode: "01",
> contractnumber: "30236", squaremeters: 56, category: 101,
> taxedaddress: "zzz\r\n", created_at: "2011-01-15 17:26:44",
> updated_at: "2011-01-15 17:26:44">
>
> irb(main):004:0> bag=Bag.first
> => # updated_at: "2011-01-15 23:32:01">
>
> irb(main):010:0> Delivery.create(:ruser_id=>user.id,
> :bag_id=>bag.id,:delivery_at=>'2011-01-01')
> => # "2011-01-01", created_at: "2011-01-22 16:32:10", updated_at:
> "2011-01-22 16:32:10">
>
> irb(main):012:0> user.deliveries
> => []
> irb(main):013:0> user.bags
> => []
>
> irb(main):014:0> exit
>
> jruby -S rails console
>
> irb(main):002:0> user.deliveries
> => [# "2011-01-01", created_at: "2011-01-22 16:32:10", updated_at:
> "2011-01-22 16:32:10">]
> irb(main):003:0> user.bags
> => [# updated_at: "2011-01-15 23:32:01">]

That is interesting, I guess it is because you have already loaded
user and have not told it that its deliveries have changed under its
feet so to speak.  I suspect that if you did user = Ruser.first again
it would be ok.  If you use the << or build methods then you should
not have that problem.  You said previously that you had problems
finding tutorials with the through construct, if you work through some
just using has_many and belongs_to you will get the basic principles
and the through bit should not be a problem.

Colin

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 17:51, Colin Law  wrote:
> On 22 January 2011 16:42, Mauro  wrote:
>> On 22 January 2011 17:39, Colin Law  wrote:
>>
>>> Can you post the complete console output please.
>>
>> It works if I close and restart console.
>
> Closed and restarted after doing what?

I do:


irb(main):001:0> user=Ruser.first
=> #

irb(main):004:0> bag=Bag.first
=> #

irb(main):010:0> Delivery.create(:ruser_id=>user.id,
:bag_id=>bag.id,:delivery_at=>'2011-01-01')
=> #

irb(main):012:0> user.deliveries
=> []
irb(main):013:0> user.bags
=> []

irb(main):014:0> exit

jruby -S rails console

irb(main):002:0> user.deliveries
=> [#]
irb(main):003:0> user.bags
=> [#]

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 16:42, Mauro  wrote:
> On 22 January 2011 17:39, Colin Law  wrote:
>
>> Can you post the complete console output please.
>
> It works if I close and restart console.

Closed and restarted after doing what?

Colin

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 17:39, Colin Law  wrote:

> Can you post the complete console output please.

It works if I close and restart console.

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 16:33, Mauro  wrote:
> On 22 January 2011 17:25, Colin Law  wrote:
>> On 22 January 2011 16:13, Mauro  wrote:
>>> On 22 January 2011 17:09, Colin Law  wrote:
 On 22 January 2011 15:47, Mauro  wrote:
> On 22 January 2011 16:42, Colin Law  wrote:
>
>> Yes, that is fine.  In that case you obviously need a Delivery model
>> and a deliveries table, otherwise you will have no way of setting the
>> date.
>
> Ok, this now it's clear.
> But how can I assign bags with delivered_at to users?
> I've created users and bags, then I've tried:
> user=User.first, bag=Bag.first
> Delivery.create(:user_id=>user.id, :bag_id=>bag.id: 
> delivered_at=>'2011-01-01')
> but when I do user.deliveries I have no data and also for user.bags.
>>
>> This won't work with the class definitions you post below as the class
>> is Ruser not User.
>
> Sorry for my mistake but what I've posted is correct, I've write
> user=User.first but it is user=Ruser.first.
>
>> What happens if you open a ruby console (rails console if using rails
>> 3, script/console otherwise) and enter the lines above (but using the
>> correct class names)?
>
> user=Ruser.first
> bag=Bag.first
> Delivery.create(:ruser_id=>user.id, 
> :bag_id=>bag.id,:delivery_at=>'2011-01-01')
> user.deliveries
> []
> user.bags
> []

Can you post the complete console output please.

Colin

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 17:25, Colin Law  wrote:
> On 22 January 2011 16:13, Mauro  wrote:
>> On 22 January 2011 17:09, Colin Law  wrote:
>>> On 22 January 2011 15:47, Mauro  wrote:
 On 22 January 2011 16:42, Colin Law  wrote:

> Yes, that is fine.  In that case you obviously need a Delivery model
> and a deliveries table, otherwise you will have no way of setting the
> date.

 Ok, this now it's clear.
 But how can I assign bags with delivered_at to users?
 I've created users and bags, then I've tried:
 user=User.first, bag=Bag.first
 Delivery.create(:user_id=>user.id, :bag_id=>bag.id: 
 delivered_at=>'2011-01-01')
 but when I do user.deliveries I have no data and also for user.bags.
>
> This won't work with the class definitions you post below as the class
> is Ruser not User.

Sorry for my mistake but what I've posted is correct, I've write
user=User.first but it is user=Ruser.first.

> What happens if you open a ruby console (rails console if using rails
> 3, script/console otherwise) and enter the lines above (but using the
> correct class names)?

user=Ruser.first
bag=Bag.first
Delivery.create(:ruser_id=>user.id, :bag_id=>bag.id,:delivery_at=>'2011-01-01')
user.deliveries
[]
user.bags
[]

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 16:16, Mauro  wrote:
> On 22 January 2011 17:09, Colin Law  wrote:
>
>> There are much better ways of doing that, but that should work.
>
> I've not found any exhaustive examples of has_many through.
> Which are the better ways?

Did you work through the Rails Guide on Associations as I suggested?
Note particularly << and the .build methods.  I would get what you
have basically working first in the console as in my previous post.

Colin

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



[Rails] Re: Relationship modelling problem

2011-01-22 Thread Craig Leppan
I think I am going to try this:

Create the model Company: name:string
Create Client: company_id:integer
Create Supplier: company_id:integer
Create Product: name:string
Create Clientship: company_id:integer, product_id:integer
Create Suppliership: company_id:integer, product_id:integer

Company
has many :clients
has many suppliers
has many supplierships
has many products through supplierships

Client
belongs to :company
has many :clientships
has many :products, through clientship

Supplier
belongs to :company
has many :supplierships
has many :products through supplierships

Product
has many supplierships
has many companies through supplierships
has many clientship
has many companies through clientships

Suppliership
belongs to company
belongs to product

Clientship
belongs to company
belongs to product

Generate a Controller for Clients, Products and Supplier
Then I can use:
Company.supierships to get suppliers (company names)
Company.clientships to get the clients (company names)

So I still have one place storing companies and they are then not split

I will let everyone know where I get to : if you have any pointers or if 
there is a better way of doing it let me know
Polymorphic can be used as its used I think to draw relations to a model 
however in this case the model is based on a relationship: If it has a 
product issues as client or supplier.

-- 
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.



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 16:13, Mauro  wrote:
> On 22 January 2011 17:09, Colin Law  wrote:
>> On 22 January 2011 15:47, Mauro  wrote:
>>> On 22 January 2011 16:42, Colin Law  wrote:
>>>
 Yes, that is fine.  In that case you obviously need a Delivery model
 and a deliveries table, otherwise you will have no way of setting the
 date.
>>>
>>> Ok, this now it's clear.
>>> But how can I assign bags with delivered_at to users?
>>> I've created users and bags, then I've tried:
>>> user=User.first, bag=Bag.first
>>> Delivery.create(:user_id=>user.id, :bag_id=>bag.id: 
>>> delivered_at=>'2011-01-01')
>>> but when I do user.deliveries I have no data and also for user.bags.

This won't work with the class definitions you post below as the class
is Ruser not User.

What happens if you open a ruby console (rails console if using rails
3, script/console otherwise) and enter the lines above (but using the
correct class names)?

Colin

>>
>> There are much better ways of doing that, but that should work.  Can
>> you post the class definitions for your three classes, and also
>> db/schema.rb?
>
> Yes:
>
> class Ruser < ActiveRecord::Base
>  has_many :deliveries
>  has_many :bags, :through => :deliveries
>  has_one :document
>  default_scope :order => 'fullname ASC'
>
>  def self.search(fullname)
>    where('fullname ILIKE ?', "#{fullname}%") if fullname
>  end
> end
>
>
> class Bag < ActiveRecord::Base
>  has_many :deliveries
>  has_many :rusers, :through => :deliveries
> end
>
> class Delivery < ActiveRecord::Base
>  belongs_to :ruser
>  belongs_to :bag
> end
>
> ActiveRecord::Schema.define(:version => 20110114084202) do
>
>  create_table "bags", :force => true do |t|
>    t.string   "bag_type"
>    t.datetime "created_at"
>    t.datetime "updated_at"
>  end
>
> create_table "delegates", :force => true do |t|
>    t.string   "fullname"
>    t.datetime "created_at"
>    t.datetime "updated_at"
>  end
>
>  create_table "deliveries", :force => true do |t|
>    t.integer  "ruser_id",    :limit => 10
>    t.integer  "bag_id",      :limit => 10
>    t.date     "delivery_at"
>    t.datetime "created_at"
>    t.datetime "updated_at"
>  end
>
>  create_table "documents", :force => true do |t|
>    t.string   "doctype"
>    t.string   "docnumber"
>    t.integer  "ruser_id",    :limit => 10
>    t.integer  "delegate_id", :limit => 10
>    t.datetime "created_at"
>    t.datetime "updated_at"
>
>
> end
>
>  create_table "rusers", :force => true do |t|
>    t.integer  "year",           :limit => 10
>    t.integer  "code",           :limit => 10
>    t.string   "fullname"
>    t.date     "birthdate"
>    t.string   "homeaddress"
>    t.string   "homepostalcode", :limit => 6
>    t.string   "homelocality"
>    t.string   "fiscalcode",     :limit => 16
>    t.string   "contractnumber"
>    t.integer  "squaremeters",   :limit => 10
>    t.integer  "category",       :limit => 10
>    t.string   "taxedaddress"
>    t.datetime "created_at"
>    t.datetime "updated_at"
>  end
>
> end
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 17:09, Colin Law  wrote:

> There are much better ways of doing that, but that should work.

I've not found any exhaustive examples of has_many through.
Which are the better ways?

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 17:09, Colin Law  wrote:
> On 22 January 2011 15:47, Mauro  wrote:
>> On 22 January 2011 16:42, Colin Law  wrote:
>>
>>> Yes, that is fine.  In that case you obviously need a Delivery model
>>> and a deliveries table, otherwise you will have no way of setting the
>>> date.
>>
>> Ok, this now it's clear.
>> But how can I assign bags with delivered_at to users?
>> I've created users and bags, then I've tried:
>> user=User.first, bag=Bag.first
>> Delivery.create(:user_id=>user.id, :bag_id=>bag.id: 
>> delivered_at=>'2011-01-01')
>> but when I do user.deliveries I have no data and also for user.bags.
>
> There are much better ways of doing that, but that should work.  Can
> you post the class definitions for your three classes, and also
> db/schema.rb?

Yes:

class Ruser < ActiveRecord::Base
  has_many :deliveries
  has_many :bags, :through => :deliveries
  has_one :document
  default_scope :order => 'fullname ASC'

  def self.search(fullname)
where('fullname ILIKE ?', "#{fullname}%") if fullname
  end
end


class Bag < ActiveRecord::Base
  has_many :deliveries
  has_many :rusers, :through => :deliveries
end

class Delivery < ActiveRecord::Base
  belongs_to :ruser
  belongs_to :bag
end

ActiveRecord::Schema.define(:version => 20110114084202) do

  create_table "bags", :force => true do |t|
t.string   "bag_type"
t.datetime "created_at"
t.datetime "updated_at"
  end

create_table "delegates", :force => true do |t|
t.string   "fullname"
t.datetime "created_at"
t.datetime "updated_at"
  end

  create_table "deliveries", :force => true do |t|
t.integer  "ruser_id",:limit => 10
t.integer  "bag_id",  :limit => 10
t.date "delivery_at"
t.datetime "created_at"
t.datetime "updated_at"
  end

  create_table "documents", :force => true do |t|
t.string   "doctype"
t.string   "docnumber"
t.integer  "ruser_id",:limit => 10
t.integer  "delegate_id", :limit => 10
t.datetime "created_at"
t.datetime "updated_at"


end

  create_table "rusers", :force => true do |t|
t.integer  "year",   :limit => 10
t.integer  "code",   :limit => 10
t.string   "fullname"
t.date "birthdate"
t.string   "homeaddress"
t.string   "homepostalcode", :limit => 6
t.string   "homelocality"
t.string   "fiscalcode", :limit => 16
t.string   "contractnumber"
t.integer  "squaremeters",   :limit => 10
t.integer  "category",   :limit => 10
t.string   "taxedaddress"
t.datetime "created_at"
t.datetime "updated_at"
  end

end

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 15:47, Mauro  wrote:
> On 22 January 2011 16:42, Colin Law  wrote:
>
>> Yes, that is fine.  In that case you obviously need a Delivery model
>> and a deliveries table, otherwise you will have no way of setting the
>> date.
>
> Ok, this now it's clear.
> But how can I assign bags with delivered_at to users?
> I've created users and bags, then I've tried:
> user=User.first, bag=Bag.first
> Delivery.create(:user_id=>user.id, :bag_id=>bag.id: 
> delivered_at=>'2011-01-01')
> but when I do user.deliveries I have no data and also for user.bags.

There are much better ways of doing that, but that should work.  Can
you post the class definitions for your three classes, and also
db/schema.rb?

Colin

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



[Rails] Re: RSpec / Cucumber painfully slow Rails 3 OSX

2011-01-22 Thread Peter Vandenabeele
adam wrote in post #976772:
> Now to get it working properly with Cucumber and Factory Girl
> ("uninitialized constant Factory") ...

That could be a confusion between version 1.3 and 2.

Compare this:

https://github.com/thoughtbot/factory_girl#readme
https://github.com/thoughtbot/factory_girl/tree/1.3.x#readme

You could be looking at the 1.3 documentation (telling you to
use the Factory class), but installed version 2.0
(that has the FactoryGirl class).

HTH,

Peter

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

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



[Rails] Re: Rails: Developing on Win7?

2011-01-22 Thread pepe
I have been developing in Windows for a while now and it's true that
there is no much support or love for it in the RoR world. If you
really want to keep going with Windows, though, if I were you I would
get the rubyinstaller and DevKit right away from 
http://rubyinstaller.org/downloads.
To install DevKit follow instructions at
https://github.com/oneclick/rubyinstaller/wiki/Development-Kit.

Most of the problems I have had working with Windows were because of
the DB adapters.

To work with MS SQL you will need 2 gems:
activerecord-sqlserver-adapter
ruby-odbc

Working with MS SQL you will probably want to stick to ODBC so you
will need to create a System DSN. In Windows 7 first try to create it
the regular way but it probably will not work. If it does not work
then you will need to delete what you just created and then use the
executable at C:\Windows\SysWOW64\odbcad32.exe. This is the 32-bit
version.

To work with Oracle you will also need 2 gems:
activerecord-oracle_enhanced-adapter
ruby-oci8

Good luck

On Jan 21, 7:06 pm, Ben Giordano  wrote:
> Looking to learn Rails but hoping to stick with Win7/xp as all of the
> machines I work on run one of those two OSs. Would hate to be stuck to
> my laptop for development b/c its the only machine I have running
> ubuntu. Am I shooting myself in the foot by trying to learn rails on
> windows?

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 16:42, Colin Law  wrote:

> Yes, that is fine.  In that case you obviously need a Delivery model
> and a deliveries table, otherwise you will have no way of setting the
> date.

Ok, this now it's clear.
But how can I assign bags with delivered_at to users?
I've created users and bags, then I've tried:
user=User.first, bag=Bag.first
Delivery.create(:user_id=>user.id, :bag_id=>bag.id: delivered_at=>'2011-01-01')
but when I do user.deliveries I have no data and also for user.bags.

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 15:38, Mauro  wrote:
> On 22 January 2011 16:22, Colin Law  wrote:
>> On 22 January 2011 15:13, Mauro  wrote:
>>> I don't find useful examples on using has_many through associations.
>>> First of all I need to know if it is necessary to have a model.
>>> I have this type of association:
>>> models: User, Bag.
>>> User has_many :deliveries, has_many :bags, :through => :deliveries,
>>> Bag has_many :deliveries, has_many :ruser, :through => :deliveries.
>>> I need to create Delivery model?
>>
>> Yes, Delivery belongs_to user and belongs_to bag.  But if there is no
>> other data in Delivery then you could use
>> User has_and_belongs_to_many :bags
>> Bag has_and_belongs_to_many :users
>> then you don't need deliveries, but you still need to provide a table
>> bags_users containing the ids.
>
> In Delivery I have the attribute delivered_at of type date.
> This is why I used :through => deliveries, I think this is correct.
> Isn't it?

Yes, that is fine.  In that case you obviously need a Delivery model
and a deliveries table, otherwise you will have no way of setting the
date.

Colin

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Mauro
On 22 January 2011 16:22, Colin Law  wrote:
> On 22 January 2011 15:13, Mauro  wrote:
>> I don't find useful examples on using has_many through associations.
>> First of all I need to know if it is necessary to have a model.
>> I have this type of association:
>> models: User, Bag.
>> User has_many :deliveries, has_many :bags, :through => :deliveries,
>> Bag has_many :deliveries, has_many :ruser, :through => :deliveries.
>> I need to create Delivery model?
>
> Yes, Delivery belongs_to user and belongs_to bag.  But if there is no
> other data in Delivery then you could use
> User has_and_belongs_to_many :bags
> Bag has_and_belongs_to_many :users
> then you don't need deliveries, but you still need to provide a table
> bags_users containing the ids.

In Delivery I have the attribute delivered_at of type date.
This is why I used :through => deliveries, I think this is correct.
Isn't it?

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



Re: [Rails] has_many :through best practices.

2011-01-22 Thread Colin Law
On 22 January 2011 15:13, Mauro  wrote:
> I don't find useful examples on using has_many through associations.
> First of all I need to know if it is necessary to have a model.
> I have this type of association:
> models: User, Bag.
> User has_many :deliveries, has_many :bags, :through => :deliveries,
> Bag has_many :deliveries, has_many :ruser, :through => :deliveries.
> I need to create Delivery model?

Yes, Delivery belongs_to user and belongs_to bag.  But if there is no
other data in Delivery then you could use
User has_and_belongs_to_many :bags
Bag has_and_belongs_to_many :users
then you don't need deliveries, but you still need to provide a table
bags_users containing the ids.
I tend to favour having a model though, and using :through as you have
suggested, especially if the join table has some meaning in the real
world (such as deliveries).

Have you seen the Rails Guide on ActiveRecord Associations, I think it
should have examples of both of these strategies.

Colin

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

2011-01-22 Thread dsadaka
Kai,

I've gone through this same headache.  I too wanted to use a helper
but couldn't.  Have you considered using content_for in view and then
reference it in the  section of the layout to generate the
javascript?

I couldn't do it that way because I was doing AJAX calls so the 
section didn't change.

HTH,
Dan

On Jan 22, 6:33 am, Kai Schlamp  wrote:
> On Jan 22, 8:07 am, Marnen Laibow-Koser  wrote:
>
> > KaiSchlampwrote in post #976711:
>
> > > Uuups, I just found out that HTML links behave the same way ... it
> > > seems I am too pampered with Rails link helpers ;-)
>
> > Apparently so.  If you don't understand relative URLs, you have no
> > business doing Web development.
>
> Thanks for the suggestion :-P
>
> > > But I still wonder
> > > what the easiest way would be to build correct URLs for Javascript
> > > then.
>
> > Use absolute URLs (the *_url helpers will produce these).
>
> That is not an option for Javascript files that live in public/
> javascript, as those won't be generated. An option I guess would be to
> set some kind of data-url tag and query that by using Javascript. But
> I handle it the pure Javascript way now with a little helper function.

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



[Rails] Re: RSpec / Cucumber painfully slow Rails 3 OSX

2011-01-22 Thread adam
Thanks guys,

got autotest running now with the hack, working like a charm - now I
remember that sometimes I do actually enjoy coding! :)

Now to get it working properly with Cucumber and Factory Girl
("uninitialized constant Factory") ...

On Jan 21, 7:12 pm, "Arailsdemo A."  wrote:
> > But don't you always need to do that?  Isn't that the task that clears
> > out the test DB?  Or is that not an issue since you're (hopefully)
> > running your specs transactionally?
>
> As far as I can tell, the difference between 'rake spec' and 'rspec
> spec' is 'db:test:prepare'. When all tests pass with 'rake spec',
> they're also passing with 'rspec spec', only faster. If you check the
> test database after running 'rspec spec', it should be empty. So that's
> why I think 'rake spec' isn't necessary, unless the database schema has
> changed.
>
> I do have
>
>         config.use_transactional_fixtures = true
>
> in my spec_helper file. If the setting is set to false, then the
> database could have residual data in it after running the tests.
>
> --
> 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] has_many :through best practices.

2011-01-22 Thread Mauro
I don't find useful examples on using has_many through associations.
First of all I need to know if it is necessary to have a model.
I have this type of association:
models: User, Bag.
User has_many :deliveries, has_many :bags, :through => :deliveries,
Bag has_many :deliveries, has_many :ruser, :through => :deliveries.
I need to create Delivery model?

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



[Rails] Re: - Model Inheritance

2011-01-22 Thread Frederick Cheung


On Jan 22, 12:39 pm, Pedro Bernardes  wrote:
> but how would I do that since all the data is missing?
>

Can you see it using the mongo console? I reckon the data isn't
missing, mongomapper is just looking for it in the wrong collection.

Fred
> well, thanks for the help! I'll keep trying.
>
> 2011/1/22 Frederick Cheung 
>
>
>
>
>
> > On Jan 22, 3:39 am, Pedro Bernardes  wrote:
> > > This is exactly it, I'm trying to add the topics behavior to the default
> > > behavior of universities and University.all just returns []
>
> > > How do I change the University? I was unable to find references to it.
>
> > I've only dabbled with mongomapper, but my understanding is that if
> > you move from two separate collections to a single collection
> > inheritance setup, you're going to need to move all the data from the
> > old universities collection to the topics collection
>
> > Fred
>
> > > 2011/1/21 Frederick Cheung 
>
> > > > On Jan 21, 10:03 pm, Pedro Bernardes  wrote:
> > > > > Hi, I'm new to this list and to rails, so I'm sorry if this subject
> > is
> > > > > repetead or too obvious.
>
> > > > > I have two models: Topic and University, both in production. I want
> > to
> > > > make
> > > > > University to inherit from Topic, but when I do this:
>
> > > > >       University < Topic
>
> > > > > My universities data just disapear (and reapears if the changes are
> > > > undone).
>
> > > > Are you trying to setup a single table inheritance type thing? When
> > > > you say that your universities data disappears, do you mean that
> > > > University.all no longer returns any data?
> > > > Switching from your previous setup to a single table inheritance
> > > > situation means that mongomapper will be looking in the topics
> > > > collection when you do University.all, so I'm not surprised that your
> > > > university data would appear to vanish, if you haven't done anything
> > > > to move it from its previous collection.
>
> > > > Fred
>
> > > > > I'm using mongomapper and mongodb. The code is pretty big sp I'll
> > post
> > > > then
> > > > > only if necessarily. I think this must be easy to solve.
>
> > > > > ps: I've tried the deprecated _type but didn't work.
>
> > > > > 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 > > >  e...@googlegroups.com> > e...@googlegroups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-talk@googlegroups.com.
> > To unsubscribe from this group, send email to
> > rubyonrails-talk+unsubscr...@googlegroups.com > e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

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



Re: [Rails] Re: - Model Inheritance

2011-01-22 Thread Pedro Bernardes
but how would I do that since all the data is missing?

well, thanks for the help! I'll keep trying.

2011/1/22 Frederick Cheung 

>
>
> On Jan 22, 3:39 am, Pedro Bernardes  wrote:
> > This is exactly it, I'm trying to add the topics behavior to the default
> > behavior of universities and University.all just returns []
> >
> > How do I change the University? I was unable to find references to it.
> >
>
> I've only dabbled with mongomapper, but my understanding is that if
> you move from two separate collections to a single collection
> inheritance setup, you're going to need to move all the data from the
> old universities collection to the topics collection
>
> Fred
>
> > 2011/1/21 Frederick Cheung 
> >
> >
> >
> >
> >
> > > On Jan 21, 10:03 pm, Pedro Bernardes  wrote:
> > > > Hi, I'm new to this list and to rails, so I'm sorry if this subject
> is
> > > > repetead or too obvious.
> >
> > > > I have two models: Topic and University, both in production. I want
> to
> > > make
> > > > University to inherit from Topic, but when I do this:
> >
> > > >   University < Topic
> >
> > > > My universities data just disapear (and reapears if the changes are
> > > undone).
> >
> > > Are you trying to setup a single table inheritance type thing? When
> > > you say that your universities data disappears, do you mean that
> > > University.all no longer returns any data?
> > > Switching from your previous setup to a single table inheritance
> > > situation means that mongomapper will be looking in the topics
> > > collection when you do University.all, so I'm not surprised that your
> > > university data would appear to vanish, if you haven't done anything
> > > to move it from its previous collection.
> >
> > > Fred
> >
> > > > I'm using mongomapper and mongodb. The code is pretty big sp I'll
> post
> > > then
> > > > only if necessarily. I think this must be easy to solve.
> >
> > > > ps: I've tried the deprecated _type but didn't work.
> >
> > > > 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 e...@googlegroups.com>
> > > .
> > > For more options, visit this group at
> > >http://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, send email to
> rubyonrails-talk+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/rubyonrails-talk?hl=en.
>
>

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



[Rails] Re: There aren't server in the script folder

2011-01-22 Thread branni
Yes,
But the problems was with the rails server, that I hadn't got
libmysql.dll, after I copy that it works.
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: Problem with relative URLs and AJAX requests.

2011-01-22 Thread Kai Schlamp
On Jan 22, 8:07 am, Marnen Laibow-Koser  wrote:
> KaiSchlampwrote in post #976711:
>
> > Uuups, I just found out that HTML links behave the same way ... it
> > seems I am too pampered with Rails link helpers ;-)
>
> Apparently so.  If you don't understand relative URLs, you have no
> business doing Web development.

Thanks for the suggestion :-P

> > But I still wonder
> > what the easiest way would be to build correct URLs for Javascript
> > then.
>
> Use absolute URLs (the *_url helpers will produce these).

That is not an option for Javascript files that live in public/
javascript, as those won't be generated. An option I guess would be to
set some kind of data-url tag and query that by using Javascript. But
I handle it the pure Javascript way now with a little helper function.

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



[Rails] Re: - Model Inheritance

2011-01-22 Thread Frederick Cheung


On Jan 22, 3:39 am, Pedro Bernardes  wrote:
> This is exactly it, I'm trying to add the topics behavior to the default
> behavior of universities and University.all just returns []
>
> How do I change the University? I was unable to find references to it.
>

I've only dabbled with mongomapper, but my understanding is that if
you move from two separate collections to a single collection
inheritance setup, you're going to need to move all the data from the
old universities collection to the topics collection

Fred

> 2011/1/21 Frederick Cheung 
>
>
>
>
>
> > On Jan 21, 10:03 pm, Pedro Bernardes  wrote:
> > > Hi, I'm new to this list and to rails, so I'm sorry if this subject is
> > > repetead or too obvious.
>
> > > I have two models: Topic and University, both in production. I want to
> > make
> > > University to inherit from Topic, but when I do this:
>
> > >       University < Topic
>
> > > My universities data just disapear (and reapears if the changes are
> > undone).
>
> > Are you trying to setup a single table inheritance type thing? When
> > you say that your universities data disappears, do you mean that
> > University.all no longer returns any data?
> > Switching from your previous setup to a single table inheritance
> > situation means that mongomapper will be looking in the topics
> > collection when you do University.all, so I'm not surprised that your
> > university data would appear to vanish, if you haven't done anything
> > to move it from its previous collection.
>
> > Fred
>
> > > I'm using mongomapper and mongodb. The code is pretty big sp I'll post
> > then
> > > only if necessarily. I think this must be easy to solve.
>
> > > ps: I've tried the deprecated _type but didn't work.
>
> > > 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 > e...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/rubyonrails-talk?hl=en.

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



[Rails] Relationship modelling problem

2011-01-22 Thread Craig Leppan
I have battled with this for ages and would love some guidance

I am building an app that has:
Companies
Products

A product belongs to a company and a company has many products and
hence: this company is a supplier

A company has many products and hence is a client

Every-time I give all relationships in the models it breaks and I think
its due to the fact that the logic is broken as the separation of
weather I am calling for clients or suppliers is not there and the model
as I see it is broken because of the ambiguity

My models look as follows:

Company
has many products
has many assignments
has many products through assignments

Products
belongs to company
has many assignments
has many companies through assignments

Assignments
belongs to company
belongs to product

What is the best way to implement this and what controller do I use to
call what relationship and how do I separate the difference of calling
clients or suppliers (both being companies)

I have been at this for ages and am at my bitter end in terms of trying
to work it out myself

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

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



[Rails] Dynamic routes

2011-01-22 Thread Yan M.
Hello !
I have a question.
I'm on Rails 3 and I'want to add dynamic routes in my Application.
I am succesuful with : File.open on a file : config/routes.rb but i'am
not satisfied by way.
Can not you do anything else to add a new dynamic route?
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.