[Rails] Need guidance in fetching data using each

2015-11-05 Thread Deepak Sharma
In my app I have 3 tables Patient, Department and Consultant. In patient table I have passed foreign key of other other two tables. Now, In my index view of patient I'm able to fetch data of department table with each loop : <% @departments.each do |d| %> <% @patient =

[Rails] Looking for a Ruby on Rails Developer- NYC Direct hire Full Time Role

2015-11-05 Thread Jennifer SB
Hi everyone, I am looking for a Senior Ruby on Rails Developer for a client in NYC. They are growing quickly. They are looking for a Senior Developer with atleast 5 years Development experience, and 3 Years ROR experience. They are unable to sponsor at this time. They are paying top dollar

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Deepak Sharma
On Thu, Nov 5, 2015 at 3:41 PM, Colin Law wrote: > You should not be using Patient.where here, rails will do this for you > if you setup the associations correctly. It should be something like > <% @departments.each do |d| %> > <% d.patients.each do |patient| %> > Such is

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Deepak Sharma
# Patient class Patient < ActiveRecord::Base belongs_to :department belongs_to :consultant end # Consultant class Consultant < ActiveRecord::Base has_many :patients end # Department class Department < ActiveRecord::Base has_many :patients end -- You received this message because you

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Colin Law
On 5 November 2015 at 09:39, Deepak Sharma wrote: > In my app I have 3 tables Patient, Department and Consultant. In > patient table I have passed foreign key of other other two tables. > Now, In my index view of patient I'm able to fetch data of department > table with

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Colin Law
On 5 November 2015 at 10:32, Deepak Sharma wrote: > ... > Now I want to fetch > same for consultant table i.e fetching consultant data in patient index > file. > > Rough example : > > > <% @departments.each do |d| %> > <% d.patients.each do |patient| %> >

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Deepak Sharma
On Thu, Nov 5, 2015 at 4:15 PM, Colin Law wrote: > > What is the relationship between consultants and patients, that is in > terms of has_many, belongs_to etc? # Patient -- Cheers! Deepak Kumar Sharma Guru Nanak Dev Engineering College India! Blog:

Re: [Rails] Need guidance in fetching data using each

2015-11-05 Thread Colin Law
On 5 November 2015 at 10:48, Deepak Sharma wrote: > # Patient > > class Patient < ActiveRecord::Base > belongs_to :department > belongs_to :consultant > end > > # Consultant > > class Consultant < ActiveRecord::Base > has_many :patients > end > > # Department > >

[Rails] Re: Active Record has_one through

2015-11-05 Thread Chris Berry
Turns out the event table needed to have an artist_id column. I was attempting to use the join table without a reference to the artist table. I dont know if that was the fix, because i also wrote a function in the event model that used the artist_id to return artist data from the database.

Re: [Rails] one liner with rescue is good style ?

2015-11-05 Thread wbsurf...@yahoo.com
rqstate is as follows, if there is not a quote request or the status field is null then we could assume that the request was never submitted to the backend api. This was actually the first time I tried this approach but I am not sure I will keep it this way def rqstate

Re: [Rails] one liner with rescue is good style ?

2015-11-05 Thread wbsurf...@yahoo.com
I know you can define actions as a block inside of rescue but that wasn't what I meant -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to

Re: [Rails] one liner with rescue is good style ?

2015-11-05 Thread wbsurf...@yahoo.com
instead of this: def rqstate self.quote_request.status rescue "unsubmitted" end I'm going for this, though maybe there is a good one liner I overlooked ? def rqstate ret_res = "unsubmitted" ret_res = quote_request.status || ret_res if quote_request ret_res end -- You

[Rails] one liner with rescue is good style ?

2015-11-05 Thread wbsurf...@yahoo.com
I was reading some ruby one liners. The rescue style seems to make it easy to write short pieces of code, but it feels like I am forcing an error and then just ignoring it in some cases. I guess I am an older programmer and was never encouraged to write this sort of code, but do most people

[Rails] Free Ruby on Rails Webinar

2015-11-05 Thread Jakub Paluch
Check out Free Ruby on Rails Webinar. If You want to take your first steps with Ruby on Rails, it is the perfect place to start. If You have any questions, just PM me. http://www.clab.type.pl/rails2/invitation/?utm_campaign=kuba -- You received this message because you are subscribed to

Re: [Rails] one liner with rescue is good style ?

2015-11-05 Thread Eric Lavigne
This is terrible style and is strictly forbidden in our codebase. In the example below, probably the programmer thought that an exception always meant that quote_responses was nil instead of an array, and that nil should be treated as an empty array. That works fine... until another source of

[Rails] [Online course in Ror]

2015-11-05 Thread chmielu831
If you are interested in Ruby on Rails programming, this course is for you. Free webinars every week. https://www.facebook.com/events/776917185774221/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and

[Rails] Where do I put plain old Ruby objects?

2015-11-05 Thread Josh Marchello
Hey all, I've been doing rails for a couple years now but this is my first time in the mailing list. My question is this: I've got a little objects housing some data, more or less like a struct with an initializer. What is the "Rails way" regarding arbitrary objects like this? Do I just