Re: [Rails] help with rotues

2011-03-19 Thread Lorenzo Brito Morales
YOu dont have to update route. It just returns the json. YOu can see
it in the html.

On Sun, Mar 20, 2011 at 12:06 AM, Quee WM  wrote:
> in my cities controller I have
>
> def for_provinceid
>  @cities = City.where("active = true && province_id = ?",
> params[:id]).sort_by{ |k| k['name'] }
>  respond_to do |format|
>    format.json  { render :json => @cities }
>  end
> end
>
> and in my zones controller I have
>
> def for_cityid
>  @zones = Zone.where("active = true && city_id = ?",
> params[:id]).sort_by{ |k| k['name'] }
>  respond_to do |format|
>    format.json  { render :json => @zones }
>  end
> end
>
> how do i update my routes file that i can access the jason returned by
> these two actions.
>
> --
> 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] help with rotues

2011-03-19 Thread Quee WM
in my cities controller I have

def for_provinceid
  @cities = City.where("active = true && province_id = ?",
params[:id]).sort_by{ |k| k['name'] }
  respond_to do |format|
format.json  { render :json => @cities }
  end
end

and in my zones controller I have

def for_cityid
  @zones = Zone.where("active = true && city_id = ?",
params[:id]).sort_by{ |k| k['name'] }
  respond_to do |format|
format.json  { render :json => @zones }
  end
end

how do i update my routes file that i can access the jason returned by
these two actions.

-- 
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: Service Management

2011-03-19 Thread Fustbariclation


On Mar 19, 6:17 pm, Chris Kottom  wrote:
> I'm not necessarily an ITIL expert, but I've worked in environments and on
> projects where it was essential (technical infrastructure architecture, help
> desk application implementation) so I can probably get you pointed in the
> right direction.  But because this has been a subject of real interest over
> the past few years as Ruby and Rails have matured for serious application
> development, there's a lot of information available out there, so don't stop
> your investigation here.
>
Thank you for all that - it's extremely helpful!

Design is a big area, I agree. I'm meaning all of it, really. You've
answered quite a bit already with your references to architectural
design.

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

2011-03-19 Thread Bryan Crossland
On Sat, Mar 19, 2011 at 11:45 PM, Bryan Crossland wrote:

> On Sat, Mar 19, 2011 at 3:02 PM, Bartek Iwaszkiewicz <
> bartek.iwaszkiew...@gmail.com> wrote:
>
>>  W dniu 2011-03-19 20:32, Frederick Cheung pisze:
>>
>>
>>> On 19 Mar 2011, at 17:23, "rails.rookie"
>>>  wrote:
>>>
>>>  Hi, i have two models:

 User<...
   has_many :photos, :dependent =>  :destroy
   ...

 Photo<...
   belongs_to :user
   ...

 and I need Attribute model such as each photo has many attributes.
 And here I'm not sure whether Attribute should be has_many: photos or
 belongs_to :photo.

>>> Can you give some examples of what your attributes are? You probably want
>>> to avoid calling the association attributes - that will collide with an
>>> internal activerecord method.
>>>
>>> Fred
>>>
>> App has to work in this way, user add photo and then add attributes to
>> photo on example (Baltic Sea.jpg; sea, water, sand ).
>> Then usning Formal concept analysis (not relevant) special paris are
>> created {(photo,...,photo n),(attribute,...,attribute n)}
>> and it should be remember in some way (i suppose best will be another
>> table), because it will be modefied when photo table or
>> attribute table will change.
>> I can't find out the best way how associations between models should look
>> like and how many models i need.
>>
>
> You are going to want to do a has_many in the Photo model to PhotoAttribute
> model. This will allow you to have the PhotoAttribute model be a list of all
> the attributes that a photo can have. From what you explained this sound
> like what you wanted to do with that table anyway. Your final models would
> look like this:
>
> class User < ActiverRecord::Base
>
>   has_many :photos, :dependent =>  :destroy
> end
>
> class Photo < ActiveRecord::Base
>   belongs_to :user
>   has_many :photo_attributes
> end
>
> class PhotoAttribute < ActiveRecord::Base
>



Sorry, I hit "Send" before I finished typing and proofing. Below is the
corrected and finished model layout. You don't want to use Attribute as the
name of a model or table.

class User < ActiverRecord::Base

  has_many :photos, :dependent =>  :destroy
end

class Photo < ActiveRecord::Base
  belongs_to :user
  has_many :photo_attributes
end

