[Rails] Re: conditional validates_associated

2013-02-13 Thread Rafael C. de Almeida
On Wednesday, February 13, 2013 12:59:11 PM UTC-2, Matt Jones wrote: > > On Tuesday, 12 February 2013 20:29:49 UTC-5, Rafael C. de Almeida wrote: >> >> Hello, >> >> Have you guys noticed that conditional validation with >> validates_associated does not work wel

[Rails] conditional validates_associated

2013-02-12 Thread Rafael C. de Almeida
Hello, Have you guys noticed that conditional validation with validates_associated does not work well when you are creating a new record? Consider this gist: https://gist.github.com/aflag/4780225 The Lawyer class has validates_associated on address conditioned on whether the Lawyer data comes

[Rails] Re: Nested models in a form

2013-01-13 Thread Rafael C. de Almeida
ce_ids in attr_accessible and accept_nested_attributes_for :services). On Sunday, January 13, 2013 7:00:55 PM UTC-2, Rafael C. de Almeida wrote: > > I have found out that user[lawyers_attributes][0][service_ids][] works for > the first lawyer (I update 0 to 1 for the second and so on). Howev

[Rails] Re: Nested models in a form

2013-01-13 Thread Rafael C. de Almeida
, Rafael C. de Almeida wrote: > > Hello, > > I'm trying to work with nested models in a form view and it's not going so > smoothly. A user has many lawyers and a lawyer can take many services. I > want a checkbox on which the user can select the services of each lawyer.

[Rails] Nested models in a form

2013-01-13 Thread Rafael C. de Almeida
Hello, I'm trying to work with nested models in a form view and it's not going so smoothly. A user has many lawyers and a lawyer can take many services. I want a checkbox on which the user can select the services of each lawyer. How can I do it? This is what I've got so far: <%= form_for @user

[Rails] Re: Rails' inflections are messy

2012-07-27 Thread Rafael C. de Almeida
ted into a gem (which is what I did), it > would still need to be bundled by default. Inflections are used in routing, > mapping between models and controllers, and a lot of other places within > Rails. They need to be there. > > On Thursday, July 26, 2012 6:21:26 PM UTC-7, Rafae

[Rails] Re: Rails' inflections are messy

2012-07-26 Thread Rafael C. de Almeida
One thing that have always bothered me about the inflector and this pluralize business is that it only work in English. That make rails newbies from non-english speaking countries have a harder time learning the technology than they should. I know ruby's keywords are already in English, and so

[Rails] Rerendering parts of a page with ajax

2012-07-26 Thread Rafael C. de Almeida
Hello guys I have a index of people on my site. There the users can see all the people the site knows about. So I have a view people/index.html.erb. I still haven't done pagination yet -- I'm not sure how's the best way to paginate in rails -- but for now I'm just showing the top 10 (which shou

[Rails] Re: Searching for area code and phone number together

2012-04-25 Thread Rafael C. de Almeida
On Apr 25, 2:41 am, Juan Pablo Avello wrote: > Or, if  phone nos. are different: > > phones = [['31', '32221'0412'], ['32','422020202']].map{|q| > "phones.area_code = #{q[0]} and phones.number = #{q[1]}"}.join(' or ') > Lawyer.includes(:phones).where(phones) That one could lead to injection, I th

[Rails] Re: Searching for area code and phone number together

2012-04-24 Thread Rafael C. de Almeida
On Apr 24, 3:24 pm, Rogerio Medeiros wrote: >  phones = [{area_code:'31', number:'32210412'}, > {area_code:'32', number:'32210412'}] > > lawyers = [] > phones.each do |phone| >   lawyer << Lawyer.joins(:phones).where('phones.area_code = ? and > phones.number ', phone.area_code, phone.number) > end

[Rails] Re: Searching for area code and phone number together

2012-04-24 Thread Rafael C. de Almeida
On Apr 24, 2:55 pm, Rogerio Medeiros wrote: > Phone.where("area_code in (?) and number in (?)", [440,441,443], > [23233233,23231212,12121212]) That would match phone (440) 12121212. In that situation, I'd like to match (440) 23233233, (441) 23231212 and (443) 12121212. However I would not like to

[Rails] Re: Searching for area code and phone number together

2012-04-24 Thread Rafael C. de Almeida
On Apr 24, 5:34 am, vishal singh wrote: > Hi, > > Phone.find(:all, :conditions=>["area_code in ? and number in > ?",(555,533),(533,12345678)]) > That wouldn't work. That would match the phone {area_code:'533',number:'533'}. I want to match only (555, 533) or (533, 12345678). -- You received thi

[Rails] Re: Searching for area code and phone number together

2012-04-24 Thread Rafael C. de Almeida
On Apr 24, 6:06 am, Juan Pablo Avello wrote: > El martes, 24 de abril de 2012 03:56:21 UTC+2, Rafael C. de Almeida > escribió: > > Hello > > > I have two tables: Lawyer and Phone. Phone is separated into area code > > and number. A lawyer has many phones. I wa

[Rails] Re: Searching for area code and phone number together

2012-04-23 Thread Rafael C. de Almeida
On Apr 24, 1:55 am, vishal singh wrote: > hi, > > Make a two model, Lawyer and Phone then in lawyer model add has_any :phones > and in phone model add belongs_to :lawyer > > then find lawler like > >  @lawyer = Lawyer.find(1)   1 is id in lawyer table > > then write >  @lawyer.phones (it will fetc

[Rails] Searching for area code and phone number together

2012-04-23 Thread Rafael C. de Almeida
Hello I have two tables: Lawyer and Phone. Phone is separated into area code and number. A lawyer has many phones. I want to produce a query which searches for lawyers who have a phone matching a phone from a list of phones. If I had only one phone I could search it like this: Lawyer.join(:p

[Rails] Filesystem active record adapter

2010-10-19 Thread Rafael C. de Almeida
Hello, I'm making a site where I'll host a few songs and texts I do. I decided to use RoR, instead of plain HTML, mostly because of the layouts and views. It's much nicer to write the menu HTML only once instead of repeat it across several HTML files. I don't need to tell you that, of course :).