class PhotoAttribute < ActiveRecord::Base
  belongs_to :photo
  belongs_to :photo_descriptor
end

class PhotoDescriptor < ActiveRecord::Base
  has_many :photo_attributes
end


Your PhotoDescriptor model would be the list of descriptions/attributes
found in the photo (sea,green,sand,etc.).


B.

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



Re: [Rails] problem with Associations idea

2011-03-19 Thread Bryan Crossland
On Sat, Mar 19, 2011 at 3:02 PM, Bartek Iwaszkiewicz <
bartek.iwaszkiew...@gmail.com> wrote:

>  W dniu 2011-03-19 20:32, Frederick Cheung pisze:
>
>
>> On 19 Mar 2011, at 17:23, "rails.rookie"
>>  wrote:
>>
>>  Hi, i have two models:
>>>
>>> User<...
>>>   has_many :photos, :dependent =>  :destroy
>>>   ...
>>>
>>> Photo<...
>>>   belongs_to :user
>>>   ...
>>>
>>> and I need Attribute model such as each photo has many attributes.
>>> And here I'm not sure whether Attribute should be has_many: photos or
>>> belongs_to :photo.
>>>
>> Can you give some examples of what your attributes are? You probably want
>> to avoid calling the association attributes - that will collide with an
>> internal activerecord method.
>>
>> Fred
>>
> App has to work in this way, user add photo and then add attributes to
> photo on example (Baltic Sea.jpg; sea, water, sand ).
> Then usning Formal concept analysis (not relevant) special paris are
> created {(photo,...,photo n),(attribute,...,attribute n)}
> and it should be remember in some way (i suppose best will be another
> table), because it will be modefied when photo table or
> attribute table will change.
> I can't find out the best way how associations between models should look
> like and how many models i need.
>

You are going to want to do a has_many in the Photo model to PhotoAttribute
model. This will allow you to have the PhotoAttribute model be a list of all
the attributes that a photo can have. From what you explained this sound
like what you wanted to do with that table anyway. Your final models would
look like this:

class User < ActiverRecord::Base
  has_many :photos, :dependent =>  :destroy
end

class Photo < ActiveRecord::Base
  belongs_to :user
  has_many :photo_attributes
end

class PhotoAttribute < ActiveRecord::Base

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

2011-03-19 Thread Neelesh Ramputh
Hello,

I got 3 models,

1) Post
2) PostTag
3) Tag

When creating/assigning tags in model Post, using tags <<
new_or_existing_tag, I need to specify an additional attribute for the
join table.

How do i specify the attribute.

Thanks.
Neelesh

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



[Rails] Routing issue

2011-03-19 Thread Linus Pettersson
Hi!

I have two models, artists and songs.

I have this in my route file:
  resources :artists, :path => "ackord" do
resources :songs
  end

Which gives me urls like this (I'm using https://github.com/norman/friendly_id
to create and manage slugs):
example.com/ackord/artistname/songs/songname-id

Now I want to remove the /songs part to get a url like this:
example.com/ackord/artistname/songname-id

Is it possible? I have tried to do it with match without success.

Any ideas?

Best Regards
Linus

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

2011-03-19 Thread Patrick L.
Hello all,
My application uses the OAuth2 gem (0.1.1) to connect to Facebook, and
the ActiveMerchant gem (1.12.0) to connect to PayPal. Under what is the
current Rails/Ruby distribution, both of these gems throw the following
OpenSSL::SSL::SSLError when used:

* SSL_connect returned=1 errno=0 state=SSLv3 read server certificate
B: certificate verify failed

I did some digging, and found two patches. The first involves plugging
this into my initializers folder as "faraday.rb" (http://bit.ly/hZqNwQ).
The OAuth2 (Facebook) side of things does work with this patch. However,
the ActiveMerchant (PayPal) code still throws the same SSL_connect
error.

The second patch I've tried (unsuccessfully) is the
'always_verify_ssl_certificates' gem (http://bit.ly/dXmuUh). I did the
following things: (1) gem 'always_verify_ssl_certificates' in the
Gemfile (2) require 'always_verify_ssl_certificates' in the
ApplicationController file. However, both OAuth2 (Facebook) and
ActiveMerchant (PayPal) throw the following TypeError:

* wrong argument (NilClass)! (Expected kind of
OpenSSL::SSL::SSLContext)

Here are the links to my OAuth2 Facebook code (http://bit.ly/hRO0Yf) and
my ActiveMerchant PayPal code (http://bit.ly/hQzdp6) as they stand now.
This is after following the 2010 OAuth2 guide by Michael Bleigh and the
2008 Cody Fauser ActiveMerchant tutorial. Any help is greatly
appreciated! I'm very confused at this point.

-- 
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] Best practice question

2011-03-19 Thread Kristinn Örn Sigurðsson
Hi fellow rails users. :-)

I'm starting to create a rails based application. It must be plugin based
with authorization.

I know of some authorization plugins which I will look at. My question is
only about the best practice of making a plugin based application.

Users must be able to create an instance of the application online and will
be able to select which plugins they want to have included in their instance
of the application.

I'm a little confused. Is it best to use the plugin architecture that is
built in rails do achieve this? How would I go around enabling/disabling
plugin loading dynamically?

All help is greatly appreciated!

Kveðja / Best regards,
Kristinn Örn Sigurðsson.

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



[Rails] Re: Check if within a transaction?

2011-03-19 Thread Michael Schuerig
On Saturday 19 March 2011, GS wrote:
> is it possible to / how can you check if you are currently within a
> transaction?
> 
> I'd like a method to raise an error if it is called from outside of a
> transaction, but run normally otherwise.

You could just wrap the code in your method in a transaction block. As 
the docs say:

  +transaction+ calls can be nested. By default, this makes all database
  statements in the nested transaction block become part of the parent
  transaction.

I.e., a nested transaction block does *not* result in a nested 
transaction. If you want the latter, you have to use 
transaction(:requires_new => true).

Michael

-- 
Michael Schuerig
mailto:mich...@schuerig.de
http://www.schuerig.de/michael/

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

2011-03-19 Thread Bartek Iwaszkiewicz

 W dniu 2011-03-19 20:32, Frederick Cheung pisze:


On 19 Mar 2011, at 17:23, "rails.rookie"  wrote:


Hi, i have two models:

User<...
   has_many :photos, :dependent =>  :destroy
   ...

Photo<...
   belongs_to :user
   ...

and I need Attribute model such as each photo has many attributes.
And here I'm not sure whether Attribute should be has_many: photos or
belongs_to :photo.

Can you give some examples of what your attributes are? You probably want to 
avoid calling the association attributes - that will collide with an internal 
activerecord method.

Fred
App has to work in this way, user add photo and then add attributes to 
photo on example (Baltic Sea.jpg; sea, water, sand ).
Then usning Formal concept analysis (not relevant) special paris are 
created {(photo,...,photo n),(attribute,...,attribute n)}
and it should be remember in some way (i suppose best will be another 
table), because it will be modefied when photo table or

attribute table will change.
I can't find out the best way how associations between models should 
look like and how many models i need.


Bartek.

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

2011-03-19 Thread Frederick Cheung


On 19 Mar 2011, at 18:40, Kedar Mhaswade  wrote:

> I found some questions posted in this regard in the past, but I
> couldn't find anything conclusive. Hence this post, with two
> questions. This is in context of Rails 3.x.
> 
> 2. If it is the former, how do I specify custom messages when a
> particular validation fails? Any examples? What if I need to have
> different messages for different criteria (e.g. with :presence and
> with :format)?
> 

Instead of :presence => true you should be able to say :presence => {...}

and specify options for that validation (such as the message) in the hash

Fred
> Thanks in advance,
> Kedar
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, 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] Check if within a transaction?

2011-03-19 Thread Frederick Cheung


On 19 Mar 2011, at 19:30, GS  wrote:

> is it possible to / how can you check if you are currently within a
> transaction?

You could check connection.open_transactions
On postgres you can ask the adapter directly if my memory is correct

Fred
> 
> I'd like a method to raise an error if it is called from outside of a
> transaction, but run normally otherwise.
> 
> Checking the transaction documentation:
> 
> http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html
> 
> I don't see a way to accomplish this...?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, 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] problem with Associations idea

2011-03-19 Thread Frederick Cheung


On 19 Mar 2011, at 17:23, "rails.rookie"  wrote:

> Hi, i have two models:
> 
> User<...
>   has_many :photos, :dependent => :destroy
>   ...
> 
> Photo<...
>   belongs_to :user
>   ...
> 
> and I need Attribute model such as each photo has many attributes.
> And here I'm not sure whether Attribute should be has_many: photos or
> belongs_to :photo.
Can you give some examples of what your attributes are? You probably want to 
avoid calling the association attributes - that will collide with an internal 
activerecord method. 

Fred


> Moreover i need to use on photos and attributes FCA algorism to build
> lattice and perhaps write it to db.
>   So do I need next model (eg. Lattice), maybe I should use
> has_many :through ?
> I use rails three weeks so I please for help as simple example
> ( doesn't have to be pro :) )
> how to associate these models.
>   Thank you in advance 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.
> 

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



[Rails] Check if within a transaction?

2011-03-19 Thread GS
is it possible to / how can you check if you are currently within a
transaction?

I'd like a method to raise an error if it is called from outside of a
transaction, but run normally otherwise.

Checking the transaction documentation:

http://api.rubyonrails.org/classes/ActiveRecord/Transactions/ClassMethods.html

I don't see a way to accomplish this...?

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



[Rails] problem with Associations idea

2011-03-19 Thread rails.rookie
Hi, i have two models:

User<...
   has_many :photos, :dependent => :destroy
   ...

Photo<...
   belongs_to :user
   ...

and I need Attribute model such as each photo has many attributes.
And here I'm not sure whether Attribute should be has_many: photos or
belongs_to :photo.
Moreover i need to use on photos and attributes FCA algorism to build
lattice and perhaps write it to db.
   So do I need next model (eg. Lattice), maybe I should use
has_many :through ?
I use rails three weeks so I please for help as simple example
( doesn't have to be pro :) )
how to associate these models.
   Thank you in advance 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] Bash script run rudy script

2011-03-19 Thread Curtis j Schofield
>
>> /usr/bin/ruby "/backups/s3sync/s3sync.rb -r -s --progress
>> /backups/cpbackup/weekly redwood_server:cpanel/$CYEAR/$CMONTH/$CDAY/"
>
> I don't think you want to quote that entire string :-)
>

i concur.

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



[Rails] :message with new style validates?

2011-03-19 Thread Kedar Mhaswade
I found some questions posted in this regard in the past, but I
couldn't find anything conclusive. Hence this post, with two
questions. This is in context of Rails 3.x.

1. Is it recommended (as a matter of "style") to use the
"validates :name, :presence => true" instead of more verbose
"validates_presence_of :name"? (RailsGuides promotes the latter, I
think)
2. If it is the former, how do I specify custom messages when a
particular validation fails? Any examples? What if I need to have
different messages for different criteria (e.g. with :presence and
with :format)?

Thanks in advance,
Kedar

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

2011-03-19 Thread Ralph Shnelvar
Saturday, March 19, 2011, 11:12:58 AM, you wrote:

CL> On 19 March 2011 16:47, Ralph Shnelvar  wrote:
>> Is there a way in Rails to get the duration (minutes, seconds, etc.) of
>> a flash video?  I want to display the amount of time to the users before
>> they start playing it or downloading it.

CL> Do you know a way of determining the time via command line?

Colin, I do not know how to do so.

I was hoping there was a gem to help me do it.

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



[Rails] Re: Hierarchical URLs

2011-03-19 Thread Linus Pettersson
Ah!

Found this video at Railscasts (of course... :) )
http://media.railscasts.com/videos/203_routing_in_rails_3.mov

Regards
Linus

On 19 mar, 17:47, Linus Pettersson  wrote:
> Hi!
>
> I have two models, artists and songs. Each artist has, of course, many
> songs and each song belongs to one artist. Everything is working fine
> but I want to make my urls look a bit different. I'm very new to Ruby
> and RoR.
>
> Right now my urls looks like this:
> example.com/artists/1    #Listing all of the songs that is related to
> this artist
> example.com/songs/1    #Showing a song
>
> What I want is something like this:
> example.com/music/artist_name/song_name-id
>
> I have tried to find info about this but I don't really know what to
> search for.
>
> Best Regards
> Linus

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

2011-03-19 Thread Colin Law
On 19 March 2011 16:47, Ralph Shnelvar  wrote:
> Is there a way in Rails to get the duration (minutes, seconds, etc.) of
> a flash video?  I want to display the amount of time to the users before
> they start playing it or downloading it.

Do you know a way of determining the time via command line?

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] Hierarchical URLs

2011-03-19 Thread Linus Pettersson
Hi!

I have two models, artists and songs. Each artist has, of course, many
songs and each song belongs to one artist. Everything is working fine
but I want to make my urls look a bit different. I'm very new to Ruby
and RoR.

Right now my urls looks like this:
example.com/artists/1#Listing all of the songs that is related to
this artist
example.com/songs/1#Showing a song

What I want is something like this:
example.com/music/artist_name/song_name-id

I have tried to find info about this but I don't really know what to
search for.

Best Regards
Linus

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



[Rails] flash duration

2011-03-19 Thread Ralph Shnelvar
Is there a way in Rails to get the duration (minutes, seconds, etc.) of
a flash video?  I want to display the amount of time to the users before
they start playing it or downloading it.

I control the flash video and it is in my public directory.

There are many video clips and they change frequently and I don't want
to
have to look at them and store the length when I copy the file over.

-- 
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] [ANN] Ruby on Rails CommunityGuides

2011-03-19 Thread Markus Proske
Dear all,

I am happy to announce Ruby on Rails CommunityGuides located at 
http://www.communityguides.eu

Ruby on Rails CommunityGuides follows the purpose of giving back to open 
source - more specific, to the Rails community. It has been built to provide 
a basis to share knowledge on Ruby on Rails development. Developers from all 
over the world can share their knowledge easily and gain profit from the 
knowledge of other developers. All content is free and published under a 
Creative Commons license.

CommunityGuides already contains a series of twelve articles that describe 
the whole process of creating CommunityGuides. It covers topics such as the 
model-view- controller principle, routes, unit and functional tests, test 
driven development, search, pagination, security aspects, Devise, Omniauth, 
reCAPTCHA, Heroku and many more.

Any feedback will be most welcome, as well as contributions to 
CommunityGuides!

Kind regards
Markus

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

2011-03-19 Thread Chris Kottom
I'm not necessarily an ITIL expert, but I've worked in environments and on
projects where it was essential (technical infrastructure architecture, help
desk application implementation) so I can probably get you pointed in the
right direction.  But because this has been a subject of real interest over
the past few years as Ruby and Rails have matured for serious application
development, there's a lot of information available out there, so don't stop
your investigation here.

There are a lot of different tools that are used for managing Rails
applications.  The best known paid options are probably New Relic RPM (
http://newrelic.com/) and Scout (https://scoutapp.com/) but there are plenty
of open source options that are also used in various combinations (Monit,
Nagios, Ganglia, ...)  The free options will cover infrastructure
status/history and basic service availability just fine.  If you need more
advanced features like performance management, troubleshooting, and inputs
for capacity planning, you might be better served by the paid applications.

As far as scaling goes, there was a series of videos and podcasts done a few
years back called Scaling Rails (http://railslab.newrelic.com/scaling-rails)
that describes a lot of the basic techniques used to improve performance.  A
lot of these have to do with caching and avoiding DB hits whenever possible.
 Beyond that though, I think it still comes down to good architectural
practices like DB management, application layering and partitioning, etc.
 For my money, Cal Henderson's book Building Scalable Web Applications (
http://oreilly.com/catalog/9780596102357) is still the best place to start
reading if you're looking for best practices for web applications in
general.  There was a Rails specific title dealing with scaling and
deployment available a few years back that's now out of print (
http://pragprog.com/titles/fr_deploy/deploying-rails-applications).

Design is too general.  You'd need to be more specific about what you mean
by that.

Testing is an area that's taken very seriously with a lot of competing and
complementary testing tools available.  Get started with the official Rails
guide to testing (http://guides.rubyonrails.org/testing.html) and then if
you're interested in going deeper check out Rails Test Prescriptions (
http://pragprog.com/titles/nrtest/rails-test-prescriptions) and the Rspec
Book (http://pragprog.com/titles/achbd/the-rspec-book).

On Sat, Mar 19, 2011 at 11:21 AM, Fustbariclation <
peter.h.m.bro...@gmail.com> wrote:

> I was just wondering if there was anybody here who'd worked in a
> Service Management environment (ITIL for example).
>
> I'm interested to know of tools for use with planning and managing
> availability, capacity, continuity and security in a RoR environment.
> Particularly the first two.
>
> How easy is it to scale RoR? Can you easily have multiple server
> instances for one service - if so, how do you do it, and what problems
> do there tend to be? How can you predict performance and capacity?
>
> I'm also interested in design and testing considerations.
>
> Much of the above is not, I know, of much direct interest to
> developers, but I'd hope that somebody has been involved with this!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-talk@googlegroups.com.
> To unsubscribe from this group, 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: how to rescue this exception

2011-03-19 Thread Guo Yangguang
pepe wrote in post #988286:
>> [...]but i do not know why nearly
>> all the examples in the book  re-raise the
>> exceptions.i think i have misunderstood the exception in ruby.if an
>> exception raises in the end used method,we generally do a final
>> capture,and no need to reraise,am i right?
>
> You are right. Catching and re-raising the exception is used if you
> want to do something when the exception happens but you don't want to
> fully handle the exception. For example, if you would like to log it
> but you don't want to be responsible for handling the problem. If in
> your case catching the exception to update the flash is enough then
> that's all you need and you don't have to re-raise.

thank you,i have further understood exception under your help,which 
makes me happy.

-- 
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] [JOBS] Senior Ruby on Rails Dev - Mobile Money Startup in Nairobi

2011-03-19 Thread Ben Lyon
Are you an experienced developer who wants to help architect, design
and build the platform that will help revolutionize small and medium
enterprises throughout Africa? Do you enjoy working with fast-paced
startups and tackling challenges head-on? Have you ever wanted to live
and work in East Africa? If so, we have an opportunity for you.

About Us
Kopo Kopo is an early-stage, technology-focused startup creating a
platform that will revolutionize the way enterprises connect with
mobile money systems in Africa and beyond. Our organization is looking
for an experienced Ruby / Rails developer who can assist our CTO in
building a compelling, feature-rich platform and is willing to work in
Nairobi.

Responsibilities Include:
 Write efficient and sustainable code
 Demonstrate progress through an iterative development life cycle
 Provide insight on design and architecture plans

Ideal candidate
 At least 5-10 years experience
 5+ years as a java developer
 Experience with a scripting language (Perl, Python, Ruby)
 Understands SSL, PGP and other security concepts
 HTML, CSS, JavaScript (jquery)
 Familiar with human-centered designed process
 Experience using an open source platform (Linux, Apache, MySql)
 Familiarity with Scrum (Agile) development methodology
 Some experience with JavaScript (AJAX)
 Solid track record of execution
 Can-do attitude
 Passionate about our organization’s mission
 Willing to relocate to Nairobi and work out of the iHub
(www.ihub.co.ke)

Compensation & Benefits
 This is a contract position offering a month-to-month compensation
package commensurate with the candidate’s skill level and experience.
Stock options included.

If interested…
 Send email to dy...@kopokopo.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] Service Management

2011-03-19 Thread Fustbariclation
I was just wondering if there was anybody here who'd worked in a
Service Management environment (ITIL for example).

I'm interested to know of tools for use with planning and managing
availability, capacity, continuity and security in a RoR environment.
Particularly the first two.

How easy is it to scale RoR? Can you easily have multiple server
instances for one service - if so, how do you do it, and what problems
do there tend to be? How can you predict performance and capacity?

I'm also interested in design and testing considerations.

Much of the above is not, I know, of much direct interest to
developers, but I'd hope that somebody has been involved with this!

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

2011-03-19 Thread Hassan Schroeder
On Sat, Mar 19, 2011 at 3:13 AM, Rob S.  wrote:

> /usr/bin/ruby: No such file or directory -- /backups/s3sync/s3sync.rb -r
> -s --progress /backups/cpbackup/weekly redwood_server:cpanel/11/03/19/
> (LoadError)

> /usr/bin/ruby "/backups/s3sync/s3sync.rb -r -s --progress
> /backups/cpbackup/weekly redwood_server:cpanel/$CYEAR/$CMONTH/$CDAY/"

I don't think you want to quote that entire string :-)

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

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



[Rails] Re: how to rescue this exception

2011-03-19 Thread pepe
> [...]but i do not know why nearly
> all the examples in the book  re-raise the
> exceptions.i think i have misunderstood the exception in ruby.if an
> exception raises in the end used method,we generally do a final
> capture,and no need to reraise,am i right?

You are right. Catching and re-raising the exception is used if you
want to do something when the exception happens but you don't want to
fully handle the exception. For example, if you would like to log it
but you don't want to be responsible for handling the problem. If in
your case catching the exception to update the flash is enough then
that's all you need and you don't have to re-raise.

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

2011-03-19 Thread Bryan Crossland
On Mar 18, 2011, at 5:51 PM, Carl Jenkins  wrote:

> Kedar Mhaswade wrote in post #988237:
>> Carl Jenkins wrote in post #988231:
>>> I am trying to get Ruby/Rails running on my mac but having some issues.
>>> 
>>> 
>>> I created a new rails project "blog_test" trying to get something
>>> working.
>>> When I follow this guide
>>> http://guides.rubyonrails.org/getting_started.html it says to do a
>>> "db:create". This is where I get this error...
>>> 
>>> Could not find gem 'sqlite3 (>= 0)' in any of the gem sources listed in
>>> your Gemfile.
>> 
>>> sqlite3-ruby (1.2.4)
>>> termios (0.9.4)
>> 
>> Maybe doing gem install sqlite3 fixes it?
> 
> I did a gem install sqlite3

Did you try sudo gem install sqlite3? 

B.

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



Re: [Rails] Re: deploying change made to a .haml file

2011-03-19 Thread radhames brito
On Sat, Mar 19, 2011 at 9:21 AM, sal streets  wrote:

> hi guys,
>
> thanks for your help.
>
> i have figured out that the front page of www.threadme.co.uk is actually
> a jpg. so the changes that i had made did register instantly, it's just
> that the jpg was unaffected (i guess this will be in the style sheets
> somewhere).
>
> i will look into all your advice and try to absrob it into my head.
>
> cheers
>
>
nice to know you solved the issue, but dont forget to read about capistrano
it will make everything easier for the future.

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



[Rails] Re: deploying change made to a .haml file

2011-03-19 Thread sal streets
hi guys,

thanks for your help.

i have figured out that the front page of www.threadme.co.uk is actually 
a jpg. so the changes that i had made did register instantly, it's just 
that the jpg was unaffected (i guess this will be in the style sheets 
somewhere).

i will look into all your advice and try to absrob it into my head.

cheers

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

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



Re: [Rails] Re: Back to Basics: Drawing a line between Rails and HTML

2011-03-19 Thread Chris Kottom
All good guidelines.  It's unfortunate that the people who follow this
mailing list most closely (and therefore are most likely to read this post)
are probably the ones who are already adhering to best practices.

On Fri, Mar 18, 2011 at 6:04 PM, dana tassler wrote:

> Well said.  While language barriers may occasionally keep a member
> from asking a question properly, it is TRULY in the best interest of
> the user to ask a well-written, intelligent, pertinent question.  I'm
> a recent college grad and am appalled by the lack of creativity/
> ingenuity/drive displayed by my own student peers.
>
> It seems common enough for people to find a forum and ask a question,
> rather than research the topic themselves.  Personally, I tend to
> exhaust all resources before asking people for help, and then I take
> quite a bit of time in formulating my question.
>
> Recently I joined Stack Overflow (which many of you are likely
> familiar with) and they have very clear information about how to post
> on and use their forums.  Included in this information is scoop about
> asking questions clearly, I think all people who use forums for
> knowledge should adhere to similar policies.
>
> Because really, these forums are our tools and communities combined.
> Abuse them, use them poorly, and they'll probably stop working
> properly for you.
>
> On Mar 18, 10:33 am, Edmond Kachale 
> wrote:
> > Railers (if you allow me to you so),
> >
> > *before_create*
> > 
> > I am not a moderator of Ruby on Rails(RoR) forum, I am not trying to
> become
> > one, and I am not pushing for any moderation of this sort. However, I  am
> a
> > bit worried that some of the questions we get on this forum are not
> really
> > Ruby on Rails questions. In addition, some of questions are already taken
> > care of by the many tutorials that are available online.
> >
> > I know that we have different backgrounds and levels of programming
> > complexity. I am not in any way trying to scare new Rails developers, but
> I
> > think we need to draw a line between RoR and non-RoR questions.
> >
> > *1. Posting Right Questions*
> > ===
> > There are some questions that are not necessarily worthy posting on this
> > forum. For example, questions on how to create HTML elements like
> textboxes,
> > buttons, forms, e.t.c. in Ruby on Rails. These are HTML specific
> questions.
> > If one wants to create them using Rails helpers there are tutorials that
> are
> > dedicated to that. All in all, there are guides on how to do that on
> > rubyonrails.org (for example this one:
> http://guides.rubyonrails.org/form_helpers.html). If one is not sure of
> > something in Ruby on Rails, they may search online first, before posting
> on
> > this forum. Things are happening very fast. It is very likely that most
> of
> > the "general questions" about RoR have been answered via blog posts or
> > various forums already. *We need to know the difference between a search
> > engine and a forum*. Only when there is no tutorial or blog post tackling
> a
> > particular question then we can go ahead posting it here.
> >
> > *2. Differentiating between Ruby and Ruby on Rails Questions*
> > ==
> > This is slightly similar to the first one but I think it needs special
> > treatment. We need to understand that this forum is not a Ruby forum; it
> is
> > a Ruby on Rails forum. I know that this is one of the most difficult
> thing
> > to do on this forum; even myself I admit that I am not good at it but I'm
> > trying my best. Some of the questions that we tend to ask here are Ruby
> > specific. Most of Railers would not love to respond to Ruby questions,
> not
> > because they cannot manage to but because a Ruby forum actually exists
> and
> > this forum is dedicated to seeking help with Rails, announcing Rails
> > projects, and discussing all kind of matters surrounding the Rails
> framework
> > and the community. If we need any help with Ruby related problems or Ruby
> > syntax (such as looping, hashing, mapping (e.g. map, each, inject,
> reduce),
> > e.t.c), let us direct them to the right forum.
> >
> > *3. Framing Questions and Email Titles/Subjects before Posting*
> > ===
> > We need to take our time framing our questions before posting them on
> this
> > forum. Some of the questions do not make real sense at all. It becomes
> hard
> > for us to figure out what someone is looking for, and (I'm sorry to say
> > that) we tend to ignore them. Some of the subjects are too general like
> "I
> > need help" , "I have problems with my Rails application" or "Newbie
> > question". Remember that  questions on this forum are searchable online,
> > posting search engine compatible questions will do us all good. Having
> "good
> > questions" and "straight-forward email subjects" will also help others
> who
> > may be experiencing similar problems like ours. This will help

[Rails] Bash script run rudy script

2011-03-19 Thread Rob S.
Hello

I trying to run a Rudy script from a bash script but it now working.
Can some one help please.  The command runs normally eg if I type

/backups/s3sync/s3sync.rb -r -s --progress /backups/cpbackup/weekly
redwood_server:cpanel/11/03/19/

but went it in the script I get

/usr/bin/ruby: No such file or directory -- /backups/s3sync/s3sync.rb -r
-s --progress /backups/cpbackup/weekly redwood_server:cpanel/11/03/19/
(LoadError)

Here the code I use for the script.

[code]
#!/bin/bash

CYEAR=`date +%y`
CMONTH=`date +%m`
CDAY=`date +%e`

/usr/bin/ruby "/backups/s3sync/s3sync.rb -r -s --progress
/backups/cpbackup/weekly redwood_server:cpanel/$CYEAR/$CMONTH/$CDAY/"
[/code]

-- 
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] Re: Help with find

2011-03-19 Thread Chris Kottom
For slighly more idiomatic Ruby, you could use the attribute name "active"
rather than "is active".  The resulting query would then look something
like:

Province.joins(:cities).where(:active => true).where("cities.active = ?",
true)

On Sat, Mar 19, 2011 at 9:49 AM, Frederick Cheung <
frederick.che...@gmail.com> wrote:

>
>
> On Mar 19, 7:11 am, Quee WM  wrote:
> > I have the following
> >
> > class Province < ActiveRecord::Base
> >   has_many  :cities
> >   attr_accessible :name, :is_active
> > end
> >
> > class City < ActiveRecord::Base
> >   belongs_to  :province
> >   attr_accessible :name, :province_id, :is_active
> > end
> >
> > now I want to get all the provinces with is_active = true which have
> > cities with is_active = true
> >
>
> You should be able to do this using the joins option to find (or in
> rails 3 by calling .joins(...)) to join the cities table to the
> provinces one. You'll then be able to write conditions that refer to
> both tables
>
> Fred
> > please guide me on how this can be done.
> >
> > --
> > 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.
>
>

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



[Rails] Re: Help with find

2011-03-19 Thread Frederick Cheung


On Mar 19, 7:11 am, Quee WM  wrote:
> I have the following
>
> class Province < ActiveRecord::Base
>   has_many  :cities
>   attr_accessible :name, :is_active
> end
>
> class City < ActiveRecord::Base
>   belongs_to  :province
>   attr_accessible :name, :province_id, :is_active
> end
>
> now I want to get all the provinces with is_active = true which have
> cities with is_active = true
>

You should be able to do this using the joins option to find (or in
rails 3 by calling .joins(...)) to join the cities table to the
provinces one. You'll then be able to write conditions that refer to
both tables

Fred
> please guide me on how this can be done.
>
> --
> 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] Help with find

2011-03-19 Thread Quee WM
I have the following

class Province < ActiveRecord::Base
  has_many  :cities
  attr_accessible :name, :is_active
end

class City < ActiveRecord::Base
  belongs_to  :province
  attr_accessible :name, :province_id, :is_active
end

now I want to get all the provinces with is_active = true which have
cities with is_active = true

please guide me on how this can be 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.